# ankitpathak62/job-portal architecture

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

- Interactive diagram: https://gitdiagram.com/ankitpathak62/job-portal
- Repository: https://github.com/ankitpathak62/job-portal

## Overview

##### Project Type and Purpose
- This is a full-stack MERN (MongoDB, Express, React, Node.js) job portal application.
- Users can register/login, browse and apply for jobs; employers can post and manage jobs via an admin dashboard.

##### File Structure
A. Backend (Node/Express API)
- index.js: Application entry point, spins up Express server.
- controllers/: Request handlers split by resource (application, company, job, user).
- routes/: Defines REST endpoints and ties them to controllers.
- models/: Mongoose schemas (Application, Company, Job, User).
- middleware/: Authentication (JWT or session) and Multer file-upload middleware.
- utils/: Database connection (db.js), file upload helpers (datauri.js, cloud.js).
- .env, package.json: Configuration and dependencies.
B. Frontend (React + Vite + Redux)
- src/: Main application code.
- components/:
– authentication/: Login/Register UI
– admincomponent/: Employer dashboard pages (post job, view applicants, manage companies)
– components_lite/: Candidate-facing pages (browse jobs, profile, filters, static pages)
– creator/: Possibly a wrapper/dashboard container
– ui/: Reusable design system components (buttons, dialogs, tables, etc.)
- hooks/: Custom data-fetching hooks (useGetAllJobs, useGetCompanyById, etc.)
- redux/: State slices and store configuration
- utils/: Static data or helper functions
- main.jsx, App.jsx: Entry point and root component
- public, index.html, CSS config, Tailwind, eslint, Vite config

##### README for Additional Insights
- Confirms MERN stack, features: authentication, job listing/search, application process, employer dashboard, responsive design.

##### Main Components and Their Relationships
A. Client Layer (Browser)
- React SPA served by Vite development server (or built static files served by Nginx/Express in production)
- UI components communicate via HTTP to backend API
- Redux manages client state; hooks abstract data fetching
B. API Layer (Express)
- Exposes REST endpoints (/api/users, /api/jobs, /api/companies, /api/applications)
- Controllers implement business logic, call Mongoose models
- Middleware enforces authentication and handles file uploads
C. Data Layer (MongoDB)
- Stores Users, Jobs, Companies, Applications
D. External Services
- Cloud storage (via cloud.js) for storing resumes/images
E. Dev/Build Tools
- Vite, Tailwind, ESLint on frontend; nodemon and dotenv on backend

##### Architectural Patterns and Design Principles
- Backend: MVC-style separation (models, controllers, routes)
- Middleware chain for concerns (auth, file handling)
- Frontend: Component-based React architecture with a centralized Redux store
- Clear separation of concerns between presentation, state management, and data-fetching

