# abhay-0103/job-portal-project architecture

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

- Interactive diagram: https://gitdiagram.com/abhay-0103/job-portal-project
- Repository: https://github.com/abhay-0103/job-portal-project

## Overview

##### Project Type & Purpose
- This is a full-stack MERN (MongoDB, Express, React, Node.js) job portal.
- Frontend: React + Vite + Tailwind CSS, deployed on Vercel.
- Backend: Express.js REST API, MongoDB via Mongoose, deployed on Render/Railway.
- Third-party services: Clerk (authentication), Sentry (error tracking), Cloudinary/Multer (file uploads).

##### Key File-Structure Insights
- client/ – React app
- src/components, pages, context (React Context for state)
- Clerk integrated at UI layer (RecruiterLogin.jsx, AppContext.jsx)
- Tailwind, Axios, React Router for styling, HTTP, routing
- server/ – Express API
- config/ (db.js, cloudinary.js, multer.js, instrument.js for Sentry)
- middleware/authMiddleware.js (protect routes via Clerk token)
- routes/ → controllers/ → models/ (MVC pattern)
- utils/generateToken.js (JWT helpers)
- Deployment config: vercel.json in both tiers, env variables for MongoDB URI, Clerk keys, etc.

##### Main Components & Interactions
- Client Browser
← React UI components & pages
→ React Context for global state & real-time updates
→ Axios HTTP calls to Backend API
→ Clerk frontend SDK handles user sign-in/up flows
→ Sentry frontend SDK captures UI errors
- API Gateway (Express server)
← Receives HTTP requests (job listings, applications, user actions)
→ authMiddleware validates Clerk JWTs
→ Routes dispatch to Controllers
→ Controllers invoke Mongoose Models
→ MongoDB for CRUD
→ Cloudinary/Multer for resume uploads
→ Sentry backend instrumentation logs exceptions
- Database & External Services
- MongoDB Atlas: stores User, Company, Job, JobApplication collections
- Clerk: auth provider (frontend + backend tokens)
- Sentry: error monitoring (frontend & backend)
- Cloudinary: file storage for resumes via multer middleware

