# roshantajne/job-scheduling architecture

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

- Interactive diagram: https://gitdiagram.com/roshantajne/job-scheduling
- Repository: https://github.com/roshantajne/job-scheduling

## Overview

##### Project type and purpose
- Type: Full-stack MERN (MongoDB, Express, React, Node.js) web application
- Purpose: A job-scheduling portal that:
– Accepts or rejects new job requests based on time and location constraints
– Visualizes scheduled jobs on a calendar/map
– Optimizes routing via a Travelling Salesman Problem (TSP) algorithm

##### File structure
- Frontend (React):
– project/public: static HTML, manifest, robots.txt
– project/src: React components (Home, About, Map, Form, Details, Service), styling (CSS), images
– project/README.md, package.json: lists React dependencies
- Backend (Node/Express):
– projectserver/server.js: Express entrypoint
– projectserver/routes/api/Job.js: REST endpoints for job CRUD
– projectserver/models/Job.js: Mongoose schema
– projectserver/config/db.js: MongoDB connection logic
– projectserver/vercel.json: deployment config
- Build & Deployment:
– package.json/package-lock.json per folder
– Vercel config for backend

##### Extract insights from README
- Key features: dynamic distance matrix, TSP optimization, OpenStreetMap and Leaflet integration
- Stack: React UI, Express API, MongoDB data store, third-party mapping/routing APIs

##### Main components
a. Frontend Client
– React SPA loaded via index.html
– UI modules: Calendar View, Job Form, Map View (Leaflet + OpenStreetMap), Navbar
b. Backend API Server
– Express.js app exposing REST endpoints (/api/jobs)
– Business logic layer: scheduling rules, time/location validation, TSP solver
– Data access layer: Mongoose ODM connecting to MongoDB
c. Database
– MongoDB instance storing Job documents (job metadata, time windows, locations)
d. External Services
– OpenStreetMap API for base maps
– Leaflet Routing Machine for route queries
e. Optional: CI/CD / Hosting
– Vercel or other hosting for serverless functions
– Static hosting for React build

##### Relationships and data flow
- User interacts with React UI → triggers API calls (fetch jobs, submit new job)
- API Server receives requests →
– Validates request
– Queries MongoDB for existing jobs
– Invokes TSP algorithm + routing API to check job inclusion
– Persists new job or returns rejection
- Server responds with JSON → UI updates state and map visualization
- Component calls Leaflet + OpenStreetMap for rendering routes

##### Architectural patterns & principles
- Client-Server separation (UI vs API)
- MVC-like layering on backend (Routes → Controllers/Business Logic → Models)
- Stateless REST endpoints
- Modular React components for reusability
- Use of third-party services abstracted behind service layer

##### Technologies & frameworks
- React, React Router, CSS modules
- Node.js, Express.js, Mongoose
- MongoDB
- OpenStreetMap, Leaflet, Leaflet Routing Machine
- TSP algorithm module (custom)
- Vercel (deployment)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (React SPA)"
        direction TB
        IndexHTML["Entry Point: index.html"]:::frontend
        Root["React Root: index.js"]:::frontend
        Navbar["Navbar"]:::frontend
        Calendar["Calendar View"]:::frontend
        FormComp["Job Form"]:::frontend
        MapView["Map View"]:::frontend
        Details["Job Details"]:::frontend
        Service["Service Layer"]:::frontend
        DataDef["Shared Data Definitions"]:::frontend
        StylesCSS["Styles (index.css, App.css)"]:::frontend
        ReactPkg["package.json"]:::config
    end

    %% API Server Layer
    subgraph "API Server (Node.js + Express)"
        direction TB
        ServerJS["Server Entrypoint: server.js"]:::server
        DBConfig["DB Config: db.js"]:::server
        Routes["API Routes: Job.js"]:::server
        Logic["Business Logic & TSP Solver"]:::server
        Model["Mongoose Model: Job.js"]:::server
        DeployCfg["Vercel Config"]:::server
        BackendPkg["package.json"]:::config
    end

    %% Database
    DB[(MongoDB)]:::database

    %% External Services
    subgraph "External Services"
        direction TB
        OSM["OpenStreetMap API"]:::external
        LRM["Leaflet Routing Machine"]:::external
    end

    %% Frontend connections
    IndexHTML --> Root
    Root --> Navbar
    Root --> Calendar
    Root --> FormComp
    Root --> MapView
    Root --> Details
    Root --> Service
    Root --> DataDef
    Root --> StylesCSS
    Root --> ReactPkg

    MapView --> OSM
    MapView --> LRM
    Service -->|fetch| Routes

    %% API Server connections
    Routes -->|GET/POST /api/jobs| ServerJS
    ServerJS --> DBConfig
    ServerJS --> Routes
    Routes --> Logic
    Logic --> Model
    Model --> DB
    Logic --> OSM
    Logic --> LRM
    ServerJS --> DeployCfg
    ServerJS --> BackendPkg

    %% Response flows
    DB --> Model
    Model --> Logic
    Logic --> Routes
    Routes --> Service
    Service --> Root

    %% Click Events
    click IndexHTML "https://github.com/roshantajne/job-scheduling/blob/master/project/public/index.html"
    click Root "https://github.com/roshantajne/job-scheduling/blob/master/project/src/index.js"
    click Navbar "https://github.com/roshantajne/job-scheduling/blob/master/project/src/Navbar.js"
    click Calendar "https://github.com/roshantajne/job-scheduling/blob/master/project/src/Home.js"
    click FormComp "https://github.com/roshantajne/job-scheduling/blob/master/project/src/Form.js"
    click MapView "https://github.com/roshantajne/job-scheduling/blob/master/project/src/Map.js"
    click Details "https://github.com/roshantajne/job-scheduling/blob/master/project/src/Details.js"
    click Service "https://github.com/roshantajne/job-scheduling/blob/master/project/src/Service.js"
    click DataDef "https://github.com/roshantajne/job-scheduling/blob/master/project/src/Data.js"
    click StylesCSS "https://github.com/roshantajne/job-scheduling/blob/master/project/src/index.css"
    click ReactPkg "https://github.com/roshantajne/job-scheduling/blob/master/project/package.json"
    click ServerJS "https://github.com/roshantajne/job-scheduling/blob/master/projectserver/server.js"
    click DBConfig "https://github.com/roshantajne/job-scheduling/blob/master/projectserver/config/db.js"
    click Routes "https://github.com/roshantajne/job-scheduling/blob/master/projectserver/routes/api/Job.js"
    click Logic "https://github.com/roshantajne/job-scheduling/blob/master/projectserver/models/Job.js"
    click Model "https://github.com/roshantajne/job-scheduling/blob/master/projectserver/models/Job.js"
    click DeployCfg "https://github.com/roshantajne/job-scheduling/blob/master/projectserver/vercel.json"
    click BackendPkg "https://github.com/roshantajne/job-scheduling/blob/master/projectserver/package.json"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#006064,color:#006064;
    classDef server fill:#E8F5E9,stroke:#1B5E20,color:#1B5E20;
    classDef database fill:#FFF3E0,stroke:#E65100,color:#E65100;
    classDef external fill:#ECEFF1,stroke:#37474F,color:#37474F;
    classDef config fill:#F3E5F5,stroke:#6A1B9A,color:#6A1B9A;
```
