# vaibhavkamtekar/library-management-system architecture

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

- Interactive diagram: https://gitdiagram.com/vaibhavkamtekar/library-management-system
- Repository: https://github.com/vaibhavkamtekar/library-management-system

## Overview

#### Purpose and Deployment Shape
NMITD Library System is an on-premises visitor/attendance management application for students, staff, guests, and administrators. It ships as a React frontend plus Node.js backend, with Windows launchers, installer automation, MySQL setup/migration scripts, PM2 process management, and backup/restore operations.

Key operational artifacts: `Backend/server.js`, `pm2.config.js`, `installer/NMITD-Library-Setup.iss`, `LibrarySystem.vbs`.

#### Application Entry Points
The browser client starts at `frontend/src/index.js` and composes routing/UI in `frontend/src/App.js`. It is served separately or alongside the API depending on deployment setup.

The API service starts in `Backend/server.js`, initializes database connectivity through `Backend/db.js`, mounts domain route modules, and runs scheduled auto-exit behavior from `Backend/jobs/autoExitJob.js`.

#### Frontend Portal and Session UX
`frontend/src/App.js` is the top-level client coordinator. Shared portal framing and operational navigation are represented by `frontend/src/components/PortalShell.js` and `frontend/src/components/OperationalLayout.js`.

The application exposes distinct role/workflow screens:
- Public and walk-in flow: `frontend/src/components/Home.js`, `frontend/src/components/GuestEntry.js`
- Student/staff entry flow: `frontend/src/components/StudentEntry.js`, `frontend/src/components/StaffEntry.js`
- Active visit in/out operation: `frontend/src/components/InOut.js`
- Admin authentication and administration: `frontend/src/components/AdminLogin.js`, `frontend/src/components/AdminDashboard.js`

Client-to-server calls are centralized in `frontend/src/api.js`, forming the primary frontend/backend boundary.

#### Backend API Domains
The Express route layer separates business capabilities by actor and operation:
- Student operations: `Backend/routes/studentRoutes.js`
- Staff operations: `Backend/routes/staffRoutes.js`
- Guest and visit lifecycle operations: `Backend/routes/guestRoutes.js`, `Backend/routes/visitRoutes.js`
- Administrative controls and student maintenance: `Backend/routes/adminRoutes.js`, `Backend/routes/adminStudentRoutes.js`

`Backend/server.js` is the composition boundary for these HTTP domains; route handlers are expected to own request validation, authorization, and persistence-oriented workflow execution.

#### Visit Lifecycle and Automation
The central control flow is entry registration → active visit tracking → explicit exit or scheduled closure. Entry-facing React components submit requests through `frontend/src/api.js`; backend visit-oriented routes persist and retrieve state using `Backend/db.js`.

`Backend/jobs/autoExitJob.js` provides a server-side corrective path for visits that remain open, decoupled from a user actively operating the browser. This makes the backend—not the UI—the authority for final visit state.

#### Persistence and Database Operations
`Backend/db.js` is the application database access boundary. Database schema evolution is operationalized under `database/migrations`, with installation and upgrade orchestration in `installer/scripts/init-database.ps1` and `installer/scripts/migrate-database.ps1`.

The repository strongly indicates MySQL as the production datastore via `installer/scripts/detect-mysql.ps1`. Backup, restore, and pre-update protection are external operational flows: `scripts/backup.bat`, `scripts/restore.bat`, and `installer/scripts/pre-update-backup.bat`.

#### Packaging, Runtime, and Infrastructure
The runtime stack is Node.js/Express for the API (`Backend/package.json`) and React for the client (`frontend/package.json`). PM2 manages the deployed server process through `pm2.config.js`.

Windows is the primary deployment target: the Inno Setup definition `installer/NMITD-Library-Setup.iss` packages the system; service lifecycle scripts include `installer/scripts/install-service.bat` and `installer/scripts/uninstall-service.bat`. Local-user launch behavior is supported by `LaunchBrowser.vbs` and `LibrarySystem.vbs`.

