# barabari-tech-collective/leave-management-system architecture

> Architecture diagram of the GitHub repository barabari-tech-collective/leave-management-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/barabari-tech-collective/leave-management-system
- Repository: https://github.com/barabari-tech-collective/leave-management-system

## Overview

The Barabari Collective Leave Management Portal lets employees apply for leave and track balances and decisions, while vertical leads and admins review requests and manage staff. The workflow runs from role-based React pages through session-authenticated Express routes to leave/user records, with email notifications for applications and decisions. Separate branches cover account provisioning, organizational lifecycle management, and scheduled holiday announcements. Relationships below are limited to source excerpts and README documentation; some frontend pages and integrations are represented at their documented paths, not inspected implementations.

Main entry points: [`frontend/src/api/axiosConfig.js`](https://github.com/barabari-tech-collective/leave-management-system/blob/main/frontend/src/api/axiosConfig.js) (HTTP client), [`backend/app.js`](https://github.com/barabari-tech-collective/leave-management-system/blob/main/backend/app.js) (Express app), [`backend/routes/authRoutes.js`](https://github.com/barabari-tech-collective/leave-management-system/blob/main/backend/routes/authRoutes.js) (Authentication routes), [`backend/controllers/leaveController.js`](https://github.com/barabari-tech-collective/leave-management-system/blob/main/backend/controllers/leaveController.js) (Leave workflows)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Role-based portal"]
  node_routes["Role-based routing<br/>[AppRoutes.jsx]"]
  node_authui["Session context<br/>[AuthContext.jsx]"]
  node_apply["Apply for leave<br/>[ApplyLeave.jsx]"]
  node_employeeviews["Balance, history, policy"]
  node_leadview["Team review"]
  node_adminview["Admin overview<br/>[AdminDashboard.jsx]"]
  node_staffviews["Staff lifecycle views"]
  node_api["HTTP client<br/>[axiosConfig.js]"]
end

subgraph group_backend["Leave services"]
  node_app["Express app<br/>[app.js]"]
  node_authroutes["Authentication routes<br/>[authRoutes.js]"]
  node_leaveapi["Leave routes<br/>[leaveRoutes.js]"]
  node_controller["Leave workflows<br/>[leaveController.js]"]
  node_authmw["Session guard<br/>[authMiddleware.js]"]
  node_leave[("Leave records<br/>[Leave.js]")]
end

subgraph group_management["People administration"]
  node_userapi["User routes<br/>[userRoutes.js]"]
  node_user[("User accounts and balances<br/>[User.js]")]
end

subgraph group_notifications["Email automation"]
  node_holiday["Holiday scheduler<br/>[holidayCron.js]"]
  node_email["Notification service<br/>[emailService.js]"]
end

node_employee(("Employee"))
node_adminlead(("Admin / Lead"))
node_resend["Resend email"]

node_employee -.->|"uses portal"| node_routes
node_adminlead -.->|"uses portal"| node_routes
node_routes -.->|"guards routes"| node_authui
node_authui -->|"fetches session"| node_api
node_apply -.->|"submits request"| node_api
node_employeeviews -.->|"loads leave data"| node_api
node_leadview -.->|"loads team requests"| node_api
node_adminview -->|"loads overview"| node_api
node_staffviews -.->|"manages staff"| node_api
node_api -.->|"HTTP requests"| node_app
node_app -->|"mounts /auth"| node_authroutes
node_app -->|"mounts /leave"| node_leaveapi
node_app -->|"mounts /users"| node_userapi
node_authroutes -->|"guards provisioning"| node_authmw
node_leaveapi -->|"guards endpoints"| node_authmw
node_userapi -->|"guards endpoints"| node_authmw
node_leaveapi -->|"dispatches workflows"| node_controller
node_controller -->|"creates and reads"| node_leave
node_controller -->|"reads and updates"| node_user
node_userapi -->|"manages accounts"| node_user
node_userapi -->|"migrates records"| node_leave
node_authroutes -->|"authenticates and creates"| node_user
node_controller -->|"sends leave notices"| node_email
node_authroutes -->|"sends welcome email"| node_email
node_app -->|"starts scheduler"| node_holiday
node_holiday -->|"finds recipients"| node_user
node_holiday -->|"sends holiday notice"| node_email
node_email -->|"dispatches email"| node_resend

click node_routes "https://github.com/barabari-tech-collective/leave-management-system/blob/main/frontend/src/routes/AppRoutes.jsx"
click node_authui "https://github.com/barabari-tech-collective/leave-management-system/blob/main/frontend/src/context/AuthContext.jsx"
click node_apply "https://github.com/barabari-tech-collective/leave-management-system/blob/main/frontend/src/pages/employee/ApplyLeave.jsx"
click node_employeeviews "https://github.com/barabari-tech-collective/leave-management-system/tree/main/frontend/src/pages/employee"
click node_leadview "https://github.com/barabari-tech-collective/leave-management-system/blob/main/frontend/src/pages/verticalLead/VerticalLeadDashboard.jsx"
click node_adminview "https://github.com/barabari-tech-collective/leave-management-system/blob/main/frontend/src/pages/admin/AdminDashboard.jsx"
click node_staffviews "https://github.com/barabari-tech-collective/leave-management-system/blob/main/frontend/src/pages/admin/ManageVerticals.jsx"
click node_api "https://github.com/barabari-tech-collective/leave-management-system/blob/main/frontend/src/api/axiosConfig.js"
click node_app "https://github.com/barabari-tech-collective/leave-management-system/blob/main/backend/app.js"
click node_authroutes "https://github.com/barabari-tech-collective/leave-management-system/blob/main/backend/routes/authRoutes.js"
click node_leaveapi "https://github.com/barabari-tech-collective/leave-management-system/blob/main/backend/routes/leaveRoutes.js"
click node_controller "https://github.com/barabari-tech-collective/leave-management-system/blob/main/backend/controllers/leaveController.js"
click node_authmw "https://github.com/barabari-tech-collective/leave-management-system/blob/main/backend/middleware/authMiddleware.js"
click node_userapi "https://github.com/barabari-tech-collective/leave-management-system/blob/main/backend/routes/userRoutes.js"
click node_user "https://github.com/barabari-tech-collective/leave-management-system/blob/main/backend/models/User.js"
click node_leave "https://github.com/barabari-tech-collective/leave-management-system/blob/main/backend/models/Leave.js"
click node_holiday "https://github.com/barabari-tech-collective/leave-management-system/blob/main/backend/cron/holidayCron.js"
click node_email "https://github.com/barabari-tech-collective/leave-management-system/blob/main/backend/services/emailService.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_routes,node_authui,node_apply,node_employeeviews,node_leadview,node_adminview,node_staffviews,node_api toneBlue
class node_app,node_authroutes,node_leaveapi,node_controller,node_authmw,node_leave toneAmber
class node_userapi,node_user toneMint
class node_holiday,node_email toneRose
class node_employee,node_adminlead,node_resend toneIndigo
```

## Components

### Role-based portal

- [Role-based routing](https://github.com/barabari-tech-collective/leave-management-system/blob/main/frontend/src/routes/AppRoutes.jsx): `frontend/src/routes/AppRoutes.jsx`
- [Session context](https://github.com/barabari-tech-collective/leave-management-system/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Apply for leave](https://github.com/barabari-tech-collective/leave-management-system/blob/main/frontend/src/pages/employee/ApplyLeave.jsx): `frontend/src/pages/employee/ApplyLeave.jsx`
- [Balance, history, policy](https://github.com/barabari-tech-collective/leave-management-system/tree/main/frontend/src/pages/employee): `frontend/src/pages/employee`
- [Team review](https://github.com/barabari-tech-collective/leave-management-system/blob/main/frontend/src/pages/verticalLead/VerticalLeadDashboard.jsx): `frontend/src/pages/verticalLead/VerticalLeadDashboard.jsx`
- [Admin overview](https://github.com/barabari-tech-collective/leave-management-system/blob/main/frontend/src/pages/admin/AdminDashboard.jsx): `frontend/src/pages/admin/AdminDashboard.jsx`
- [Staff lifecycle views](https://github.com/barabari-tech-collective/leave-management-system/blob/main/frontend/src/pages/admin/ManageVerticals.jsx): `frontend/src/pages/admin/ManageVerticals.jsx`
- [HTTP client](https://github.com/barabari-tech-collective/leave-management-system/blob/main/frontend/src/api/axiosConfig.js): `frontend/src/api/axiosConfig.js`

### Leave services

- [Express app](https://github.com/barabari-tech-collective/leave-management-system/blob/main/backend/app.js): `backend/app.js`
- [Authentication routes](https://github.com/barabari-tech-collective/leave-management-system/blob/main/backend/routes/authRoutes.js): `backend/routes/authRoutes.js`
- [Leave routes](https://github.com/barabari-tech-collective/leave-management-system/blob/main/backend/routes/leaveRoutes.js): `backend/routes/leaveRoutes.js`
- [Leave workflows](https://github.com/barabari-tech-collective/leave-management-system/blob/main/backend/controllers/leaveController.js): `backend/controllers/leaveController.js`
- [Session guard](https://github.com/barabari-tech-collective/leave-management-system/blob/main/backend/middleware/authMiddleware.js): `backend/middleware/authMiddleware.js`
- [Leave records](https://github.com/barabari-tech-collective/leave-management-system/blob/main/backend/models/Leave.js): `backend/models/Leave.js`

### People administration

- [User routes](https://github.com/barabari-tech-collective/leave-management-system/blob/main/backend/routes/userRoutes.js): `backend/routes/userRoutes.js`
- [User accounts and balances](https://github.com/barabari-tech-collective/leave-management-system/blob/main/backend/models/User.js): `backend/models/User.js`

### Email automation

- [Holiday scheduler](https://github.com/barabari-tech-collective/leave-management-system/blob/main/backend/cron/holidayCron.js): `backend/cron/holidayCron.js`
- [Notification service](https://github.com/barabari-tech-collective/leave-management-system/blob/main/backend/services/emailService.js): `backend/services/emailService.js`

### Other components

- **Employee**
- **Admin / Lead**
- **Resend email**

## Connections

- Employee → Role-based routing: uses portal
- Admin / Lead → Role-based routing: uses portal
- Role-based routing → Session context: guards routes (evidence: `frontend/src/routes/AppRoutes.jsx`)
- Session context → HTTP client: fetches session (evidence: `frontend/src/context/AuthContext.jsx`)
- Apply for leave → HTTP client: submits request
- Balance, history, policy → HTTP client: loads leave data
- Team review → HTTP client: loads team requests
- Admin overview → HTTP client: loads overview (evidence: `frontend/src/pages/admin/AdminDashboard.jsx`)
- Staff lifecycle views → HTTP client: manages staff
- HTTP client → Express app: HTTP requests
- Express app → Authentication routes: mounts /auth (evidence: `backend/app.js`)
- Express app → Leave routes: mounts /leave (evidence: `backend/app.js`)
- Express app → User routes: mounts /users (evidence: `backend/app.js`)
- Authentication routes → Session guard: guards provisioning (evidence: `backend/routes/authRoutes.js`)
- Leave routes → Session guard: guards endpoints (evidence: `backend/routes/leaveRoutes.js`)
- User routes → Session guard: guards endpoints (evidence: `backend/routes/userRoutes.js`)
- Leave routes → Leave workflows: dispatches workflows (evidence: `backend/routes/leaveRoutes.js`)
- Leave workflows → Leave records: creates and reads (evidence: `backend/controllers/leaveController.js`)
- Leave workflows → User accounts and balances: reads and updates (evidence: `backend/controllers/leaveController.js`)
- User routes → User accounts and balances: manages accounts (evidence: `backend/routes/userRoutes.js`)
- User routes → Leave records: migrates records (evidence: `backend/routes/userRoutes.js`)
- Authentication routes → User accounts and balances: authenticates and creates (evidence: `backend/routes/authRoutes.js`)
- Leave workflows → Notification service: sends leave notices (evidence: `backend/controllers/leaveController.js`)
- Authentication routes → Notification service: sends welcome email (evidence: `backend/routes/authRoutes.js`)
- Express app → Holiday scheduler: starts scheduler (evidence: `backend/app.js`)
- Holiday scheduler → User accounts and balances: finds recipients (evidence: `backend/cron/holidayCron.js`)
- Holiday scheduler → Notification service: sends holiday notice (evidence: `backend/cron/holidayCron.js`)
- Notification service → Resend email: dispatches email (evidence: `backend/services/emailService.js`)
