# adityaraj1910/exam-genie architecture

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

- Interactive diagram: https://gitdiagram.com/adityaraj1910/exam-genie
- Repository: https://github.com/adityaraj1910/exam-genie

## Overview

##### Project type and purpose
- This is a full-stack MERN application named “Exam-Scribe AI.”
- Frontend: React (TypeScript) with Vite, Tailwind CSS, Shadcn UI; Backend: Node.js/Express; Database: MongoDB.
- Purpose: Enable educators to register/login, manage courses, set up exams, and generate AI-powered questions.

##### File structure
- Top level separates frontend and backend:
- Root folders/files: index.html, src/, public/, vite.config.ts, tailwind.config.ts (frontend)
- server/: Express app, routes/, models/, middlewares/, scripts/
- Frontend follows a component/page pattern:
- src/pages/: route-level views (Login, Dashboard, ExamSetup, etc.)
- src/components/ui/: reusable UI primitives (buttons, dialogs, forms)
- src/lib/api.ts: HTTP client for REST calls
- src/contexts/AuthContext: user state management
- Backend is structured in MVC style:
- server/models/: Mongoose schemas (Course, Educator, Exam, Question)
- server/routes/: REST endpoints (auth, courses, exams, questions)
- server/middlewares/: auth checks, admin guards
- server/scripts/: DB initialization/seed

##### README for additional insights
- Confirms MERN stack, environment variables, startup scripts.
- Mentions AI question-generation (likely calls external AI service).

