Architecture Overview
System architecture and design
Platform Architecture
Girard AI is built on a modern, scalable architecture designed for enterprise-grade AI automation.
Core Technology Stack
| Layer | Technology | Purpose |
|---|---|---|
| Frontend | Next.js 16 (App Router) | React 19 with Server Components |
| Backend | Next.js API Routes | Server Actions for mutations |
| Database | PostgreSQL (Neon) | Serverless, auto-scaling database |
| Auth | Clerk | Enterprise authentication with SSO |
| AI | Claude, GPT-4, Gemini | Multi-provider AI capabilities |
| Storage | Cloudflare R2 | S3-compatible object storage |
| Queue | Inngest | Background job processing |
| Monitoring | Sentry | Error tracking and APM |
High-Level Data Flow
User Request
↓
Clerk Authentication
↓
Next.js Middleware (rate limiting, org context)
↓
Server Component / API Route
↓
Prisma ORM
↓
PostgreSQL (Neon)
Key Architectural Patterns
1. Multi-Tenant Architecture
- Organization-based isolation
- Row-level security via Prisma middleware
- Per-org billing and rate limits
2. AI Abstraction Layer
- Unified AI interface (
lib/ai/) - Provider-agnostic design
- Automatic fallback handling
3. Event-Driven Processing
- Inngest for background jobs
- Webhook-based integrations
- Real-time updates via polling/SSE
Module Structure
/app # Next.js App Router pages
├── (auth) # Authentication pages
├── (dashboard) # Main dashboard
├── (god-mode) # Admin/God Mode pages
└── api/ # API routes
/lib # Shared libraries
├── ai/ # AI abstractions
├── db.ts # Prisma client
├── email/ # Email services
├── outreach/ # Outreach system
├── scheduling/ # Booking/calendar
└── integrations/ # Third-party integrations
/components # React components
├── ui/ # shadcn/ui base components
├── dashboard/ # Dashboard-specific
└── [feature]/ # Feature-specific components
Environment Configuration
Required environment variables are organized by service:
DATABASE_URL- Neon PostgreSQL connectionCLERK_*- AuthenticationANTHROPIC_API_KEY,OPENAI_API_KEY- AI providersSTRIPE_*- PaymentsR2_*- Storage
See .env.example for complete list.