How maheshwarreddy970/corinna-ai works
Main Components
• Frontend (Next.js app router pages & React components in src/app + src/components)
• Backend API / Server Actions (Next.js server-side functions in src/actions + src/app/api)
• Database (Prisma ORM → underlying SQL database via prisma/schema.prisma)
• Authentication (Clerk)
• Real-time Chat (Pusher)
• AI Engine (OpenAI API)
• Payments (Stripe Connect + Stripe API)
• Email (NodeMailer via custom mailer service)
• File Uploads (UploadCare)
Relationships & Data Flows
a. User’s Browser ←→ Next.js Frontend
b. Frontend → Server Actions / API Routes (HTTP / fetch / Server Actions calls)
c. Server Actions → Prisma → Database
d. Server Actions → Clerk SDK (authenticate, user metadata)
e. Server Actions → Pusher (publish/subscribe chat events)
f. Server Actions → OpenAI (chatbot intelligence)
g. Server Actions → Stripe (payment intents, connect accounts)
h. Server Actions → NodeMailer (outgoing emails)
i. Frontend → UploadCare widget (direct uploads)
Architectural Patterns & Design Principles
• Monolithic full-stack: UI & API live under one Next.js codebase
• App Router with React Server & Client components → SSR/ISR where appropriate
• “Actions” folder as service layer: each domain (appointments, auth, bot, etc.) encapsulates business logic
• Domain-based routing (portal routes under /portal/[domainid], dashboard under /dashboard)
• Prisma as the single source of truth for data models
• Environment-driven integration points (Clerk, Stripe, Pusher, OpenAI, UploadCare)
Essential Details to Capture
• Division between pages (/auth, /dashboard, /portal, /blogs, /chatbot) and shared UI library (src/components/ui)
• Central “Service Layer” (src/actions/…) as the orchestrator of business logic
• Middleware (middleware.ts) for domain routing or auth redirection
• Real-time chat loop: Frontend ↔ Pusher ↔ Bot service (OpenAI)
• Payment flow: Frontend → Stripe Connect API route → Stripe → Webhook back to Server Actions → Prisma