##### Detail
- Layer: UI → application logic → API client → server middleware → controllers → database.
- Question-generation flow separately: backend → AI service → back to client.
- Configuration nodes (env vars, scripts for DB init).
- Don’t overthink: break the system into as many logical components as needed to make the architecture crystal clear.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend"
        Browser["Browser (User)"]:::frontend
        Browser --> UI["React SPA"]:::frontend

        subgraph "React SPA"
            Main["main.tsx"]:::frontend
            App["App.tsx"]:::frontend

            subgraph "Pages (src/pages)"
                Login["Login.tsx"]:::frontend
                Register["Register.tsx"]:::frontend
                WelcomeSplash["WelcomeSplash.tsx"]:::frontend
                Dashboard["Dashboard.tsx"]:::frontend
                ExamTypeSelection["ExamTypeSelection.tsx"]:::frontend
                CieExamSetup["CieExamSetup.tsx"]:::frontend
                SemesterExamSetup["SemesterExamSetup.tsx"]:::frontend
                GenerateQuestions["GenerateQuestions.tsx"]:::frontend
                IndexPage["Index.tsx"]:::frontend
                NotFound["NotFound.tsx"]:::frontend
            end

            UIPrimitives["UI Primitives (src/components/ui)"]:::frontend
            NetworkGridBackground["NetworkGridBackground.tsx"]:::frontend
            SecureRoute["SecureRoute.tsx"]:::frontend
            AuthContext["AuthContext.tsx"]:::frontend
            APIClient["api.ts / utils.ts"]:::frontend
            Hooks["use-mobile.tsx / use-toast.tsx"]:::frontend
            subgraph "Config & Styles"
                HTML["index.html"]:::frontend
                CSS["index.css"]:::frontend
                TailwindConfig["tailwind.config.ts"]:::frontend
                ViteConfig["vite.config.ts"]:::frontend
                PostCSS["postcss.config.js"]:::frontend
                AppConfig["appConfig.ts"]:::frontend
            end
        end

        UI --> Main
        UI --> App
        UI --> Login
        UI --> Register
        UI --> WelcomeSplash
        UI --> Dashboard
        UI --> ExamTypeSelection
        UI --> CieExamSetup
        UI --> SemesterExamSetup
        UI --> GenerateQuestions
        UI --> IndexPage
        UI --> NotFound
        UI --> UIPrimitives
        UI --> NetworkGridBackground
        UI --> SecureRoute
        UI --> AuthContext
        UI --> APIClient
        UI --> Hooks
        UI --> HTML
        UI --> CSS
        UI --> TailwindConfig
        UI --> ViteConfig
        UI --> PostCSS
        UI --> AppConfig
    end

    %% Backend Layer
    subgraph "Backend"
        Env["Environment Variables"]:::backend
        Env --> ServerEntry

        ServerEntry["server/server.js"]:::backend

        subgraph "Middlewares (server/middlewares)"
            AuthMiddleware["auth.js"]:::backend
            AdminMiddleware["admin.js"]:::backend
        end

        subgraph "Routes (server/routes)"
            AuthRoute["auth.js"]:::backend
            CoursesRoute["courses.js"]:::backend
            ExamsRoute["exams.js"]:::backend
            QuestionsRoute["questions.js"]:::backend
        end

        subgraph "Models (server/models)"
            EducatorModel["Educator.js"]:::backend
            CourseModel["Course.js"]:::backend
            ExamModel["Exam.js"]:::backend
            QuestionModel["Question.js"]:::backend
        end

        subgraph "Scripts (server/scripts)"
            InitDB["initDb.js"]:::backend
            SeedData["seedData.js"]:::backend
        end

        ServerEntry --> AuthMiddleware --> AuthRoute
        ServerEntry --> AdminMiddleware --> CoursesRoute
        ServerEntry --> ExamsRoute
        ServerEntry --> QuestionsRoute
        AuthRoute --> EducatorModel
        CoursesRoute --> CourseModel
        ExamsRoute --> ExamModel
        QuestionsRoute --> QuestionModel
        ServerEntry --> InitDB
        ServerEntry --> SeedData
    end

    %% Data & External Services
    DB["MongoDB"]:::db
    QuestionModel --> DB
    CourseModel --> DB
    EducatorModel --> DB
    ExamModel --> DB

    AI["External AI Service"]:::external
    QuestionsRoute -->|Generate Questions| AI
    AI -->|Response| QuestionsRoute

    %% Integrations
    APIClient -->|HTTP REST| ServerEntry

    %% Click events for frontend mappings
    click Main "https://github.com/adityaraj1910/exam-genie/blob/main/src/main.tsx"
    click App "https://github.com/adityaraj1910/exam-genie/blob/main/src/App.tsx"
    click Login "https://github.com/adityaraj1910/exam-genie/blob/main/src/pages/Login.tsx"
    click Register "https://github.com/adityaraj1910/exam-genie/blob/main/src/pages/Register.tsx"
    click WelcomeSplash "https://github.com/adityaraj1910/exam-genie/blob/main/src/pages/WelcomeSplash.tsx"
    click Dashboard "https://github.com/adityaraj1910/exam-genie/blob/main/src/pages/Dashboard.tsx"
    click ExamTypeSelection "https://github.com/adityaraj1910/exam-genie/blob/main/src/pages/ExamTypeSelection.tsx"
    click CieExamSetup "https://github.com/adityaraj1910/exam-genie/blob/main/src/pages/CieExamSetup.tsx"
    click SemesterExamSetup "https://github.com/adityaraj1910/exam-genie/blob/main/src/pages/SemesterExamSetup.tsx"
    click GenerateQuestions "https://github.com/adityaraj1910/exam-genie/blob/main/src/pages/GenerateQuestions.tsx"
    click IndexPage "https://github.com/adityaraj1910/exam-genie/blob/main/src/pages/Index.tsx"
    click NotFound "https://github.com/adityaraj1910/exam-genie/blob/main/src/pages/NotFound.tsx"
    click UIPrimitives "https://github.com/adityaraj1910/exam-genie/tree/main/src/components/ui"
    click NetworkGridBackground "https://github.com/adityaraj1910/exam-genie/blob/main/src/components/NetworkGridBackground.tsx"
    click SecureRoute "https://github.com/adityaraj1910/exam-genie/blob/main/src/components/SecureRoute.tsx"
    click AuthContext "https://github.com/adityaraj1910/exam-genie/blob/main/src/contexts/AuthContext.tsx"
    click APIClient "https://github.com/adityaraj1910/exam-genie/blob/main/src/lib/api.ts"
    click Hooks "https://github.com/adityaraj1910/exam-genie/blob/main/src/hooks/use-mobile.tsx"
    click Hooks "https://github.com/adityaraj1910/exam-genie/blob/main/src/hooks/use-toast.tsx"
    click HTML "https://github.com/adityaraj1910/exam-genie/blob/main/index.html"
    click CSS "https://github.com/adityaraj1910/exam-genie/blob/main/src/index.css"
    click TailwindConfig "https://github.com/adityaraj1910/exam-genie/blob/main/tailwind.config.ts"
    click ViteConfig "https://github.com/adityaraj1910/exam-genie/blob/main/vite.config.ts"
    click PostCSS "https://github.com/adityaraj1910/exam-genie/blob/main/postcss.config.js"
    click AppConfig "https://github.com/adityaraj1910/exam-genie/blob/main/src/config/appConfig.ts"

    %% Click events for backend mappings
    click ServerEntry "https://github.com/adityaraj1910/exam-genie/blob/main/server/server.js"
    click AuthMiddleware "https://github.com/adityaraj1910/exam-genie/blob/main/server/middlewares/auth.js"
    click AdminMiddleware "https://github.com/adityaraj1910/exam-genie/blob/main/server/middlewares/admin.js"
    click AuthRoute "https://github.com/adityaraj1910/exam-genie/blob/main/server/routes/auth.js"
    click CoursesRoute "https://github.com/adityaraj1910/exam-genie/blob/main/server/routes/courses.js"
    click ExamsRoute "https://github.com/adityaraj1910/exam-genie/blob/main/server/routes/exams.js"
    click QuestionsRoute "https://github.com/adityaraj1910/exam-genie/blob/main/server/routes/questions.js"
    click EducatorModel "https://github.com/adityaraj1910/exam-genie/blob/main/server/models/Educator.js"
    click CourseModel "https://github.com/adityaraj1910/exam-genie/blob/main/server/models/Course.js"
    click ExamModel "https://github.com/adityaraj1910/exam-genie/blob/main/server/models/Exam.js"
    click QuestionModel "https://github.com/adityaraj1910/exam-genie/blob/main/server/models/Question.js"
    click InitDB "https://github.com/adityaraj1910/exam-genie/blob/main/server/scripts/initDb.js"
    click SeedData "https://github.com/adityaraj1910/exam-genie/blob/main/server/scripts/seedData.js"
    click Env "https://github.com/adityaraj1910/exam-genie/blob/main/.env.example"
    click Env "https://github.com/adityaraj1910/exam-genie/blob/main/server/.env"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0093FF,color:#000
    classDef backend fill:#D0FFD8,stroke:#00A000,color:#000
    classDef db fill:#F0F0F0,stroke:#CCCCCC,color:#000
    classDef external fill:#FFE4B5,stroke:#FFA500,color:#000
```
