# chandrakantamandal/sensei architecture

> Architecture diagram of the GitHub repository chandrakantamandal/sensei, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chandrakantamandal/sensei
- Repository: https://github.com/chandrakantamandal/sensei

## Overview

1. **Overall shape**
   - SensAI is a single Next.js 16 App Router application, not a split frontend/backend repo.
   - The app is organized around route groups for unauthenticated marketing/auth flows and authenticated product flows.

2. **Route boundaries**
   - `app/(auth)` contains sign-in and sign-up pages handled through Clerk.
   - `app/(main)` contains the protected product experience: dashboard, onboarding, resume builder, interview practice, and AI cover letters.
   - `app/layout.js` and `app/(main)/layout.jsx` define the top-level and protected-shell layouts; `proxy.js` and `lib/checkUser.js` likely enforce auth/redirect behavior.

3. **Primary product subsystems**
   - **Dashboard**: industry insights, trends, salary ranges, and recommendation content.
   - **Resume**: resume composition with live preview and editing.
   - **Interview**: quiz generation, practice flow, results, and performance tracking.
   - **AI Cover Letter**: generate, preview, list, and open individual cover letters.
   - **Onboarding**: collects user profile data used to personalize the rest of the app.

4. **Server-side business logic**
   - The `actions/` folder is the main domain logic layer.
   - Each file maps to a feature area: `dashboard.js`, `interview.js`, `cover-letter.js`, `resume.js`, and `user.js`.
   - These actions are the main bridge between UI events and backend services such as Prisma, Gemini, and user/session state.

5. **Data persistence**
   - Prisma is the persistence boundary: `prisma/schema.prisma` plus migrations define the application database model.
   - The database is PostgreSQL, and user/profile/generated-content records are likely stored there.
   - `lib/prisma.js` centralizes the Prisma client so feature actions and route handlers can share database access.

6. **AI and external services**
   - Google Gemini is the AI generation backend for dashboard insights, interview questions, cover letters, and resume assistance.
   - Clerk is the identity provider and session system.
   - The app’s core value flow is: authenticated user input → server action → AI generation and/or DB persistence → rendered personalized content.

7. **Background jobs / async processing**
   - The `lib/inggest/` folder, `app/api/inggest/route.js`, and `inggest` naming indicate an Inngest-based job pipeline.
   - This likely handles asynchronous workflows that should not block the UI, such as generation, enrichment, or post-processing.
   - Architecturally, this is a separate event/job boundary from the normal request-response route handlers.

8. **Feature-local UI structure**
   - Each major page keeps its own component set under `_components/` or `_component/`, which keeps feature logic close to the route.
   - Examples: resume builder, interview quiz/results, dashboard view, and cover-letter generator/preview/list.
   - This suggests a vertical-slice structure: route + local components + server actions per feature.

9. **Shared UI and design system**
   - `components/ui/` contains the reusable shadcn/ui primitives used across the app.
   - `components/` also includes top-level pieces like header, footer, hero, theme provider.
   - This layer is presentation-focused and separate from domain logic, so it can be diagrammed as a shared UI foundation.

10. **Static content and content models**
   - `data/` contains prebuilt domain content such as industries, features, FAQs, stats, testimonials, and “how it works.”
   - These datasets likely feed the landing page, onboarding choices, and dashboard recommendations.
   - They form a non-database content source that complements generated and user-specific data.

11. **Validation and form flow**
   - The app uses React Hook Form + Zod, with shared validation definitions in `app/lib/schema.js`.
   - `app/lib/helper.js` and `lib/utils.js` provide shared helpers for formatting and common logic.
   - Form data usually follows: user input → schema validation → server action → persistence/AI generation.

12. **Main end-to-end flows**
   - **Signup/signin → onboarding → personalized main app**
   - **Onboarding/profile data → dashboard/interview/resume/cover-letter personalization**
   - **User input → server action → Gemini/Prisma → saved/generated output → UI preview or history**
   - These are the key paths to show in an architecture diagram, with Clerk, Prisma/Postgres, Gemini, and Inngest as the external/service boundaries.

