# sandeepdara-sd/ats_resume_builder architecture

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

- Interactive diagram: https://gitdiagram.com/sandeepdara-sd/ats_resume_builder
- Repository: https://github.com/sandeepdara-sd/ats_resume_builder

## Overview

##### Project Type and Purpose
- This is a full-stack AI-powered resume builder.
- Frontend: React + Firebase Auth + Material UI (user interface).
- Backend: Node.js + Express.js + MongoDB + JWT (API server, data store).
- External AI: Google Gemini Flash API for summary generation and scoring.
- PDF Export: html-pdf-node for generating downloadable resumes.
- Email: EmailJS/Nodemailer for feedback and password resets.
- Admin Panel: Role-based access control, user/content management.

##### File Structure
- frontend/: React app with pages/, components/, contexts/, firebase configuration.
- backend/: Express app with routes/, controllers/, models/, middleware/, utils/, config files.
- Shared points: .env for secrets, scripts for admin setup, deployment guides.

##### Main Components (to include
A. User Interface (Browser)
- React SPA
- Page routes: Landing, Signup/Login, Dashboard, Resume Builder, Admin Dashboard
- UI Components: Forms (Experience, Education, etc.), Template Selector, Preview

B. Authentication & User Management
- Firebase Auth (Google OAuth + email/password)
- JWT issued by backend for protected endpoints
- Middleware: auth.js, adminAuth.js

C. API Layer (Backend / Express)
- Routes: /auth, /resume, /ai, /feedback, /admin
- Controllers: handle business logic for sign-up, login, resume CRUD, AI calls, feedback
- Middleware: request validation, file uploads (multer), role checks

D. Data Store
- MongoDB via Mongoose
- Collections: Users, Resumes, Feedback, Admins, PasswordResets

E. AI & Scoring Services
- Google Gemini Flash API (via gemini.js config & aiController.js)
- resume scoring & summary generation

F. PDF Generation
- html-pdf-node (pdfExtractor.js, resumeTemplate.js)
- Converts React-like templates (JSX) into a downloadable PDF

G. External Services
- Firebase (Authentication + optional Firestore/Storage)
- Email (Nodemailer / EmailJS) for password resets and feedback notifications

##### Relationships & Data Flows
- Browser ↔ React App ↔ REST API (Express + JWT)
- Express ↔ MongoDB (read/write)
- Express ↔ Firebase Auth (token verification / user info)
- Express ↔ Google Gemini API (AI requests/responses)
- Express ↔ html-pdf-node (PDF generation)
- Express ↔ Email Service (SMTP)
- Admin Dashboard → Protected admin routes (role check)

