# saketh010/cdc-portal architecture

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

- Interactive diagram: https://gitdiagram.com/saketh010/cdc-portal
- Repository: https://github.com/saketh010/cdc-portal

## Overview

##### Project Type and Purpose
- Full-stack web application for students/admins to browse, post, and apply for jobs.
- Built with Next.js (frontend + API routes), Node.js/Express style logic, MongoDB database, and SMTP for emails.

##### Main Components
a. Frontend (Next.js pages & React components)
- UI modules: Auth, Layout, Profile, SEO, Buttons/Inputs
- Pages: home, login, signup, job listings, admin dashboard, profile, etc.
b. Backend/API (Next.js API routes under pages/api)
- Auth routes: login, logout, password reset, OTP
- Jobs routes: list, detail, post, update
- Applications routes: apply, list, withdraw, email notifications
- Selections routes: add/get selection records
c. Database
- MongoDB collections via Mongoose models (User, Job, Application, Selections, etc.)
d. External Services
- SMTP email provider for notifications
- Docker/Docker-Compose for containerized deployment

##### Relationships & Data Flow
1. User’s browser → Next.js frontend (HTTP/HTTPS)
2. Frontend → API routes (REST calls)
3. API handlers → MongoDB (CRUD via Mongoose)
4. API handlers → SMTP service (send emails)
5. Docker Compose orchestrates frontend, backend, and database containers

##### Architectural Patterns & Design Principles
- Separation of Concerns: UI components vs. page layouts vs. API logic vs. data models
- RESTful API structure within Next.js routes
- Role-based access control enforced in Auth middleware components
- Containerization for environment consistency

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layers
    Browser["User Browser"]:::client
    subgraph "Next.js Frontend"
        direction TB
        subgraph "UI Components"
            direction TB
            AuthComp["Auth"]:::frontend
            LayoutComp["Layout"]:::frontend
            ProfileComp["Profile"]:::frontend
            SEOComp["SEO"]:::frontend
            UIComp["UI"]:::frontend
        end
        subgraph "Pages"
            direction TB
            HomePage["home.js / index.js"]:::frontend
            AuthPages["forgot-password.js / unauthorized.js"]:::frontend
            UserPages["profile.js / myapplications.js / previousSelections.js"]:::frontend
            JobDetailPage["jobDetailPage/[id].js"]:::frontend
            AdminPages["listjob.js / postjob.js"]:::frontend
        end
    end

    subgraph "Backend / API Layer"
        direction TB
        AuthAPI["Auth Routes"]:::api
        JobAPI["Job Routes"]:::api
        AppAPI["Application Routes"]:::api
        SelAPI["Selection Routes"]:::api
    end

    subgraph "Database"
        direction TB
        MongoDB["MongoDB\n(Mongoose Models)"]:::db
        DBConn["MongoDB Connection"]:::db
    end

    EmailService["SMTP Email Service"]:::external
    Container["Docker &\nDocker Compose"]:::infra

    %% Connections
    Browser -->|"HTTP/HTTPS"| HomePage
    HomePage -->|"calls API"| AuthAPI
    HomePage -->|"calls API"| JobAPI
    AuthPages -->|"calls API"| AuthAPI
    UserPages -->|"calls API"| AppAPI
    JobDetailPage -->|"calls API"| JobAPI
    AdminPages -->|"calls API"| JobAPI
    AuthAPI -->|"CRUD via Mongoose"| MongoDB
    JobAPI -->|"CRUD via Mongoose"| MongoDB
    AppAPI -->|"CRUD via Mongoose"| MongoDB
    SelAPI -->|"CRUD via Mongoose"| MongoDB
    AppAPI -->|"send emails"| EmailService
    AuthAPI -->|"send emails"| EmailService
    Container --> Browser
    Container --> MongoDB
    Container --> AuthAPI

    %% Click Events - Frontend Components
    click AuthComp "https://github.com/saketh010/cdc-portal/tree/main/components/Auth"
    click LayoutComp "https://github.com/saketh010/cdc-portal/tree/main/components/Layout"
    click ProfileComp "https://github.com/saketh010/cdc-portal/tree/main/components/Profile"
    click SEOComp "https://github.com/saketh010/cdc-portal/tree/main/components/SEO"
    click UIComp "https://github.com/saketh010/cdc-portal/tree/main/components/UI"

    %% Click Events - Frontend Pages
    click HomePage "https://github.com/saketh010/cdc-portal/blob/main/pages/home.js"
    click HomePage "https://github.com/saketh010/cdc-portal/blob/main/pages/index.js"
    click AuthPages "https://github.com/saketh010/cdc-portal/blob/main/pages/forgot-password.js"
    click AuthPages "https://github.com/saketh010/cdc-portal/blob/main/pages/unauthorized.js"
    click UserPages "https://github.com/saketh010/cdc-portal/blob/main/pages/profile.js"
    click UserPages "https://github.com/saketh010/cdc-portal/blob/main/pages/myapplications.js"
    click UserPages "https://github.com/saketh010/cdc-portal/blob/main/pages/selections/previousSelections.js"
    click JobDetailPage "https://github.com/saketh010/cdc-portal/blob/main/pages/jobDetailPage/[id].js"
    click AdminPages "https://github.com/saketh010/cdc-portal/blob/main/pages/admin/listjob.js"
    click AdminPages "https://github.com/saketh010/cdc-portal/blob/main/pages/admin/postjob.js"

    %% Click Events - API Layer
    click AuthAPI "https://github.com/saketh010/cdc-portal/tree/main/pages/api/auth"
    click JobAPI "https://github.com/saketh010/cdc-portal/tree/main/pages/api"
    click AppAPI "https://github.com/saketh010/cdc-portal/blob/main/pages/api/applyForJob.js"
    click SelAPI "https://github.com/saketh010/cdc-portal/tree/main/pages/api/selections"

    %% Click Events - Database & Helpers
    click MongoDB "https://github.com/saketh010/cdc-portal/tree/main/models"
    click DBConn "https://github.com/saketh010/cdc-portal/blob/main/lib/mongodb.js"
    click EmailService "https://github.com/saketh010/cdc-portal/blob/main/utils/nodemailer.js"
    click Container "https://github.com/saketh010/cdc-portal/blob/main/docker-compose.yml"

    %% Styles
    classDef client fill:#AEDFF7,stroke:#000,stroke-width:1px
    classDef frontend fill:#A8D5E2,stroke:#000,stroke-width:1px
    classDef api fill:#B2E1A1,stroke:#000,stroke-width:1px
    classDef db fill:#F9D59B,stroke:#000,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef infra fill:#E2D1F9,stroke:#000,stroke-width:1px
```