##### Detail
- Major sub-folder as its own module (e.g., /admincomponent, /authentication).
- Middleware order: JWT auth → multer → controllers.
- Utils (datauri.js → transforms buffer to data URI for cloud).
- Call out Redux slices and store topology (how authSlice, jobSlice integrate into App).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Zone
    subgraph "Frontend (Browser)"
        direction TB
        FE1["React SPA"]:::frontend
        FE2["main.jsx"]:::frontend
        FE3["App.jsx"]:::frontend
        subgraph "UI Components"
            direction TB
            UI1["Login/Register"]:::frontend
            UI2["Admin Dashboard"]:::frontend
            UI3["Candidate Pages"]:::frontend
            UI4["Reusable UI Library"]:::frontend
        end
        subgraph "State Management & Data Fetching"
            direction TB
            FE4["Redux Store"]:::frontend
            FE5["authSlice.js"]:::frontend
            FE6["jobSlice.js"]:::frontend
            FE7["companySlice.js"]:::frontend
            FE8["applicationSlice.js"]:::frontend
            FE9["Custom Hooks"]:::frontend
        end
        FE10["vite.config.js"]:::frontend
        FE11["tailwind.config.js"]:::frontend
    end

    %% Backend Zone
    subgraph "Backend (Express API Server)"
        direction TB
        BE1["index.js"]:::server
        subgraph "Middleware"
            direction TB
            BE2["isAuthenticated.js"]:::server
            BE3["multer.js"]:::server
        end
        subgraph "Routes"
            direction TB
            BE4["application.route.js"]:::server
            BE5["company.route.js"]:::server
            BE6["job.route.js"]:::server
            BE7["user.route.js"]:::server
        end
        subgraph "Controllers"
            direction TB
            BE8["application.controller.js"]:::server
            BE9["company.controller.js"]:::server
            BE10["job.controller.js"]:::server
            BE11["user.controller.js"]:::server
        end
        subgraph "Models"
            direction TB
            BE12["application.model.js"]:::server
            BE13["company.model.js"]:::server
            BE14["job.model.js"]:::server
            BE15["user.model.js"]:::server
        end
        subgraph "Utils"
            direction TB
            BE16["db.js"]:::server
            BE17["cloud.js"]:::external
            BE18["datauri.js"]:::server
        end
    end

    %% Data & External
    subgraph "Data & External Services"
        direction TB
        DB["MongoDB"]:::database
        CLOUD["Cloud Storage"]:::external
    end

    %% Connections Frontend to Backend
    FE1 -->|HTTP/REST| BE1
    FE2 --> FE1
    FE3 --> FE1
    UI1 --> FE1
    UI2 --> FE1
    UI3 --> FE1
    UI4 --> FE1
    FE4 --> FE1
    FE5 --> FE4
    FE6 --> FE4
    FE7 --> FE4
    FE8 --> FE4
    FE9 --> FE1

    %% Backend Flow
    BE1 --> BE2
    BE2 --> BE3
    BE3 --> BE4
    BE3 --> BE5
    BE3 --> BE6
    BE3 --> BE7
    BE4 --> BE8
    BE5 --> BE9
    BE6 --> BE10
    BE7 --> BE11
    BE8 --> BE12
    BE9 --> BE13
    BE10 --> BE14
    BE11 --> BE15

    %% Database and Cloud
    BE12 -->|read/write| DB
    BE13 -->|read/write| DB
    BE14 -->|read/write| DB
    BE15 -->|read/write| DB
    BE8 -->|upload/download| BE17
    BE9 -->|upload/download| BE17
    BE10 -->|upload/download| BE17
    BE17 --> CLOUD
    BE18 --> BE17

    %% Config Tools
    FE10 --> FE1
    FE11 --> FE1

    %% Click Events
    click BE1 "https://github.com/ankitpathak62/job-portal/blob/master/Backend/index.js"
    click BE2 "https://github.com/ankitpathak62/job-portal/blob/master/Backend/middleware/isAuthenticated.js"
    click BE3 "https://github.com/ankitpathak62/job-portal/blob/master/Backend/middleware/multer.js"
    click BE8 "https://github.com/ankitpathak62/job-portal/blob/master/Backend/controllers/application.controller.js"
    click BE9 "https://github.com/ankitpathak62/job-portal/blob/master/Backend/controllers/company.controller.js"
    click BE10 "https://github.com/ankitpathak62/job-portal/blob/master/Backend/controllers/job.controller.js"
    click BE11 "https://github.com/ankitpathak62/job-portal/blob/master/Backend/controllers/user.controller.js"
    click BE4 "https://github.com/ankitpathak62/job-portal/blob/master/Backend/routes/application.route.js"
    click BE5 "https://github.com/ankitpathak62/job-portal/blob/master/Backend/routes/company.route.js"
    click BE6 "https://github.com/ankitpathak62/job-portal/blob/master/Backend/routes/job.route.js"
    click BE7 "https://github.com/ankitpathak62/job-portal/blob/master/Backend/routes/user.route.js"
    click BE12 "https://github.com/ankitpathak62/job-portal/blob/master/Backend/models/application.model.js"
    click BE13 "https://github.com/ankitpathak62/job-portal/blob/master/Backend/models/company.model.js"
    click BE14 "https://github.com/ankitpathak62/job-portal/blob/master/Backend/models/job.model.js"
    click BE15 "https://github.com/ankitpathak62/job-portal/blob/master/Backend/models/user.model.js"
    click BE16 "https://github.com/ankitpathak62/job-portal/blob/master/Backend/utils/db.js"
    click BE17 "https://github.com/ankitpathak62/job-portal/blob/master/Backend/utils/cloud.js"
    click BE18 "https://github.com/ankitpathak62/job-portal/blob/master/Backend/utils/datauri.js"
    click FE2 "https://github.com/ankitpathak62/job-portal/blob/master/Frontend/src/main.jsx"
    click FE3 "https://github.com/ankitpathak62/job-portal/blob/master/Frontend/src/App.jsx"
    click FE4 "https://github.com/ankitpathak62/job-portal/blob/master/Frontend/src/redux/store.js"
    click FE5 "https://github.com/ankitpathak62/job-portal/blob/master/Frontend/src/redux/authSlice.js"
    click FE6 "https://github.com/ankitpathak62/job-portal/blob/master/Frontend/src/redux/jobSlice.js"
    click FE7 "https://github.com/ankitpathak62/job-portal/blob/master/Frontend/src/redux/companyslice.js"
    click FE8 "https://github.com/ankitpathak62/job-portal/blob/master/Frontend/src/redux/applicationSlice.js"
    click UI1 "https://github.com/ankitpathak62/job-portal/blob/master/Frontend/src/components/authentication/Login.jsx"
    click UI1 "https://github.com/ankitpathak62/job-portal/blob/master/Frontend/src/components/authentication/Register.jsx"
    click UI2 "https://github.com/ankitpathak62/job-portal/tree/master/Frontend/src/components/admincomponent/"
    click UI3 "https://github.com/ankitpathak62/job-portal/tree/master/Frontend/src/components/components_lite/"
    click UI4 "https://github.com/ankitpathak62/job-portal/tree/master/Frontend/src/components/ui/"
    click FE9 "https://github.com/ankitpathak62/job-portal/tree/master/Frontend/src/hooks/"
    click FE10 "https://github.com/ankitpathak62/job-portal/blob/master/Frontend/vite.config.js"
    click FE11 "https://github.com/ankitpathak62/job-portal/blob/master/Frontend/tailwind.config.js"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000
    classDef server fill:#90EE90,stroke:#000
    classDef database fill:#FFA500,stroke:#000
    classDef external fill:#DDA0DD,stroke:#000
```