##### Architectural Patterns & Design Principles
- 3-Tier Architecture: Presentation (React), Application (Express), Data (MongoDB)
- RESTful API design
- Middleware pattern for cross-cutting concerns (auth, uploads)
- Separation of concerns: controllers vs. models vs. routes vs. utils
- Modular codebase: clear frontend/backend separation
- Secure design: JWT, role-based access control, environment variables

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        UI["React SPA"]:::frontend
        Pages["UI Pages"]:::frontend
        Components["React Components"]:::frontend
        Templates["Template Components"]:::frontend
        AuthContext["Auth Context"]:::frontend
        FirebaseConfig["Firebase Config"]:::frontend
    end

    %% Application Layer
    subgraph "Application Layer"
        APIGW["API Gateway (Express)"]:::backend

        subgraph "Routes"
            AuthRoutes["/auth Routes"]:::backend
            ResumeRoutes["/resume Routes"]:::backend
            AIRoutes["/ai Routes"]:::backend
            FeedbackRoutes["/feedback Routes"]:::backend
            AdminRoutes["/admin Routes"]:::backend
        end

        subgraph "Controllers"
            AuthCtrl["Auth Controller"]:::backend
            ResumeCtrl["Resume Controller"]:::backend
            AICtrl["AI Controller"]:::backend
            FeedbackCtrl["Feedback Controller"]:::backend
            AdminCtrl["Admin Controller"]:::backend
        end

        subgraph "Middleware"
            AuthMW["Auth Middleware"]:::backend
            AdminAuthMW["Admin Auth Middleware"]:::backend
            UploadMW["Upload Middleware"]:::backend
        end

        subgraph "Config & Utils"
            DBConfig["DB Config"]:::backend
            FirebaseAdminConfig["Firebase Admin Config"]:::backend
            GeminiConfig["Gemini API Config"]:::backend
            PDFUtil["PDF Extraction Utility"]:::backend
            TemplateUtil["Resume Template Utility"]:::backend
            AdminSetup["Admin Setup Script"]:::backend
            EnvExample[".env Example"]:::backend
        end

        APIGW --> AuthRoutes
        APIGW --> ResumeRoutes
        APIGW --> AIRoutes
        APIGW --> FeedbackRoutes
        APIGW --> AdminRoutes

        AuthRoutes --> AuthMW --> AuthCtrl
        ResumeRoutes --> AuthMW
        ResumeRoutes --> UploadMW --> ResumeCtrl
        AIRoutes --> AuthMW --> AICtrl
        FeedbackRoutes --> AuthMW --> FeedbackCtrl
        AdminRoutes --> AuthMW & AdminAuthMW --> AdminCtrl

        APIGW --> DBConfig
        APIGW --> FirebaseAdminConfig
        APIGW --> GeminiConfig
        APIGW --> PDFUtil
        APIGW --> TemplateUtil
        APIGW --> AdminSetup
        APIGW --> EnvExample

        AICtrl --> GeminiConfig
        ResumeCtrl --> PDFUtil
        ResumeCtrl --> TemplateUtil
    end

    %% Data & External Layer
    subgraph "Data & External Layer"
        DB["MongoDB"]:::db
        Users["Users Collection"]:::db
        Resumes["Resumes Collection"]:::db
        Feedbacks["Feedback Collection"]:::db
        Admins["Admins Collection"]:::db
        PWResets["PasswordResets Collection"]:::db

        Firebase["Firebase Auth"]:::external
        GeminiAPI["Google Gemini API"]:::external
        EmailSMTP["Email SMTP"]:::external
    end

    %% Data flows
    UI -->|HTTP REST| APIGW
    AuthCtrl -->|JWT| UI
    APIGW -->|reads/writes| DB
    APIGW -->|verifies tokens| Firebase
    AICtrl -->|API Key Auth| GeminiAPI
    FeedbackCtrl -->|SMTP| EmailSMTP

    DB --> Users
    DB --> Resumes
    DB --> Feedbacks
    DB --> Admins
    DB --> PWResets

    %% Click Events
    click UI "https://github.com/sandeepdara-sd/ats_resume_builder/tree/main/frontend/src"
    click Pages "https://github.com/sandeepdara-sd/ats_resume_builder/tree/main/frontend/src/pages"
    click Components "https://github.com/sandeepdara-sd/ats_resume_builder/tree/main/frontend/src/components"
    click Templates "https://github.com/sandeepdara-sd/ats_resume_builder/tree/main/frontend/src/components/templates"
    click AuthContext "https://github.com/sandeepdara-sd/ats_resume_builder/blob/main/frontend/src/contexts/AuthContext.jsx"
    click FirebaseConfig "https://github.com/sandeepdara-sd/ats_resume_builder/blob/main/frontend/src/firebase/config.js"
    click APIGW "https://github.com/sandeepdara-sd/ats_resume_builder/blob/main/backend/index.js"
    click AuthRoutes "https://github.com/sandeepdara-sd/ats_resume_builder/blob/main/backend/routes/auth.js"
    click ResumeRoutes "https://github.com/sandeepdara-sd/ats_resume_builder/blob/main/backend/routes/resume.js"
    click AIRoutes "https://github.com/sandeepdara-sd/ats_resume_builder/blob/main/backend/routes/ai.js"
    click FeedbackRoutes "https://github.com/sandeepdara-sd/ats_resume_builder/blob/main/backend/routes/feedback.js"
    click AdminRoutes "https://github.com/sandeepdara-sd/ats_resume_builder/blob/main/backend/routes/admin.js"
    click AuthCtrl "https://github.com/sandeepdara-sd/ats_resume_builder/blob/main/backend/controllers/authController.js"
    click ResumeCtrl "https://github.com/sandeepdara-sd/ats_resume_builder/blob/main/backend/controllers/resumeController.js"
    click AICtrl "https://github.com/sandeepdara-sd/ats_resume_builder/blob/main/backend/controllers/aiController.js"
    click FeedbackCtrl "https://github.com/sandeepdara-sd/ats_resume_builder/blob/main/backend/controllers/feedbackController.js"
    click AdminCtrl "https://github.com/sandeepdara-sd/ats_resume_builder/blob/main/backend/controllers/adminController.js"
    click AuthMW "https://github.com/sandeepdara-sd/ats_resume_builder/blob/main/backend/middleware/auth.js"
    click AdminAuthMW "https://github.com/sandeepdara-sd/ats_resume_builder/blob/main/backend/middleware/adminAuth.js"
    click UploadMW "https://github.com/sandeepdara-sd/ats_resume_builder/blob/main/backend/middleware/upload.js"
    click DBConfig "https://github.com/sandeepdara-sd/ats_resume_builder/blob/main/backend/config/database.js"
    click FirebaseAdminConfig "https://github.com/sandeepdara-sd/ats_resume_builder/blob/main/backend/config/firebase.js"
    click GeminiConfig "https://github.com/sandeepdara-sd/ats_resume_builder/blob/main/backend/config/gemini.js"
    click PDFUtil "https://github.com/sandeepdara-sd/ats_resume_builder/blob/main/backend/utils/pdfExtractor.js"
    click TemplateUtil "https://github.com/sandeepdara-sd/ats_resume_builder/blob/main/backend/utils/resumeTemplate.js"
    click AdminSetup "https://github.com/sandeepdara-sd/ats_resume_builder/blob/main/backend/scripts/createAdmin.js"
    click EnvExample "https://github.com/sandeepdara-sd/ats_resume_builder/blob/main/backend/.env.example"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef backend fill:#d4edda,stroke:#333,stroke-width:1px
    classDef db fill:#ffe5b4,stroke:#333,stroke-width:1px
    classDef external fill:#fff3cd,stroke:#333,stroke-width:1px
```