Main entry points: [`Backend/server.js`](https://github.com/vaibhavkamtekar/library-management-system/blob/main/Backend/server.js) (Express server), [`Backend/db.js`](https://github.com/vaibhavkamtekar/library-management-system/blob/main/Backend/db.js) (Database access), [`frontend/src/components/OperationalLayout.js`](https://github.com/vaibhavkamtekar/library-management-system/blob/main/frontend/src/components/OperationalLayout.js) (Operational layout), [`frontend/src/api.js`](https://github.com/vaibhavkamtekar/library-management-system/blob/main/frontend/src/api.js) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React Client"]
  node_client_entry["Client entry<br/>React bootstrap<br/>[index.js]"]
  node_app["App routing<br/>React coordinator<br/>[App.js]"]
  node_portal["Portal shell<br/>shared UI<br/>[PortalShell.js]"]
  node_operations_ui["Operational layout<br/>shared UI"]
  node_entry_screens["Entry screens<br/>visitor workflows<br/>[GuestEntry.js]"]
  node_visit_ui["In/out screen<br/>visit workflow<br/>[InOut.js]"]
  node_admin_ui["Admin screens<br/>admin workflow<br/>[AdminDashboard.js]"]
  node_api_client["API client<br/>HTTP boundary<br/>[api.js]"]
end

subgraph group_api["Node.js API"]
  node_server{{"Express server<br/>API composition<br/>[server.js]"}}
  node_actor_routes["Actor routes<br/>HTTP domains<br/>[studentRoutes.js]"]
  node_visit_routes["Visit routes<br/>visit lifecycle<br/>[visitRoutes.js]"]
  node_auto_exit["Auto-exit job<br/>scheduled closure<br/>[autoExitJob.js]"]
end

subgraph group_data["Data Operations"]
  node_db_access[("Database access<br/>MySQL boundary<br/>[db.js]")]
  node_migrations["Schema migrations<br/>database evolution"]
  node_db_setup["Database setup<br/>installer scripts<br/>[init-database.ps1]"]
  node_backup_restore["Backup and restore<br/>data protection<br/>[backup.bat]"]
end

subgraph group_deployment["Windows Deployment"]
  node_pm2["PM2 process manager<br/>runtime management<br/>[pm2.config.js]"]
  node_installer["Inno Setup installer<br/>Windows packaging"]
  node_launchers["Windows launchers<br/>local launch<br/>[LibrarySystem.vbs]"]
end

node_client_entry --> node_app
node_app --> node_portal
node_portal --> node_operations_ui
node_operations_ui --> node_entry_screens
node_operations_ui --> node_visit_ui
node_operations_ui --> node_admin_ui
node_entry_screens -->|"register entry"| node_api_client
node_visit_ui -->|"view / exit visit"| node_api_client
node_admin_ui -->|"admin requests"| node_api_client
node_api_client -->|"HTTP"| node_server
node_server -->|"mounts"| node_actor_routes
node_server -->|"mounts"| node_visit_routes
node_server -->|"schedules"| node_auto_exit
node_actor_routes -->|"persist workflows"| node_db_access
node_visit_routes -->|"active visit state"| node_db_access
node_auto_exit -->|"close open visits"| node_db_access
node_db_setup -->|"applies"| node_migrations
node_migrations -->|"evolves schema"| node_db_access
node_backup_restore -.->|"protects data"| node_db_access
node_pm2 -->|"manages"| node_server
node_installer -->|"deploys runtime"| node_pm2
node_installer -->|"provisions database"| node_db_setup
node_launchers -.->|"opens local system"| node_server

click node_client_entry "https://github.com/vaibhavkamtekar/library-management-system/blob/main/frontend/src/index.js"
click node_app "https://github.com/vaibhavkamtekar/library-management-system/blob/main/frontend/src/App.js"
click node_portal "https://github.com/vaibhavkamtekar/library-management-system/blob/main/frontend/src/components/PortalShell.js"
click node_operations_ui "https://github.com/vaibhavkamtekar/library-management-system/blob/main/frontend/src/components/OperationalLayout.js"
click node_entry_screens "https://github.com/vaibhavkamtekar/library-management-system/blob/main/frontend/src/components/GuestEntry.js"
click node_visit_ui "https://github.com/vaibhavkamtekar/library-management-system/blob/main/frontend/src/components/InOut.js"
click node_admin_ui "https://github.com/vaibhavkamtekar/library-management-system/blob/main/frontend/src/components/AdminDashboard.js"
click node_api_client "https://github.com/vaibhavkamtekar/library-management-system/blob/main/frontend/src/api.js"
click node_server "https://github.com/vaibhavkamtekar/library-management-system/blob/main/Backend/server.js"
click node_actor_routes "https://github.com/vaibhavkamtekar/library-management-system/blob/main/Backend/routes/studentRoutes.js"
click node_visit_routes "https://github.com/vaibhavkamtekar/library-management-system/blob/main/Backend/routes/visitRoutes.js"
click node_auto_exit "https://github.com/vaibhavkamtekar/library-management-system/blob/main/Backend/jobs/autoExitJob.js"
click node_db_access "https://github.com/vaibhavkamtekar/library-management-system/blob/main/Backend/db.js"
click node_migrations "https://github.com/vaibhavkamtekar/library-management-system/tree/main/database/migrations"
click node_db_setup "https://github.com/vaibhavkamtekar/library-management-system/blob/main/installer/scripts/init-database.ps1"
click node_backup_restore "https://github.com/vaibhavkamtekar/library-management-system/blob/main/scripts/backup.bat"
click node_pm2 "https://github.com/vaibhavkamtekar/library-management-system/blob/main/pm2.config.js"
click node_installer "https://github.com/vaibhavkamtekar/library-management-system/blob/main/installer/NMITD-Library-Setup.iss"
click node_launchers "https://github.com/vaibhavkamtekar/library-management-system/blob/main/LibrarySystem.vbs"

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_client_entry,node_app,node_portal,node_operations_ui,node_entry_screens,node_visit_ui,node_admin_ui,node_api_client toneBlue
class node_server,node_actor_routes,node_visit_routes,node_auto_exit toneAmber
class node_db_access,node_migrations,node_db_setup,node_backup_restore toneMint
class node_pm2,node_installer,node_launchers toneRose
```

## Components

### React Client

- [Client entry](https://github.com/vaibhavkamtekar/library-management-system/blob/main/frontend/src/index.js): React bootstrap · `frontend/src/index.js`
- [App routing](https://github.com/vaibhavkamtekar/library-management-system/blob/main/frontend/src/App.js): React coordinator · `frontend/src/App.js`
- [Portal shell](https://github.com/vaibhavkamtekar/library-management-system/blob/main/frontend/src/components/PortalShell.js): shared UI · `frontend/src/components/PortalShell.js`
- [Operational layout](https://github.com/vaibhavkamtekar/library-management-system/blob/main/frontend/src/components/OperationalLayout.js): shared UI · `frontend/src/components/OperationalLayout.js`
- [Entry screens](https://github.com/vaibhavkamtekar/library-management-system/blob/main/frontend/src/components/GuestEntry.js): visitor workflows · Home, guest, student, and staff entry screens. · `frontend/src/components/GuestEntry.js`
- [In/out screen](https://github.com/vaibhavkamtekar/library-management-system/blob/main/frontend/src/components/InOut.js): visit workflow · `frontend/src/components/InOut.js`
- [Admin screens](https://github.com/vaibhavkamtekar/library-management-system/blob/main/frontend/src/components/AdminDashboard.js): admin workflow · Login and dashboard administration. · `frontend/src/components/AdminDashboard.js`
- [API client](https://github.com/vaibhavkamtekar/library-management-system/blob/main/frontend/src/api.js): HTTP boundary · `frontend/src/api.js`

### Node.js API

- [Express server](https://github.com/vaibhavkamtekar/library-management-system/blob/main/Backend/server.js): API composition · `Backend/server.js`
- [Actor routes](https://github.com/vaibhavkamtekar/library-management-system/blob/main/Backend/routes/studentRoutes.js): HTTP domains · Student, staff, guest, and admin operations. · `Backend/routes/studentRoutes.js`
- [Visit routes](https://github.com/vaibhavkamtekar/library-management-system/blob/main/Backend/routes/visitRoutes.js): visit lifecycle · `Backend/routes/visitRoutes.js`
- [Auto-exit job](https://github.com/vaibhavkamtekar/library-management-system/blob/main/Backend/jobs/autoExitJob.js): scheduled closure · Closes visits left active without browser action. · `Backend/jobs/autoExitJob.js`

### Data Operations

- [Database access](https://github.com/vaibhavkamtekar/library-management-system/blob/main/Backend/db.js): MySQL boundary · `Backend/db.js`
- [Schema migrations](https://github.com/vaibhavkamtekar/library-management-system/tree/main/database/migrations): database evolution · `database/migrations`
- [Database setup](https://github.com/vaibhavkamtekar/library-management-system/blob/main/installer/scripts/init-database.ps1): installer scripts · Initialization and migration orchestration. · `installer/scripts/init-database.ps1`
- [Backup and restore](https://github.com/vaibhavkamtekar/library-management-system/blob/main/scripts/backup.bat): data protection · `scripts/backup.bat`

### Windows Deployment

- [PM2 process manager](https://github.com/vaibhavkamtekar/library-management-system/blob/main/pm2.config.js): runtime management · `pm2.config.js`
- [Inno Setup installer](https://github.com/vaibhavkamtekar/library-management-system/blob/main/installer/NMITD-Library-Setup.iss): Windows packaging · `installer/NMITD-Library-Setup.iss`
- [Windows launchers](https://github.com/vaibhavkamtekar/library-management-system/blob/main/LibrarySystem.vbs): local launch · `LibrarySystem.vbs`

## Connections

- Client entry → App routing
- App routing → Portal shell
- Portal shell → Operational layout
- Operational layout → Entry screens
- Operational layout → In/out screen
- Operational layout → Admin screens
- Entry screens → API client: register entry
- In/out screen → API client: view / exit visit
- Admin screens → API client: admin requests
- API client → Express server: HTTP
- Express server → Actor routes: mounts
- Express server → Visit routes: mounts
- Express server → Auto-exit job: schedules
- Actor routes → Database access: persist workflows
- Visit routes → Database access: active visit state
- Auto-exit job → Database access: close open visits
- Database setup → Schema migrations: applies
- Schema migrations → Database access: evolves schema
- Backup and restore → Database access: protects data
- PM2 process manager → Express server: manages
- Inno Setup installer → PM2 process manager: deploys runtime
- Inno Setup installer → Database setup: provisions database
- Windows launchers → Express server: opens local system
