Features β’ Quick Start β’ Architecture β’ Documentation β’ Security
Agent-SAFE Grid is a production-ready middleware platform that sits between your application and LLM providers (OpenAI, Google Gemini, Anthropic, etc.). It provides enterprise-grade security, compliance, and observability for AI applications without requiring custom guardrail development.
- π Security First: Built-in PII detection, content filtering, and encryption
- π Observability: Real-time monitoring, audit logs, and analytics
- π° Cost Control: Usage tracking, billing management, and rate limiting
- π― Policy Engine: No-code policy builder for compliance and safety rules
- π Multi-Provider: Support for multiple LLM providers with automatic routing
- π’ Multi-Tenant: Built-in organization and team management
-
π Authentication & Authorization
- JWT-based authentication
- Role-based access control (Owner, Admin, Analyst)
- Multi-tenant architecture with organization isolation
-
π‘οΈ Security & Compliance
- PII detection and redaction
- Input sanitization and validation
- CSRF protection
- Rate limiting
- AES-256-GCM encryption for sensitive data
-
π³ Payment & Billing
- Flexible pricing plans
- Payment gateway integration
- Encrypted bank account storage
- Transaction tracking
- Payout management
-
π¨ Advanced Policy Builder
- Visual policy creation interface
- Custom rule definitions
- JSON Schema validation
- Policy versioning
-
π Monitoring & Analytics
- Real-time audit logs
- Login attempt tracking
- Transaction history
- Usage analytics
-
π§ͺ LLM Integration
- Google Gemini integration
- Playground for testing prompts
- Robustness testing
- Response caching
- Framework: React 18.2 with TypeScript
- Build Tool: Vite 5.0
- Styling: Tailwind CSS 3.4
- Icons: Lucide React
- Charts: Recharts
- Testing: Vitest + Playwright
- Runtime: Node.js 20+ with Express 4.18
- Language: TypeScript 5.3
- Database: PostgreSQL with pg driver
- Authentication: JWT (jsonwebtoken)
- Password Hashing: bcrypt
- Security: Helmet, CORS, express-rate-limit
- Validation: Joi
- LLM Integration: Google Generative AI SDK
erDiagram
organizations ||--o{ users : has
organizations ||--o{ pricing_plans : owns
organizations ||--o{ transactions : conducts
organizations ||--o{ bank_accounts : maintains
organizations ||--o{ payment_gateways : configures
users ||--o{ login_attempts : generates
organizations {
uuid id PK
string name
string slug
string tier
timestamp created_at
}
users {
uuid id PK
uuid tenant_id FK
string email
string password_hash
string name
string role
boolean is_active
timestamp last_login
}
login_attempts {
uuid id PK
string email
boolean success
string ip_address
timestamp attempted_at
}
- Node.js 20.x or higher
- PostgreSQL 12.x or higher
- npm or yarn package manager
-
Clone the repository
git clone https://github.com/ramailo1/agent-safe-grid.git cd agent-safe-grid -
Install dependencies
npm install
-
Configure environment variables
Copy the example environment file:
cp .env.example .env
Edit
.envand configure the following:# Database Configuration DATABASE_URL=postgres://user:password@host:port/database?sslmode=require # Authentication JWT_SECRET=your-secure-jwt-secret-here ENCRYPTION_KEY=your-32-byte-encryption-key-here # Application PORT=3001 NODE_ENV=development # LLM Integration (Optional) VITE_API_KEY=your-gemini-api-key-here
β οΈ Security: Generate secure secrets using:# Generate JWT Secret openssl rand -base64 32 # Generate Encryption Key (must be exactly 32 bytes) openssl rand -base64 32 | head -c 32
-
Initialize the database
The application will automatically create database tables and seed initial data on first run.
-
Start the backend server
npm run server
-
Start the frontend (in a new terminal)
npm run dev
-
Access the application
Open your browser and navigate to:
http://localhost:3000
On first run, a default admin account is created:
- Email:
[email protected] - Password:
SecureAdminPassword123!
β οΈ Important: Change this password immediately after first login!
| Command | Description |
|---|---|
npm run dev |
Start Vite development server (frontend) |
npm run build |
Build production frontend bundle |
npm run preview |
Preview production build |
npm run server |
Start Express backend server |
npm run seed |
Manually seed admin user |
npm run restart-backend |
Restart backend server (Windows PowerShell) |
npm run stop-backend |
Stop backend server (Windows PowerShell) |
npm test |
Run unit tests with Vitest |
npm run test:integration |
Run integration tests |
npm run test:e2e |
Run end-to-end tests with Playwright |
agent-safe-grid/
βββ backend/ # Backend application
β βββ middleware/ # Authentication, validation, CSRF
β βββ routes/ # API routes (auth, gateways, llm)
β βββ services/ # Business logic (encryption, migrations)
β βββ seeds/ # Database seeders
β βββ tests/ # Backend tests
βββ components/ # React components
βββ pages/ # Page components
β βββ AdminDashboard.tsx
β βββ AdvancedPolicyBuilder.tsx
β βββ AuditLogs.tsx
β βββ Billing.tsx
β βββ PayoutDashboard.tsx
β βββ Playground.tsx
β βββ Settings.tsx
β βββ public/ # Public pages (landing, docs)
βββ services/ # Frontend services
βββ utils/ # Utility functions
βββ e2e/ # End-to-end tests
βββ .env # Environment variables (DO NOT COMMIT)
βββ .env.example # Environment template
βββ README.md # This file
- Authentication: JWT tokens with 24-hour expiration
- Password Security: bcrypt hashing with configurable rounds
- Data Encryption: AES-256-GCM for sensitive data (bank accounts)
- Input Validation: Joi schema validation on all API endpoints
- CSRF Protection: Token-based CSRF protection
- Rate Limiting: Configurable rate limits per IP
- SQL Injection Prevention: Parameterized queries
- XSS Protection: Helmet security headers
- Never commit
.envfiles to version control - Rotate secrets regularly (JWT secret, encryption keys)
- Use strong passwords (enforced by password strength validator)
- Enable SSL/TLS in production
- Keep dependencies updated regularly
- Review audit logs for suspicious activity
If you discover a security vulnerability, please email [email protected]. Do not create a public issue.
npm testnpm run test:integrationnpm run test:e2ePlaywright tests cover:
- Authentication flow
- Admin dashboard operations
- Payment processing
- Payout management
- Settings configuration
Login with email and password.
Request Body:
{
"email": "[email protected]",
"password": "SecurePassword123!"
}Response:
{
"token": "jwt-token-here",
"user": {
"id": "uuid",
"email": "[email protected]",
"name": "User Name",
"role": "owner"
},
"organization": {
"id": "uuid",
"name": "Organization Name",
"tier": "enterprise"
}
}Register a new user and organization.
Request password reset (currently mock implementation).
Fetch all pricing plans (active only by default).
Create a new pricing plan (Owner only).
Update a pricing plan (Owner only).
Process a payment charge.
Get bank accounts (encrypted data).
Add a new bank account.
Delete a bank account.
π = Requires authentication token
- Set
NODE_ENV=production - Use production database URL
- Configure secure JWT_SECRET
- Enable SSL/TLS
- Set appropriate CORS origins
npm run buildThis creates an optimized production build in the dist/ directory.
The application automatically runs migrations on startup. For manual control:
npm run serverCheck logs for migration status.
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Use TypeScript for all new code
- Follow existing code formatting
- Add tests for new features
- Update documentation as needed
This project is licensed under the MIT License - see the LICENSE file for details.
- React - Frontend framework
- Express - Backend framework
- PostgreSQL - Database
- Tailwind CSS - Styling
- Google Generative AI - LLM integration
- Documentation: View full documentation
- Issues: GitHub Issues
- Email: [email protected]
- β Buy me a coffee - Support the developer
- πΌ Commercial licensing for business use
- π§ Contact for custom development services
Made with β€οΈ by the Soufienne Rahali