Main entry points: [`app/(main)/layout.jsx`](https://github.com/chandrakantamandal/sensei/blob/main/app/(main)/layout.jsx) (Main shell), [`lib/prisma.js`](https://github.com/chandrakantamandal/sensei/blob/main/lib/prisma.js) (Prisma client), [`app/(main)/dashboard/page.jsx`](https://github.com/chandrakantamandal/sensei/blob/main/app/(main)/dashboard/page.jsx) (Dashboard), [`actions/dashboard.js`](https://github.com/chandrakantamandal/sensei/blob/main/actions/dashboard.js) (Dashboard logic)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_routes["Routes"]
  node_app_layout["App layout<br/>root layout<br/>[layout.js]"]
  node_main_layout["Main shell<br/>protected layout<br/>[layout.jsx]"]
  node_auth_layout["Auth shell<br/>public layout<br/>[layout.jsx]"]
  node_sign_in["Sign in<br/>auth page<br/>[page.jsx]"]
  node_sign_up["Sign up<br/>auth page<br/>[page.jsx]"]
end

subgraph group_features["Features"]
  node_onboarding["Onboarding<br/>profile flow<br/>[page.jsx]"]
  node_dashboard["Dashboard<br/>insights view<br/>[page.jsx]"]
  node_resume["Resume<br/>builder<br/>[page.jsx]"]
  node_interview["Interview<br/>practice flow<br/>[page.jsx]"]
  node_cover_letter["Cover letters<br/>generator<br/>[page.jsx]"]
end

subgraph group_logic["Server Logic"]
  node_proxy_guard["Proxy guard<br/>auth proxy<br/>[proxy.js]"]
  node_check_user["User check<br/>auth helper<br/>[checkUser.js]"]
  node_dashboard_actions["Dashboard logic<br/>server actions<br/>[dashboard.js]"]
  node_resume_actions["Resume logic<br/>server actions<br/>[resume.js]"]
  node_interview_actions["Interview logic<br/>server actions<br/>[interview.js]"]
  node_cover_letter_actions["Cover logic<br/>server actions<br/>[cover-letter.js]"]
  node_user_actions["User logic<br/>server actions<br/>[user.js]"]
end

subgraph group_storage["Persistence"]
  node_prisma_client["Prisma client<br/>db client<br/>[prisma.js]"]
  node_schema["Schema<br/>[schema.prisma]"]
end

subgraph group_integrations["Integrations"]
  node_gemini(("Gemini<br/>ai service"))
  node_clerk(("Clerk<br/>identity service"))
  node_inggest_client["Inngest client<br/>job client<br/>[client.js]"]
  node_inggest_api["Inngest API<br/>job route<br/>[route.js]"]
  node_inggest_funcs["Job funcs<br/>job handlers<br/>[functions.js]"]
end

subgraph group_shared["Shared UI"]
  node_ui_kit["UI kit<br/>shared ui<br/>[button.jsx]"]
  node_site_components["Site components<br/>shared ui<br/>[hero.jsx]"]
  node_content_data["Content data<br/>static content<br/>[features.js]"]
  node_validation["Validation<br/>schemas<br/>[schema.js]"]
  node_helpers["Helpers<br/>utilities<br/>[helper.js]"]
end

node_app_layout -->|"wraps"| node_auth_layout
node_app_layout -->|"wraps"| node_main_layout
node_proxy_guard -->|"uses"| node_check_user
node_auth_layout -->|"hosts"| node_sign_in
node_auth_layout -->|"hosts"| node_sign_up
node_main_layout -->|"routes to"| node_onboarding
node_main_layout -->|"routes to"| node_dashboard
node_main_layout -->|"routes to"| node_resume
node_main_layout -->|"routes to"| node_interview
node_main_layout -->|"routes to"| node_cover_letter
node_onboarding -->|"submits to"| node_user_actions
node_dashboard -->|"loads via"| node_dashboard_actions
node_resume -->|"uses"| node_resume_actions
node_interview -->|"uses"| node_interview_actions
node_cover_letter -->|"uses"| node_cover_letter_actions
node_dashboard_actions -->|"reads/writes"| node_prisma_client
node_resume_actions -->|"reads/writes"| node_prisma_client
node_interview_actions -->|"reads/writes"| node_prisma_client
node_cover_letter_actions -->|"reads/writes"| node_prisma_client
node_user_actions -->|"writes"| node_prisma_client
node_prisma_client -->|"implements"| node_schema
node_dashboard_actions -->|"generates"| node_gemini
node_resume_actions -->|"generates"| node_gemini
node_interview_actions -->|"generates"| node_gemini
node_cover_letter_actions -->|"generates"| node_gemini
node_main_layout -->|"authenticates"| node_clerk
node_proxy_guard -->|"authenticates"| node_clerk
node_inggest_api -->|"accepts events"| node_inggest_client
node_inggest_client -->|"dispatches"| node_inggest_funcs
node_dashboard_actions -.->|"queues"| node_inggest_client
node_cover_letter_actions -.->|"queues"| node_inggest_client
node_onboarding -->|"validates"| node_validation
node_resume -->|"validates"| node_validation
node_interview -->|"validates"| node_validation
node_cover_letter -->|"validates"| node_validation
node_dashboard -->|"uses"| node_content_data
node_site_components -->|"composes"| node_ui_kit
node_app_layout -->|"renders"| node_site_components
node_dashboard -->|"formats"| node_helpers

click node_app_layout "https://github.com/chandrakantamandal/sensei/blob/main/app/layout.js"
click node_main_layout "https://github.com/chandrakantamandal/sensei/blob/main/app/(main)/layout.jsx"
click node_auth_layout "https://github.com/chandrakantamandal/sensei/blob/main/app/(auth)/layout.jsx"
click node_proxy_guard "https://github.com/chandrakantamandal/sensei/blob/main/proxy.js"
click node_check_user "https://github.com/chandrakantamandal/sensei/blob/main/lib/checkUser.js"
click node_sign_in "https://github.com/chandrakantamandal/sensei/blob/main/app/(auth)/sign-in/[[...sign-in]]/page.jsx"
click node_sign_up "https://github.com/chandrakantamandal/sensei/blob/main/app/(auth)/sign-up/[[...sign-up]]/page.jsx"
click node_onboarding "https://github.com/chandrakantamandal/sensei/blob/main/app/(main)/onboarding/page.jsx"
click node_dashboard "https://github.com/chandrakantamandal/sensei/blob/main/app/(main)/dashboard/page.jsx"
click node_resume "https://github.com/chandrakantamandal/sensei/blob/main/app/(main)/resume/page.jsx"
click node_interview "https://github.com/chandrakantamandal/sensei/blob/main/app/(main)/interview/page.jsx"
click node_cover_letter "https://github.com/chandrakantamandal/sensei/blob/main/app/(main)/ai-cover-letter/page.jsx"
click node_dashboard_actions "https://github.com/chandrakantamandal/sensei/blob/main/actions/dashboard.js"
click node_resume_actions "https://github.com/chandrakantamandal/sensei/blob/main/actions/resume.js"
click node_interview_actions "https://github.com/chandrakantamandal/sensei/blob/main/actions/interview.js"
click node_cover_letter_actions "https://github.com/chandrakantamandal/sensei/blob/main/actions/cover-letter.js"
click node_user_actions "https://github.com/chandrakantamandal/sensei/blob/main/actions/user.js"
click node_prisma_client "https://github.com/chandrakantamandal/sensei/blob/main/lib/prisma.js"
click node_schema "https://github.com/chandrakantamandal/sensei/blob/main/prisma/schema.prisma"
click node_inggest_client "https://github.com/chandrakantamandal/sensei/blob/main/lib/inggest/client.js"
click node_inggest_api "https://github.com/chandrakantamandal/sensei/blob/main/app/api/inggest/route.js"
click node_inggest_funcs "https://github.com/chandrakantamandal/sensei/blob/main/lib/inggest/functions.js"
click node_ui_kit "https://github.com/chandrakantamandal/sensei/blob/main/components/ui/button.jsx"
click node_site_components "https://github.com/chandrakantamandal/sensei/blob/main/components/hero.jsx"
click node_content_data "https://github.com/chandrakantamandal/sensei/blob/main/data/features.js"
click node_validation "https://github.com/chandrakantamandal/sensei/blob/main/app/lib/schema.js"
click node_helpers "https://github.com/chandrakantamandal/sensei/blob/main/app/lib/helper.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app_layout,node_main_layout,node_auth_layout,node_sign_in,node_sign_up toneBlue
class node_onboarding,node_dashboard,node_resume,node_interview,node_cover_letter toneAmber
class node_proxy_guard,node_check_user,node_dashboard_actions,node_resume_actions,node_interview_actions,node_cover_letter_actions,node_user_actions toneMint
class node_prisma_client,node_schema toneRose
class node_gemini,node_clerk,node_inggest_client,node_inggest_api,node_inggest_funcs toneIndigo
class node_ui_kit,node_site_components,node_content_data,node_validation,node_helpers toneTeal
```

## Components

### Routes

App Router shells and page entry points

- [App layout](https://github.com/chandrakantamandal/sensei/blob/main/app/layout.js): root layout · Top-level Next.js app shell · `app/layout.js`
- [Main shell](https://github.com/chandrakantamandal/sensei/blob/main/app/(main)/layout.jsx): protected layout · Authenticated product layout · `app/(main)/layout.jsx`
- [Auth shell](https://github.com/chandrakantamandal/sensei/blob/main/app/(auth)/layout.jsx): public layout · Sign-in and sign-up layout · `app/(auth)/layout.jsx`
- [Sign in](https://github.com/chandrakantamandal/sensei/blob/main/app/(auth)/sign-in/[[...sign-in]]/page.jsx): auth page · Clerk sign-in route · `app/(auth)/sign-in/[[...sign-in]]/page.jsx`
- [Sign up](https://github.com/chandrakantamandal/sensei/blob/main/app/(auth)/sign-up/[[...sign-up]]/page.jsx): auth page · Clerk sign-up route · `app/(auth)/sign-up/[[...sign-up]]/page.jsx`

### Features

Main product slices inside the protected app

- [Onboarding](https://github.com/chandrakantamandal/sensei/blob/main/app/(main)/onboarding/page.jsx): profile flow · Collects user profile and preferences · `app/(main)/onboarding/page.jsx`
- [Dashboard](https://github.com/chandrakantamandal/sensei/blob/main/app/(main)/dashboard/page.jsx): insights view · Personalized career insights and recommendations · `app/(main)/dashboard/page.jsx`
- [Resume](https://github.com/chandrakantamandal/sensei/blob/main/app/(main)/resume/page.jsx): builder · Resume composition and preview experience · `app/(main)/resume/page.jsx`
- [Interview](https://github.com/chandrakantamandal/sensei/blob/main/app/(main)/interview/page.jsx): practice flow · Quiz generation, practice, and results · `app/(main)/interview/page.jsx`
- [Cover letters](https://github.com/chandrakantamandal/sensei/blob/main/app/(main)/ai-cover-letter/page.jsx): generator · AI cover letter creation and history · `app/(main)/ai-cover-letter/page.jsx`

### Server Logic

Actions, guards, and shared runtime helpers

- [Proxy guard](https://github.com/chandrakantamandal/sensei/blob/main/proxy.js): auth proxy · Request-time redirect and protection boundary · `proxy.js`
- [User check](https://github.com/chandrakantamandal/sensei/blob/main/lib/checkUser.js): auth helper · Central user/session guard logic · `lib/checkUser.js`
- [Dashboard logic](https://github.com/chandrakantamandal/sensei/blob/main/actions/dashboard.js): server actions · Dashboard data and recommendation generation · `actions/dashboard.js`
- [Resume logic](https://github.com/chandrakantamandal/sensei/blob/main/actions/resume.js): server actions · Resume editing and generation actions · `actions/resume.js`
- [Interview logic](https://github.com/chandrakantamandal/sensei/blob/main/actions/interview.js): server actions · Quiz, practice, and scoring actions · `actions/interview.js`
- [Cover logic](https://github.com/chandrakantamandal/sensei/blob/main/actions/cover-letter.js): server actions · Cover letter generation and retrieval actions · `actions/cover-letter.js`
- [User logic](https://github.com/chandrakantamandal/sensei/blob/main/actions/user.js): server actions · Profile and onboarding persistence actions · `actions/user.js`

### Persistence

Database schema and Prisma access

- [Prisma client](https://github.com/chandrakantamandal/sensei/blob/main/lib/prisma.js): db client · Shared database access layer · `lib/prisma.js`
- [Schema](https://github.com/chandrakantamandal/sensei/blob/main/prisma/schema.prisma): prisma schema · Database model definition and migrations · `prisma/schema.prisma`

### Integrations

External identity, AI, and async job services

- **Gemini**: ai service · Generative AI backend for personalized content
- **Clerk**: identity service · Authentication and session provider
- [Inngest client](https://github.com/chandrakantamandal/sensei/blob/main/lib/inggest/client.js): job client · Event/job pipeline client · `lib/inggest/client.js`
- [Inngest API](https://github.com/chandrakantamandal/sensei/blob/main/app/api/inggest/route.js): job route · Webhook/trigger endpoint for async jobs · `app/api/inggest/route.js`
- [Job funcs](https://github.com/chandrakantamandal/sensei/blob/main/lib/inggest/functions.js): job handlers · Background workflow handlers · `lib/inggest/functions.js`

### Shared UI

Reusable presentation, content, and validation layer

- [UI kit](https://github.com/chandrakantamandal/sensei/blob/main/components/ui/button.jsx): shared ui · Reusable shadcn component primitives · `components/ui/button.jsx`
- [Site components](https://github.com/chandrakantamandal/sensei/blob/main/components/hero.jsx): shared ui · Header, footer, hero, and theme wrapper · `components/hero.jsx`
- [Content data](https://github.com/chandrakantamandal/sensei/blob/main/data/features.js): static content · FAQs, features, stats, industries, testimonials · `data/features.js`
- [Validation](https://github.com/chandrakantamandal/sensei/blob/main/app/lib/schema.js): schemas · Shared form schemas and helper logic · `app/lib/schema.js`
- [Helpers](https://github.com/chandrakantamandal/sensei/blob/main/app/lib/helper.js): utilities · Shared formatting and utility functions · `app/lib/helper.js`

## Connections

- App layout → Auth shell: wraps · Public auth routes render within the app shell
- App layout → Main shell: wraps · Protected product routes render within the app shell
- Proxy guard → User check: uses · Request guard delegates user/session checks
- Auth shell → Sign in: hosts · Clerk sign-in pages live under the auth shell
- Auth shell → Sign up: hosts · Clerk sign-up pages live under the auth shell
- Main shell → Onboarding: routes to · Protected shell contains onboarding flow
- Main shell → Dashboard: routes to · Protected shell contains dashboard
- Main shell → Resume: routes to · Protected shell contains resume builder
- Main shell → Interview: routes to · Protected shell contains interview practice
- Main shell → Cover letters: routes to · Protected shell contains cover-letter tools
- Onboarding → User logic: submits to · Profile form persists user data through actions
- Dashboard → Dashboard logic: loads via · Dashboard UI requests personalized data
- Resume → Resume logic: uses · Resume UI drives server actions
- Interview → Interview logic: uses · Practice flow drives quiz and scoring actions
- Cover letters → Cover logic: uses · Generator and history use cover-letter actions
- Dashboard logic → Prisma client: reads/writes · Dashboard logic persists and reads user content
- Resume logic → Prisma client: reads/writes · Resume logic persists generated and edited data
- Interview logic → Prisma client: reads/writes · Interview progress and results are stored in the database
- Cover logic → Prisma client: reads/writes · Cover-letter records are stored and retrieved
- User logic → Prisma client: writes · Onboarding/profile data is persisted through Prisma
- Prisma client → Schema: implements · Client targets the Prisma data model
- Dashboard logic → Gemini: generates · AI powers insights and recommendations
- Resume logic → Gemini: generates · AI assists resume composition
- Interview logic → Gemini: generates · AI creates questions and feedback
- Cover logic → Gemini: generates · AI drafts cover letters
- Main shell → Clerk: authenticates · Protected app uses Clerk session state
- Proxy guard → Clerk: authenticates · Edge/proxy guard depends on Clerk session info
- Inngest API → Inngest client: accepts events · API route is the job entrypoint
- Inngest client → Job funcs: dispatches · Client triggers background handlers
- Dashboard logic → Inngest client: queues · Some work may be deferred to async jobs
- Cover logic → Inngest client: queues · Generation or post-processing can run asynchronously
- Onboarding → Validation: validates · Form input is validated before submission
- Resume → Validation: validates · Resume form data follows shared schemas
- Interview → Validation: validates · Quiz and practice input use shared schemas
- Cover letters → Validation: validates · Cover-letter forms use shared schemas
- Dashboard → Content data: uses · Static domain content feeds dashboard and landing surfaces
- Site components → UI kit: composes · Site-level components are built from reusable primitives
- App layout → Site components: renders · Global shell depends on shared presentation components
- Dashboard → Helpers: formats · Feature UI uses shared helper functions
