# mananshahid/staffsync-ems architecture

> Architecture diagram of the GitHub repository mananshahid/staffsync-ems, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mananshahid/staffsync-ems
- Repository: https://github.com/mananshahid/staffsync-ems

## Overview

EMS is a role-scoped employee management workspace. Users enter through the React application, authenticate into the workspace, and use its people and operations features; the backend route table dispatches API requests to domain controllers backed by MongoDB models. The README documents major capabilities including attendance, leave/WFH approvals, payroll and payslips, tasks, recruitment, assets, teams, chat, complaints, and appraisals. Some domain implementations were not sampled, so their internal call paths are not expanded.

Main entry points: [`backend/src/controllers`](https://github.com/mananshahid/staffsync-ems/tree/main/backend/src/controllers) (Domain controllers), [`frontend/src/App.jsx`](https://github.com/mananshahid/staffsync-ems/blob/main/frontend/src/App.jsx) (App routes), [`backend/src/index.js`](https://github.com/mananshahid/staffsync-ems/blob/main/backend/src/index.js) (Backend startup), [`backend/src/routes/index.js`](https://github.com/mananshahid/staffsync-ems/blob/main/backend/src/routes/index.js) (API routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_app["App routes<br/>[App.jsx]"]
  node_authctx["Session context<br/>[AuthContext.jsx]"]
  node_datacontext["Shared data context<br/>[DataContext.jsx]"]
  node_api_client["API client<br/>[api.js]"]
  node_ui["Shared UI<br/>[ui.jsx]"]
  node_task_page["Task workspace<br/>[Tasks.jsx]"]
  node_coverage_page["Coverage planner"]
  node_socket_client["Socket client<br/>[socket.js]"]
end

subgraph group_backend["API and domain"]
  node_api_routes["API routes<br/>[index.js]"]
  node_auth_mw["Session middleware<br/>[auth.js]"]
  node_domain_controllers["Domain controllers"]
  node_backend_entry["Backend startup<br/>[index.js]"]
end

subgraph group_shared["State and policy"]
  node_access["Access policy<br/>[access.js]"]
  node_payroll["Payroll calculations<br/>[payroll.js]"]
  node_helpers["Notifications and helpers<br/>[helpers.js]"]
end

subgraph group_integrations["Persistence and messaging"]
  node_models[("Domain models")]
  node_db_config["Database setup<br/>[db.js]"]
  node_mailer["Mail delivery<br/>[mailer.js]"]
  node_realtime["Realtime events<br/>[realtime.js]"]
  node_storage_config["File storage<br/>[storage.js]"]
end

node_user(("Workspace user"))

node_user -->|"uses"| node_app
node_app -->|"checks session"| node_authctx
node_authctx -->|"requests session"| node_api_client
node_datacontext -->|"fetches shared data"| node_api_client
node_datacontext -->|"connects realtime"| node_socket_client
node_app -->|"routes to"| node_task_page
node_app -->|"routes to"| node_coverage_page
node_task_page -->|"renders"| node_ui
node_coverage_page -->|"renders"| node_ui
node_backend_entry -->|"mounts routes"| node_api_routes
node_backend_entry -->|"connects database"| node_db_config
node_api_routes -->|"applies auth"| node_auth_mw
node_api_routes -->|"dispatches requests"| node_domain_controllers
node_domain_controllers -->|"reads and writes"| node_models
node_domain_controllers -->|"checks scope"| node_access
node_domain_controllers -->|"uses calculations"| node_payroll
node_domain_controllers -->|"sends notifications"| node_helpers
node_helpers -->|"delivers messages"| node_mailer
node_helpers -->|"emits events"| node_realtime
node_backend_entry -->|"initializes"| node_realtime

click node_app "https://github.com/mananshahid/staffsync-ems/blob/main/frontend/src/App.jsx"
click node_authctx "https://github.com/mananshahid/staffsync-ems/blob/main/frontend/src/context/AuthContext.jsx"
click node_datacontext "https://github.com/mananshahid/staffsync-ems/blob/main/frontend/src/context/DataContext.jsx"
click node_api_client "https://github.com/mananshahid/staffsync-ems/blob/main/frontend/src/lib/api.js"
click node_ui "https://github.com/mananshahid/staffsync-ems/blob/main/frontend/src/components/ui.jsx"
click node_task_page "https://github.com/mananshahid/staffsync-ems/blob/main/frontend/src/pages/Tasks.jsx"
click node_coverage_page "https://github.com/mananshahid/staffsync-ems/blob/main/frontend/src/pages/CoveragePlanner.jsx"
click node_api_routes "https://github.com/mananshahid/staffsync-ems/blob/main/backend/src/routes/index.js"
click node_auth_mw "https://github.com/mananshahid/staffsync-ems/blob/main/backend/src/middleware/auth.js"
click node_domain_controllers "https://github.com/mananshahid/staffsync-ems/tree/main/backend/src/controllers"
click node_models "https://github.com/mananshahid/staffsync-ems/tree/main/backend/src/models"
click node_access "https://github.com/mananshahid/staffsync-ems/blob/main/backend/src/utils/access.js"
click node_payroll "https://github.com/mananshahid/staffsync-ems/blob/main/backend/src/utils/payroll.js"
click node_helpers "https://github.com/mananshahid/staffsync-ems/blob/main/backend/src/utils/helpers.js"
click node_backend_entry "https://github.com/mananshahid/staffsync-ems/blob/main/backend/src/index.js"
click node_db_config "https://github.com/mananshahid/staffsync-ems/blob/main/backend/src/config/db.js"
click node_mailer "https://github.com/mananshahid/staffsync-ems/blob/main/backend/src/config/mailer.js"
click node_realtime "https://github.com/mananshahid/staffsync-ems/blob/main/backend/src/realtime.js"
click node_socket_client "https://github.com/mananshahid/staffsync-ems/blob/main/frontend/src/lib/socket.js"
click node_storage_config "https://github.com/mananshahid/staffsync-ems/blob/main/backend/src/config/storage.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_authctx,node_datacontext,node_api_client,node_ui,node_task_page,node_coverage_page,node_socket_client,node_user toneBlue
class node_api_routes,node_auth_mw,node_domain_controllers,node_backend_entry toneAmber
class node_access,node_payroll,node_helpers toneMint
class node_models,node_db_config,node_mailer,node_realtime,node_storage_config toneRose
```

## Components

### Web application

- [App routes](https://github.com/mananshahid/staffsync-ems/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Session context](https://github.com/mananshahid/staffsync-ems/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Shared data context](https://github.com/mananshahid/staffsync-ems/blob/main/frontend/src/context/DataContext.jsx): `frontend/src/context/DataContext.jsx`
- [API client](https://github.com/mananshahid/staffsync-ems/blob/main/frontend/src/lib/api.js): `frontend/src/lib/api.js`
- [Shared UI](https://github.com/mananshahid/staffsync-ems/blob/main/frontend/src/components/ui.jsx): `frontend/src/components/ui.jsx`
- [Task workspace](https://github.com/mananshahid/staffsync-ems/blob/main/frontend/src/pages/Tasks.jsx): `frontend/src/pages/Tasks.jsx`
- [Coverage planner](https://github.com/mananshahid/staffsync-ems/blob/main/frontend/src/pages/CoveragePlanner.jsx): `frontend/src/pages/CoveragePlanner.jsx`
- [Socket client](https://github.com/mananshahid/staffsync-ems/blob/main/frontend/src/lib/socket.js): `frontend/src/lib/socket.js`

### API and domain

- [API routes](https://github.com/mananshahid/staffsync-ems/blob/main/backend/src/routes/index.js): `backend/src/routes/index.js`
- [Session middleware](https://github.com/mananshahid/staffsync-ems/blob/main/backend/src/middleware/auth.js): `backend/src/middleware/auth.js`
- [Domain controllers](https://github.com/mananshahid/staffsync-ems/tree/main/backend/src/controllers): `backend/src/controllers`
- [Backend startup](https://github.com/mananshahid/staffsync-ems/blob/main/backend/src/index.js): `backend/src/index.js`

### State and policy

- [Access policy](https://github.com/mananshahid/staffsync-ems/blob/main/backend/src/utils/access.js): `backend/src/utils/access.js`
- [Payroll calculations](https://github.com/mananshahid/staffsync-ems/blob/main/backend/src/utils/payroll.js): `backend/src/utils/payroll.js`
- [Notifications and helpers](https://github.com/mananshahid/staffsync-ems/blob/main/backend/src/utils/helpers.js): `backend/src/utils/helpers.js`

### Persistence and messaging

- [Domain models](https://github.com/mananshahid/staffsync-ems/tree/main/backend/src/models): `backend/src/models`
- [Database setup](https://github.com/mananshahid/staffsync-ems/blob/main/backend/src/config/db.js): `backend/src/config/db.js`
- [Mail delivery](https://github.com/mananshahid/staffsync-ems/blob/main/backend/src/config/mailer.js): `backend/src/config/mailer.js`
- [Realtime events](https://github.com/mananshahid/staffsync-ems/blob/main/backend/src/realtime.js): `backend/src/realtime.js`
- [File storage](https://github.com/mananshahid/staffsync-ems/blob/main/backend/src/config/storage.js): `backend/src/config/storage.js`

### Other components

- **Workspace user**

## Connections

- Workspace user → App routes: uses (evidence: `README.md`)
- App routes → Session context: checks session (evidence: `frontend/src/App.jsx`)
- Session context → API client: requests session (evidence: `frontend/src/context/AuthContext.jsx`)
- Shared data context → API client: fetches shared data (evidence: `frontend/src/context/DataContext.jsx`)
- Shared data context → Socket client: connects realtime (evidence: `frontend/src/context/DataContext.jsx`)
- App routes → Task workspace: routes to (evidence: `frontend/src/App.jsx`)
- App routes → Coverage planner: routes to (evidence: `frontend/src/App.jsx`)
- Task workspace → Shared UI: renders (evidence: `frontend/src/pages/Tasks.jsx`)
- Coverage planner → Shared UI: renders (evidence: `frontend/src/pages/CoveragePlanner.jsx`)
- Backend startup → API routes: mounts routes (evidence: `backend/src/index.js`)
- Backend startup → Database setup: connects database (evidence: `backend/src/index.js`)
- API routes → Session middleware: applies auth (evidence: `backend/src/routes/index.js`)
- API routes → Domain controllers: dispatches requests (evidence: `backend/src/routes/index.js`)
- Domain controllers → Domain models: reads and writes (evidence: `backend/src/controllers/attendanceController.js`)
- Domain controllers → Access policy: checks scope (evidence: `backend/src/controllers/coverageController.js`)
- Domain controllers → Payroll calculations: uses calculations (evidence: `backend/src/controllers/attendanceController.js`)
- Domain controllers → Notifications and helpers: sends notifications (evidence: `backend/src/controllers/attendanceController.js`)
- Notifications and helpers → Mail delivery: delivers messages (evidence: `backend/src/utils/helpers.js`)
- Notifications and helpers → Realtime events: emits events (evidence: `backend/src/utils/helpers.js`)
- Backend startup → Realtime events: initializes (evidence: `backend/src/index.js`)
