# magesh-sam/job-portal architecture

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

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

## Overview

##### Project type and purpose
- This is a Single-Page Application (“Job Portal”) written in React + TypeScript.
- It uses a mock backend (json-server) to expose RESTful endpoints over a local JSON file (db.json).
- Key features: user/admin roles, job CRUD, save jobs, theme toggle, profile pages, WYSIWYG editor (TinyMCE).

##### File structure
- Top level: configuration files (.env, tsconfig, vite.config.ts), package.json, README.
- public/: static assets (index.html, screenshots).
- src/: application code subdivided into:
- pages/ (route-level components)
- components/ (UI components & Shadcn UI wrappers)
- hooks/ (data-fetching & mutation hooks)
- redux/ (Redux Toolkit slices, rootReducer, store)
- lib/ (shared types, utils, mock data)
- main.tsx + App.tsx (entrypoints)
- db.json + json-server script emulate backend API.

##### Key architectural insights from README
- Frontend communicates with json-server via REST (GET/POST/PUT/DELETE).
- Uses React Router for navigation.
- State is managed in Redux Toolkit (jobsSlice, userSlice).
- React Hook Form + TinyMCE for job-form input.
- Tailwind CSS + Shadcn UI for styling and UI primitives.

A. Client (Browser)
1. Vite Dev Server (or built static bundle) → serves index.html + JS/CSS.
2. React App
- Presentation layer: Pages & reusable Components (JobCard, Navbar, etc.)
- State layer: Redux store (jobsSlice, userSlice)
- Data layer: custom hooks (useGetJobs, useDeleteJobById, etc.)
- Utility layer: lib/utils, lib/types
- External integration: TinyMCE (via its cloud API key)
B. Backend (Mock API)
- json-server process
- Endpoints: /jobs, /users, /candidates, etc.
- Persistence: db.json

##### Relationships & interactions
- On mount or user action → React Hook (useGetJobs) dispatches Redux async thunk → HTTP GET → json-server → returns JSON → Redux store updates → UI re-renders.
- Form submissions (job create/edit) → Hook → HTTP POST/PUT → json-server → updates db.json → response flows back to client.
- Auth flow: LoginForm sends credentials to /users endpoint → json-server returns user data → stored in userSlice.
- Theme toggle: client-side only via ThemeProvider component (no server involvement).
- TinyMCE: loaded via script from TinyMCE cloud, used inside JobForm.

##### Architectural patterns & design principles
- Component-based UI (React functional components + Shadcn/UI primitives).
- Layered front-end architecture (Presentation → State → Data → Utilities).
- Redux Toolkit for predictable global state.
- Hooks for encapsulating side-effects (data-fetching).
- RESTful API separation (client ↔ json-server).