##### Architectural Patterns & Principles
- MVC on the backend (Routes → Controllers → Models)
- Component-based and context state management on the frontend
- RESTful API design
- Separation of concerns: UI, business logic, data layer
- Secure stateless auth using Clerk tokens & JWTs

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Layer" 
        direction TB
        Browser["Client Browser"]:::frontend
        ReactApp["React App<br>(React + Vite + Tailwind)"]:::frontend
        Components["UI Components<br>(client/src/components)"]:::frontend
        Pages["Pages<br>(client/src/pages)"]:::frontend
        Context["React Context<br>(client/src/context/AppContext.jsx)"]:::frontend
        Router["Router & Entry<br>(client/src/App.jsx,<br>client/src/main.jsx)"]:::frontend
        ClerkSDK["Clerk SDK<br>(client/src/components/RecruiterLogin.jsx)"]:::frontend
        SentrySDK["Sentry SDK"]:::frontend
        TailwindConfig["tailwind.config.js"]:::frontend
        Styles["index.css"]:::frontend
        ViteConfig["vite.config.js"]:::frontend
        VercelConfigClient["vercel.json"]:::frontend
    end

    subgraph "API Layer" 
        direction TB
        ExpressServer["Express Server<br>(server/server.js)"]:::backend
        AuthMiddleware["Auth Middleware<br>(server/middleware/authMiddleware.js)"]:::backend
        RoutesCompany["Company Routes<br>(server/routes/companyRoutes.js)"]:::backend
        RoutesJob["Job Routes<br>(server/routes/jobRoutes.js)"]:::backend
        RoutesUser["User Routes<br>(server/routes/userRoutes.js)"]:::backend
        ControllersCompany["Company Controller<br>(server/controllers/companyController.js)"]:::backend
        ControllersJob["Job Controller<br>(server/controllers/jobController.js)"]:::backend
        ControllersUser["User Controller<br>(server/controllers/userController.js)"]:::backend
        ControllersWebhook["Webhooks Controller<br>(server/controllers/webhooks.js)"]:::backend
        ModelsCompany["Company Model<br>(server/models/Company.js)"]:::backend
        ModelsJob["Job Model<br>(server/models/Job.js)"]:::backend
        ModelsJobApp["Job Application Model<br>(server/models/JobApplication.js)"]:::backend
        ModelsUser["User Model<br>(server/models/User.js)"]:::backend
        DBConfig["DB Config<br>(server/config/db.js)"]:::backend
        CloudinaryConfig["Cloudinary Config<br>(server/config/cloudinary.js)"]:::backend
        MulterConfig["Multer Config<br>(server/config/multer.js)"]:::backend
        SentryConfig["Sentry Instrumentation<br>(server/config/instrument.js)"]:::backend
        JWTUtil["JWT Utility<br>(server/utils/generateToken.js)"]:::backend
        VercelConfigServer["vercel.json"]:::backend
        PackageJSONServer["package.json"]:::backend
    end

    subgraph "Data & Services Layer"
        direction TB
        MongoDB["MongoDB Atlas + Mongoose"]:::services
        ClerkService["Clerk Auth Service"]:::services
        SentryService["Sentry Error Monitoring"]:::services
        CloudinaryService["Cloudinary File Storage"]:::services
    end

    %% Client flows
    Browser --> ReactApp
    ReactApp --> Components
    ReactApp --> Pages
    ReactApp --> Context
    ReactApp --> Router
    ReactApp -->|"REST API (JSON)"| ExpressServer
    ReactApp -->|"Auth Flow"| ClerkService
    ReactApp -->|"Error logs"| SentryService
    Pages -->|"File Upload"| MulterConfig
    TailwindConfig --> ReactApp
    Styles --> ReactApp
    ViteConfig --> ReactApp
    VercelConfigClient --> ReactApp

    %% API flows
    ExpressServer --> AuthMiddleware
    ExpressServer --> RoutesCompany
    ExpressServer --> RoutesJob
    ExpressServer --> RoutesUser
    AuthMiddleware -->|Validates JWT| ClerkService
    RoutesCompany --> ControllersCompany
    RoutesJob --> ControllersJob
    RoutesUser --> ControllersUser
    ControllersCompany --> ModelsCompany
    ControllersJob --> ModelsJob
    ControllersUser --> ModelsUser
    ControllersWebhook --> SentryService
    ModelsCompany --> MongoDB
    ModelsJob --> MongoDB
    ModelsJobApp --> MongoDB
    ModelsUser --> MongoDB
    DBConfig --> MongoDB
    MulterConfig --> CloudinaryService
    CloudinaryConfig --> CloudinaryService
    SentryConfig --> SentryService
    JWTUtil --> AuthMiddleware
    VercelConfigServer --> ExpressServer
    PackageJSONServer --> ExpressServer

    %% Cross-layer
    MongoDB --> ControllersCompany
    MongoDB --> ControllersJob
    MongoDB --> ControllersUser
    ClerkService --> AuthMiddleware
    CloudinaryService --> ControllersJob

    %% Click Events
    click Components "https://github.com/abhay-0103/job-portal-project/tree/main/client/src/components"
    click Pages "https://github.com/abhay-0103/job-portal-project/tree/main/client/src/pages"
    click Context "https://github.com/abhay-0103/job-portal-project/blob/main/client/src/context/AppContext.jsx"
    click Router "https://github.com/abhay-0103/job-portal-project/blob/main/client/src/App.jsx"
    click Router "https://github.com/abhay-0103/job-portal-project/blob/main/client/src/main.jsx"
    click ClerkSDK "https://github.com/abhay-0103/job-portal-project/blob/main/client/src/components/RecruiterLogin.jsx"
    click TailwindConfig "https://github.com/abhay-0103/job-portal-project/blob/main/client/tailwind.config.js"
    click Styles "https://github.com/abhay-0103/job-portal-project/blob/main/client/src/index.css"
    click ViteConfig "https://github.com/abhay-0103/job-portal-project/blob/main/client/vite.config.js"
    click VercelConfigClient "https://github.com/abhay-0103/job-portal-project/blob/main/client/vercel.json"

    click ExpressServer "https://github.com/abhay-0103/job-portal-project/blob/main/server/server.js"
    click AuthMiddleware "https://github.com/abhay-0103/job-portal-project/blob/main/server/middleware/authMiddleware.js"
    click RoutesCompany "https://github.com/abhay-0103/job-portal-project/blob/main/server/routes/companyRoutes.js"
    click RoutesJob "https://github.com/abhay-0103/job-portal-project/blob/main/server/routes/jobRoutes.js"
    click RoutesUser "https://github.com/abhay-0103/job-portal-project/blob/main/server/routes/userRoutes.js"
    click ControllersCompany "https://github.com/abhay-0103/job-portal-project/blob/main/server/controllers/companyController.js"
    click ControllersJob "https://github.com/abhay-0103/job-portal-project/blob/main/server/controllers/jobController.js"
    click ControllersUser "https://github.com/abhay-0103/job-portal-project/blob/main/server/controllers/userController.js"
    click ControllersWebhook "https://github.com/abhay-0103/job-portal-project/blob/main/server/controllers/webhooks.js"
    click ModelsCompany "https://github.com/abhay-0103/job-portal-project/blob/main/server/models/Company.js"
    click ModelsJob "https://github.com/abhay-0103/job-portal-project/blob/main/server/models/Job.js"
    click ModelsJobApp "https://github.com/abhay-0103/job-portal-project/blob/main/server/models/JobApplication.js"
    click ModelsUser "https://github.com/abhay-0103/job-portal-project/blob/main/server/models/User.js"
    click DBConfig "https://github.com/abhay-0103/job-portal-project/blob/main/server/config/db.js"
    click CloudinaryConfig "https://github.com/abhay-0103/job-portal-project/blob/main/server/config/cloudinary.js"
    click MulterConfig "https://github.com/abhay-0103/job-portal-project/blob/main/server/config/multer.js"
    click SentryConfig "https://github.com/abhay-0103/job-portal-project/blob/main/server/config/instrument.js"
    click JWTUtil "https://github.com/abhay-0103/job-portal-project/blob/main/server/utils/generateToken.js"
    click VercelConfigServer "https://github.com/abhay-0103/job-portal-project/blob/main/server/vercel.json"
    click PackageJSONServer "https://github.com/abhay-0103/job-portal-project/blob/main/server/package.json"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#0366d6,color:#000;
    classDef backend fill:#d4edda,stroke:#155724,color:#000;
    classDef services fill:#fff3cd,stroke:#856404,color:#000
```
