# sitanshulall/sensai architecture

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

- Interactive diagram: https://gitdiagram.com/sitanshulall/sensai
- Repository: https://github.com/sitanshulall/sensai

## Overview

##### Main Components
- Frontend (Next.js Application):
– The “app” directory houses the Next.js pages with a clear separation between authentication (under (auth)) and main application functionalities (under (main)).
– The “components” directory includes general-purpose UI components and the design system (e.g., ui subfolder with various common elements such as buttons, dialogs, tabs, etc.).
- Backend/Business Logic:
– The “actions” directory hosts JavaScript modules for key functionalities (coverLetter, dashboard, interview, resume, user) that potentially act as controller-like functions or API handlers.
– The “app/api” directory contains API endpoints (e.g., inngest) that provide server-side logic and event handling.
- Utility and Service Layers:
– The “lib” and “app/lib” directories include helper functions, user/session checks, and schema logic required by both frontend and backend components.
– The “hooks” directory provides custom React hooks, such as fetching data.
- Database/Persistence:
– The “prisma” directory shows the Prisma schema and migrations that define the database models and migrations, indicating an abstraction layer for database operations.
- Static and Supplemental Data:
– The “data” folder holds static JSON-like structures for FAQs, features, industries, etc., which support static content display.
- External Integrations:
– Integration with third-party services is suggested by “lib/inngest” and the API route “app/api/inngest/route.js”.
– Deployment considerations include Vercel (as mentioned in the README), with configurations for Next.js hosting.

##### Relationships & Interactions
- Client Interaction:
– The Next.js pages (in “app”) interact with UI components (in “components”) to render dynamic content.
– Authentication flows (sign-in/sign-up) in the “(auth)” directory connect with session management in “lib/checkUser.js” and possibly actions in “actions/user.js”.
- Business Logic and Data Flow:
– When a user interacts with features (cover letter, resume, interview, dashboard, onboarding), the frontend pages delegate business operations to the corresponding modules in “actions/…” and “lib/…” through API endpoints (see “app/api/inngest”) and in-client component calls.
- Database Operations:
– The Prisma ORM (schema.prisma, migrations) supports data persistence and is typically invoked by server-side functions or within API calls.
- Utility and Helpers:
– Shared helper functions and schema validators (in “app/lib” and “lib”) are employed across various components and actions for consistency and reusability.

##### Architectural Patterns & Design Principles
- Component-Based Architecture:
– UI components are modular, with clear separation between “smart” (data-fetching, logic-heavy) pages and “dumb” (UI-focused) components.
- Separation of Concerns:
– Clear partitioning between authentication logic, action business logic, and frontend UI allows easier maintenance and scalability.
- API Layer:
– Usage of Next.js API routes (e.g., for inngest) separates the client and server responsibilities.
- Database Abstraction:
– Prisma serves as an ORM, abstracting the database layer and facilitating migrations and model management.

##### Essential Elements
- Clear, descriptive labels for each module and component.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        AuthPages["Authentication Pages"]:::presentation
        MainPages["Main Application Pages"]:::presentation
        UIComponents["UI Components & Design System"]:::presentation
    end

    %% Business Logic & API Layer
    subgraph "Business Logic & API Layer"
        CoverLetter["Cover Letter Module"]:::logic
        Dashboard["Dashboard Module"]:::logic
        Interview["Interview Module"]:::logic
        Resume["Resume Module"]:::logic
        UserOnboarding["User/Onboarding Module"]:::logic
        APIEndpoints["API Endpoints (Inngest)"]:::logic
    end

    %% Utility Layer
    subgraph "Utilities"
        Utility["Utility Functions & Helpers"]:::utility
        CustomHooks["Custom Hooks"]:::utility
    end

    %% Persistent Storage & Static Content
    Database["Database (Prisma ORM)"]:::db
    StaticContent["Static Content & Data"]:::static

    %% Relationships: Presentation to Business Logic/API
    AuthPages -->|"authFlow"| UserOnboarding
    MainPages -->|"coverLetter"| CoverLetter
    MainPages -->|"dashboard"| Dashboard
    MainPages -->|"interview"| Interview
    MainPages -->|"resume"| Resume
    MainPages -->|"onboarding"| UserOnboarding
    MainPages --> UIComponents
    AuthPages --> UIComponents
    MainPages -->|"staticData"| StaticContent
    MainPages -->|"apiCall"| APIEndpoints

    %% Relationships: API and Business Logic to Utilities and Database
    CoverLetter --> Utility
    Dashboard --> Utility
    Interview --> Utility
    Resume --> Utility
    UserOnboarding --> Utility
    APIEndpoints --> Utility
    Utility --> Database

    %% Relationship: Custom Hooks supporting Presentation
    CustomHooks --> MainPages

    %% Click Events
    click AuthPages "https://github.com/sitanshulall/sensai/tree/master/app/(auth)"
    click MainPages "https://github.com/sitanshulall/sensai/tree/master/app/(main)"
    click CoverLetter "https://github.com/sitanshulall/sensai/blob/master/actions/coverLetter.js"
    click CoverLetter "https://github.com/sitanshulall/sensai/tree/master/app/(main)/cover-letter"
    click Dashboard "https://github.com/sitanshulall/sensai/blob/master/actions/dashboard.js"
    click Dashboard "https://github.com/sitanshulall/sensai/tree/master/app/(main)/dashboard"
    click Interview "https://github.com/sitanshulall/sensai/blob/master/actions/interview.js"
    click Interview "https://github.com/sitanshulall/sensai/tree/master/app/(main)/interview"
    click Resume "https://github.com/sitanshulall/sensai/blob/master/actions/resume.js"
    click Resume "https://github.com/sitanshulall/sensai/tree/master/app/(main)/resume"
    click UserOnboarding "https://github.com/sitanshulall/sensai/blob/master/actions/user.js"
    click UserOnboarding "https://github.com/sitanshulall/sensai/tree/master/app/(main)/onboarding"
    click APIEndpoints "https://github.com/sitanshulall/sensai/blob/master/app/api/inngest/route.js"
    click UIComponents "https://github.com/sitanshulall/sensai/tree/master/components"
    click UIComponents "https://github.com/sitanshulall/sensai/tree/master/components/ui"
    click Utility "https://github.com/sitanshulall/sensai/blob/master/lib/checkUser.js"
    click Utility "https://github.com/sitanshulall/sensai/tree/master/app/lib"
    click CustomHooks "https://github.com/sitanshulall/sensai/blob/master/hooks/use-fetch.js"
    click Database "https://github.com/sitanshulall/sensai/tree/master/prisma"
    click StaticContent "https://github.com/sitanshulall/sensai/tree/master/data"

    %% Class Definitions
    classDef presentation fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef logic fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef utility fill:#FFFF99,stroke:#000,stroke-width:2px;
    classDef db fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef static fill:#FFC0CB,stroke:#000,stroke-width:2px;
```