- Have you separated the SPA into logical layers?
- Have you labeled all major Redux slices and hooks?
- Are all HTTP endpoints and the db.json store represented?
- Is the TinyMCE integration shown as an external dependency?

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Configuration"
        VITECFG["vite.config.ts"]:::config
        ENV[".env"]:::config
        TAIL["tailwind.config.js"]:::config
        CSSCFG["Global Styles (src/index.css)"]:::config
        INDEXHT["index.html"]:::frontend
    end

    subgraph "Browser (React SPA)"
        subgraph "Dev & Entry"
            VITE["Vite Dev Server"]:::config
            VITE --> INDEXHT
            INDEXHT --> MAINTSX
            MAINTSX["main.tsx"]:::frontend
            APPTSX["App.tsx"]:::frontend
        end

        subgraph "Presentation Layer"
            PAGES["Pages (src/pages/)"]:::frontend
            UI["UI Components (src/components/)"]:::frontend
            SHADCN["Shadcn UI Primitives (src/components/ui/)"]:::frontend
        end

        subgraph "State Layer"
            STORE["Redux Store (store.ts)"]:::state
            ROOT["Root Reducer (rootReducer.ts)"]:::state
            JOBS["Jobs Slice (jobsSlice.ts)"]:::state
            USER["User Slice (userSlice.ts)"]:::state
        end

        subgraph "Data Layer"
            HOOKS["Custom Hooks (src/hooks/)"]:::data
        end

        subgraph "Utility Layer"
            TYPES["Shared Types (types.ts)"]:::util
            UTILS["Utility Functions (utils.ts)"]:::util
            DATADEF["Mock Data Definitions (data.ts)"]:::util
        end

        subgraph "External Service"
            TINYMCE["TinyMCE Cloud"]:::external
        end
    end

    subgraph "json-server (Mock API)"
        API["json-server"]:::api
        subgraph "Endpoints"
            JOBAPI["/jobs"]:::api
            USERAPI["/users"]:::api
            CANDAPI["/candidates"]:::api
        end
        DB["db.json"]:::storage
    end

    %% Internal Data Flows
    APPTSX -.->|renders| PAGES
    APPTSX -.->|renders| UI
    APPTSX -.->|renders| SHADCN
    PAGES -.->|uses hooks| HOOKS
    UI -.->|uses hooks| HOOKS
    SHADCN -.->|uses hooks| HOOKS
    HOOKS -.->|dispatches async thunk| STORE
    STORE -->|combines with| ROOT
    STORE -->|manages state| JOBS
    STORE -->|manages state| USER

    %% HTTP Requests
    HOOKS -->|"GET/POST/PUT/DELETE"| JOBAPI
    HOOKS -->|"auth requests"| USERAPI
    HOOKS -->|"candidate data"| CANDAPI
    JOBAPI -->|reads/writes| DB
    USERAPI -->|reads/writes| DB
    CANDAPI -->|reads/writes| DB

    %% External Integration
    PAGES -.->|loads editor| TINYMCE

    %% Configuration & Dev Server
    VITECFG -->|configures| VITE

    %% Click Events
    click VITECFG "https://github.com/magesh-sam/job-portal/blob/main/vite.config.ts"
    click MAINTSX "https://github.com/magesh-sam/job-portal/blob/main/src/main.tsx"
    click APPTSX "https://github.com/magesh-sam/job-portal/blob/main/src/App.tsx"
    click PAGES "https://github.com/magesh-sam/job-portal/tree/main/src/pages/"
    click UI "https://github.com/magesh-sam/job-portal/tree/main/src/components/"
    click SHADCN "https://github.com/magesh-sam/job-portal/tree/main/src/components/ui/"
    click STORE "https://github.com/magesh-sam/job-portal/blob/main/src/redux/store.ts"
    click ROOT "https://github.com/magesh-sam/job-portal/blob/main/src/redux/rootReducer.ts"
    click JOBS "https://github.com/magesh-sam/job-portal/blob/main/src/redux/features/jobs/jobsSlice.ts"
    click USER "https://github.com/magesh-sam/job-portal/blob/main/src/redux/features/user/userSlice.ts"
    click HOOKS "https://github.com/magesh-sam/job-portal/tree/main/src/hooks/"
    click TYPES "https://github.com/magesh-sam/job-portal/blob/main/src/lib/types.ts"
    click UTILS "https://github.com/magesh-sam/job-portal/blob/main/src/lib/utils.ts"
    click DATADEF "https://github.com/magesh-sam/job-portal/blob/main/src/lib/data.ts"
    click TINYMCE "https://github.com/magesh-sam/job-portal/blob/main/src/pages/JobForm.tsx"
    click DB "https://github.com/magesh-sam/job-portal/blob/main/db.json"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6
    classDef state fill:#D4F1BE,stroke:#3C9D1A
    classDef api fill:#FFD1A1,stroke:#E37B00
    classDef external fill:#FFF5BA,stroke:#E1B800
    classDef data fill:#E8D5FF,stroke:#9F3EDF
    classDef util fill:#FFE4C4,stroke:#D2A679
    classDef config fill:#EDEEF0,stroke:#B0B0B0
    classDef storage fill:#F0D9FF,stroke:#C78ADE
```
