# niharika1102/jobify architecture

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

- Interactive diagram: https://gitdiagram.com/niharika1102/jobify
- Repository: https://github.com/niharika1102/jobify

## Overview

##### Project Type and Purpose
- Jobify is a full-stack web application (MERN: MongoDB, Express, React, Node).
- Purpose: allow job seekers to add/edit/delete job applications, track stats, and manage profiles via a sleek UI.

##### File Structure
- Top-level:
- client/ – React front-end (Vite, JSX, components, pages, wrappers, assets).
- controllers/, routes/, models/ – Backend Express MVC layers.
- middleware/ – Express middleware (auth, validation, error handling, file uploads).
- utils/ – Shared utilities (constants, token/password helpers, mock data).
- server.js – Entry point for the Node/Express server.
- populate.js – Script to seed the database.
- package.json (root & client) – Dependencies and scripts.
- Architecture: clearly follows MVC, RESTful API, React component/page hierarchy, React Query for data fetching.

##### README for Additional Insights
- Built with: MERN stack, Axios, React Router, MVC, bcryptjs, Recharts, React Query.
- Features: REST API for CRUD on jobs, JWT auth, password hashing, responsive React UI with charts.

##### Main Components and Their Interactions
a. Frontend (React App)
- Pages: Landing, Register, Login, Dashboard, Stats, AllJobs, AddJob, EditJob, Profile, Admin
- Components/Wrappers: Navbar, Sidebars, ChartsContainer, FormRow, JobList, ErrorPage, etc.
- Utils: customFetch (Axios wrapper), links config, React Query hooks.
- Build: Vite for bundling.
b. Backend (Node/Express API)
- server.js – Configures Express, global middleware, routes.
- Routes: /api/v1/auth, /api/v1/jobs, /api/v1/users
- Controllers: authController (login/register), jobController (CRUD jobs), userController (profile update)
- Models: userModel (defines User schema), jobModel (defines Job schema)
- Middleware: authMiddleware (JWT verification), validationMiddleware, multerMiddleware (file uploads), errorHandlerMiddleware
- Utils: passwordUtils (hash/compare), tokenUtils (sign/verify JWT), constants (status codes).
c. Database
- MongoDB – hosted (e.g., Atlas or local), stores users and jobs collections.
d. External Services
- Render (hosting front and back)
- Potential file storage if multer uploads to S3 or similar (not shown but easy to add).

##### Relationships and Data Flows
- Browser → React App: user interacts via UI, React Router manages routes.
- React App → Express API: Axios (customFetch) sends HTTP requests (with JWT in headers).
- Express API → MongoDB: Mongoose ORM reads/writes user and job documents.
- Middleware intercepts requests for auth, validation, error handling.
- Controllers orchestrate business logic, models handle persistence.

##### Important Architectural Patterns and Design Principles
- MVC on backend: separation of routes, controllers, models.
- RESTful API design: clear resource endpoints.
- JWT-based stateless authentication.
- React Query for caching and synchronizing server state.
- Recharts for data visualization (Stats page).

##### Additional Details to Capture
- Use of Vite dev server on the client side.
- React Query layer between Components and Axios.
- Population script (populate.js) as an initialization task.
- Error handling flow: Controller → errorHandlerMiddleware → HTTP response.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Browser to Frontend
    Browser["Browser"]:::external
    Browser -->|"1: User Interaction"| FrontendApp

    %% Frontend Application
    subgraph "Frontend (client/)" 
        direction TB
        FrontendApp["App.jsx"]:::frontend
        MainRender["main.jsx"]:::frontend
        ViteServer["Vite Dev Server"]:::frontend
        ReactQuery["React Query"]:::frontend

        subgraph "Pages (client/src/pages/)"
            direction TB
            Landing["Landing.jsx"]:::frontend
            Register["Register.jsx"]:::frontend
            Login["Login.jsx"]:::frontend
            DashboardLayout["DashboardLayout.jsx"]:::frontend
            HomeLayout["HomeLayout.jsx"]:::frontend
            AllJobs["AllJobs.jsx"]:::frontend
            AddJob["AddJob.jsx"]:::frontend
            EditJob["EditJob.jsx"]:::frontend
            DeleteJob["DeleteJob.jsx"]:::frontend
            StatsPage["Stats.jsx"]:::frontend
            Profile["Profile.jsx"]:::frontend
            Admin["Admin.jsx"]:::frontend
            ErrorPage["Error.jsx"]:::frontend
        end

        subgraph "UI Components/Utilities"
            direction TB
            Components["Components & Wrappers"]:::frontend
            UtilsFE["customFetch, links, Vite Config"]:::frontend
        end

        FrontendApp --> MainRender
        MainRender --> ViteServer
        FrontendApp --> ReactQuery
        ReactQuery --> Components
        Components --> UtilsFE
        FrontendApp -->|"2: HTTP Calls\nAxios/customFetch,\nJWT in headers"| BackendAPI
    end

    %% Backend API
    subgraph "Backend (server/)" 
        direction TB
        BackendAPI["server.js"]:::backend

        subgraph "Routes (routes/)"
            direction TB
            AuthRoutes["authRouter.js"]:::backend
            JobRoutes["jobRouter.js"]:::backend
            UserRoutes["userRouter.js"]:::backend
        end

        subgraph "Middleware (middleware/)"
            direction TB
            AuthMW["authMiddleware.js"]:::backend
            ValidationMW["validationMiddleware.js"]:::backend
            MulterMW["multerMiddleware.js"]:::backend
            ErrorHandlerMW["errorHandlerMiddleware.js"]:::backend
        end

        subgraph "Controllers (controllers/)"
            direction TB
            AuthCtrl["authController.js"]:::backend
            JobCtrl["jobController.js"]:::backend
            UserCtrl["userController.js"]:::backend
        end

        subgraph "Models (models/)"
            direction TB
            UserModel["userModel.js"]:::backend
            JobModel["jobModel.js"]:::backend
        end

        subgraph "Utils (utils/)"
            direction TB
            Constants["constants.js"]:::backend
            TokenUtils["tokenUtils.js"]:::backend
            PasswordUtils["passwordUtils.js"]:::backend
            MockData["mockData.json"]:::backend
        end

        populate["populate.js"]:::backend

        %% Backend flow
        BackendAPI --> AuthRoutes
        BackendAPI --> JobRoutes
        BackendAPI --> UserRoutes
        AuthRoutes --> AuthMW
        JobRoutes --> AuthMW
        UserRoutes --> AuthMW
        AuthMW --> ValidationMW
        ValidationMW --> AuthCtrl
        JobRoutes --> ValidationMW
        ValidationMW --> JobCtrl
        UserRoutes --> ValidationMW
        ValidationMW --> UserCtrl
        AuthCtrl --> UserModel
        JobCtrl --> JobModel
        UserCtrl --> UserModel
        AuthCtrl --> TokenUtils
        AuthCtrl --> PasswordUtils
        populate -.-> MockData
        populate --> UserModel
        populate --> JobModel

        AuthCtrl --> ErrorHandlerMW
        JobCtrl --> ErrorHandlerMW
        UserCtrl --> ErrorHandlerMW

        ErrorHandlerMW --> BackendAPI
    end

    %% Database
    MongoDB[(MongoDB)]:::db
    JobModel -->|"3: Mongoose Queries"| MongoDB
    UserModel --> MongoDB
    MongoDB -->|"4: Query Results"| BackendAPI

    %% External Services
    Render["Render (Hosting)"]:::external
    FrontendApp --> Render
    BackendAPI --> Render

    %% Click events for frontend pages
    click Landing "https://github.com/niharika1102/jobify/blob/main/client/src/pages/Landing.jsx"
    click Register "https://github.com/niharika1102/jobify/blob/main/client/src/pages/Register.jsx"
    click Login "https://github.com/niharika1102/jobify/blob/main/client/src/pages/Login.jsx"
    click DashboardLayout "https://github.com/niharika1102/jobify/blob/main/client/src/pages/DashboardLayout.jsx"
    click HomeLayout "https://github.com/niharika1102/jobify/blob/main/client/src/pages/HomeLayout.jsx"
    click AllJobs "https://github.com/niharika1102/jobify/blob/main/client/src/pages/AllJobs.jsx"
    click AddJob "https://github.com/niharika1102/jobify/blob/main/client/src/pages/AddJob.jsx"
    click EditJob "https://github.com/niharika1102/jobify/blob/main/client/src/pages/EditJob.jsx"
    click DeleteJob "https://github.com/niharika1102/jobify/blob/main/client/src/pages/DeleteJob.jsx"
    click StatsPage "https://github.com/niharika1102/jobify/blob/main/client/src/pages/Stats.jsx"
    click Profile "https://github.com/niharika1102/jobify/blob/main/client/src/pages/Profile.jsx"
    click Admin "https://github.com/niharika1102/jobify/blob/main/client/src/pages/Admin.jsx"
    click ErrorPage "https://github.com/niharika1102/jobify/blob/main/client/src/pages/Error.jsx"
    click FrontendApp "https://github.com/niharika1102/jobify/blob/main/client/src/App.jsx"
    click MainRender "https://github.com/niharika1102/jobify/blob/main/client/src/main.jsx"
    click ViteServer "https://github.com/niharika1102/jobify/blob/main/client/vite.config.js"

    %% Click events for backend
    click BackendAPI "https://github.com/niharika1102/jobify/blob/main/server.js"
    click AuthRoutes "https://github.com/niharika1102/jobify/blob/main/routes/authRouter.js"
    click JobRoutes "https://github.com/niharika1102/jobify/blob/main/routes/jobRouter.js"
    click UserRoutes "https://github.com/niharika1102/jobify/blob/main/routes/userRouter.js"
    click AuthCtrl "https://github.com/niharika1102/jobify/blob/main/controllers/authController.js"
    click JobCtrl "https://github.com/niharika1102/jobify/blob/main/controllers/jobController.js"
    click UserCtrl "https://github.com/niharika1102/jobify/blob/main/controllers/userController.js"
    click UserModel "https://github.com/niharika1102/jobify/blob/main/models/userModel.js"
    click JobModel "https://github.com/niharika1102/jobify/blob/main/models/jobModel.js"
    click AuthMW "https://github.com/niharika1102/jobify/blob/main/middleware/authMiddleware.js"
    click ValidationMW "https://github.com/niharika1102/jobify/blob/main/middleware/validationMiddleware.js"
    click MulterMW "https://github.com/niharika1102/jobify/blob/main/middleware/multerMiddleware.js"
    click ErrorHandlerMW "https://github.com/niharika1102/jobify/blob/main/middleware/errorHandlerMiddleware.js"
    click Constants "https://github.com/niharika1102/jobify/blob/main/utils/constants.js"
    click TokenUtils "https://github.com/niharika1102/jobify/blob/main/utils/tokenUtils.js"
    click PasswordUtils "https://github.com/niharika1102/jobify/blob/main/utils/passwordUtils.js"
    click MockData "https://github.com/niharika1102/jobify/blob/main/utils/mockData.json"
    click populate "https://github.com/niharika1102/jobify/blob/main/populate.js"

    %% 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:#e2e3e5,stroke:#333,stroke-width:1px
```
