# parthi952/pvms architecture

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

- Interactive diagram: https://gitdiagram.com/parthi952/pvms
- Repository: https://github.com/parthi952/pvms

## Overview

#### Purpose and Runtime
VPMS is a React single-page frontend for visitor registration, approval/status workflows, visitor records, reporting/activity views, and role-based user administration. It runs in the browser, is built by Vite, and consumes a separate HTTP backend; production deployment is static hosting with SPA fallback. Key entry points: `src/main.tsx`, `src/App.tsx`, `src/Router.tsx`.

#### Application Bootstrap and Routing
`main.tsx` mounts the React application and provides Redux state and routing. `Router.tsx` centrally maps application pages, including login, protected application views, access-denied, not-found, and an error boundary. `App.tsx` is the top-level application wrapper. Routes separate public authentication from authenticated operational screens.
Paths: `src/main.tsx`, `src/Router.tsx`, `src/App.tsx`.

#### Authentication and Authorization Boundary
Login is implemented as an API mutation; successful credentials are persisted in Redux and browser `localStorage`. The base API attaches the bearer token to subsequent requests. Protected route handling gates authenticated navigation, while permissions support role-based access decisions and dashboard variants.
Paths: `src/Auth/Loginpage.tsx`, `src/components/ProtectedRoute.tsx`, `src/context/Api/authSlice.ts`, `src/context/Api/permissions.ts`.

#### Shell, Navigation, and Role-Oriented Workspace
Authenticated pages render within a shared application shell with top navigation and sidebar. This shell is the navigation/control boundary around dashboards and operational pages. Dashboard content has admin, employee, and reception variants, reflecting the role-based model.
Paths: `src/Root/MainLayout.tsx`, `src/Root/Navbar.tsx`, `src/Root/Sidebar.tsx`, `src/pages/Dashbord/Admin.tsx`.

#### Visitor Lifecycle Features
Visitor operations are represented by route-level screens: registration creates records; list/detail screens retrieve and manage records; pending requests expose approval workflow. API mutations cover create, status updates, full detail updates, and deletion. Shared filtering, tables, date/time controls, and validation support these workflows.
Paths: `src/pages/RegisterVisitor.tsx`, `src/pages/VisitorList.tsx`, `src/pages/VisitorDetails.tsx`, `src/pages/PendingRequests.tsx`, `src/context/Api/visitorsApi.ts`.

#### State, API Integration, and External Backend
Redux Toolkit provides client state; RTK Query owns request lifecycle, caching, and tag invalidation. `baseApi.ts` establishes JSON HTTP behavior, authorization headers, and common tags; feature services inject auth, user, and visitor endpoints. The backend base URL is centrally configured and can be overridden through Vite environment variables; development proxies `/api` to a local backend.
Paths: `src/context/Api/store.ts`, `src/context/Api/baseApi.ts`, `src/context/Api/authApi.ts`, `src/context/Api/usersApi.ts`, `ApiLink.tsx`, `vite.config.ts`.

#### Administration, Reporting, and Presentation System
User administration, employee management, reports, and activity logs are separate route views backed by the same authenticated API/state boundary. Reusable UI components provide tables, search, filters, forms, and loading behavior. Theme context and component theme definitions provide application-wide visual state and styling behavior, with Tailwind CSS as the styling runtime.
Paths: `src/pages/Users.tsx`, `src/pages/Employees.tsx`, `src/pages/Reports.tsx`, `src/pages/ActivityLogs.tsx`, `src/components/DataTable.tsx`, `src/Themes/ThemeContext.tsx`.

Main entry points: [`src/Root/MainLayout.tsx`](https://github.com/parthi952/pvms/blob/main/src/Root/MainLayout.tsx) (Main workspace shell), [`src/context/Api/baseApi.ts`](https://github.com/parthi952/pvms/blob/main/src/context/Api/baseApi.ts) (Base API), [`src/Router.tsx`](https://github.com/parthi952/pvms/blob/main/src/Router.tsx) (Route map), [`src/context/Api/authApi.ts`](https://github.com/parthi952/pvms/blob/main/src/context/Api/authApi.ts) (Auth API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Browser Runtime"]
  node_main["React bootstrap<br/>entry point<br/>[main.tsx]"]
  node_app["App wrapper<br/>root component<br/>[App.tsx]"]
  node_router["Route map<br/>routing<br/>[Router.tsx]"]
  node_vite["Vite build &amp; dev proxy<br/>build runtime<br/>[vite.config.ts]"]
end

subgraph group_access["Access &amp; Workspace"]
  node_login["Login<br/>public screen<br/>[Loginpage.tsx]"]
  node_protected["Protected routes<br/>auth guard<br/>[ProtectedRoute.tsx]"]
  node_shell["Main workspace shell<br/>layout<br/>[MainLayout.tsx]"]
  node_dashboard["Role dashboards<br/>workspace view<br/>[Admin.tsx]"]
end

subgraph group_features["Operational Views"]
  node_visitor_screens["Visitor lifecycle screens<br/>route views"]
  node_administration["Administration<br/>route views<br/>[Users.tsx]"]
  node_reporting["Reports &amp; activity<br/>route views<br/>[Reports.tsx]"]
  node_ui["Reusable UI<br/>component system<br/>[DataTable.tsx]"]
  node_theme["Theme context<br/>visual state<br/>[ThemeContext.tsx]"]
end

subgraph group_data["State &amp; API"]
  node_store[("Redux store<br/>client state<br/>[store.ts]")]
  node_auth_state["Auth state &amp; permissions<br/>authorization state<br/>[authSlice.ts]"]
  node_base_api["Base API<br/>RTK Query transport<br/>[baseApi.ts]"]
  node_auth_api["Auth API<br/>endpoint service<br/>[authApi.ts]"]
  node_visitor_api["Visitor API<br/>endpoint service<br/>[visitorsApi.ts]"]
  node_users_api["Users API<br/>endpoint service<br/>[usersApi.ts]"]
end

node_backend{{"HTTP backend<br/>external service<br/>[ApiLink.tsx]"}}

node_main -->|"provides"| node_store
node_main -->|"mounts"| node_app
node_app -->|"renders"| node_router
node_router -->|"public route"| node_login
node_router -->|"protected routes"| node_protected
node_protected -->|"allows authenticated access"| node_shell
node_shell -->|"hosts"| node_dashboard
node_shell -->|"hosts"| node_visitor_screens
node_shell -->|"hosts"| node_administration
node_shell -->|"hosts"| node_reporting
node_login -->|"authenticates"| node_auth_api
node_auth_api -->|"stores credentials"| node_auth_state
node_auth_state -->|"supplies identity"| node_protected
node_store -->|"registers query state"| node_base_api
node_auth_api -->|"injects endpoints"| node_base_api
node_visitor_api -->|"injects endpoints"| node_base_api
node_users_api -->|"injects endpoints"| node_base_api
node_visitor_screens -->|"queries and mutates"| node_visitor_api
node_administration -->|"queries and mutates"| node_users_api
node_base_api -->|"authenticated HTTP"| node_backend
node_vite -.->|"development /api proxy"| node_backend
node_ui -->|"supports"| node_visitor_screens
node_theme -->|"styles"| node_app

click node_main "https://github.com/parthi952/pvms/blob/main/src/main.tsx"
click node_app "https://github.com/parthi952/pvms/blob/main/src/App.tsx"
click node_router "https://github.com/parthi952/pvms/blob/main/src/Router.tsx"
click node_login "https://github.com/parthi952/pvms/blob/main/src/Auth/Loginpage.tsx"
click node_protected "https://github.com/parthi952/pvms/blob/main/src/components/ProtectedRoute.tsx"
click node_shell "https://github.com/parthi952/pvms/blob/main/src/Root/MainLayout.tsx"
click node_dashboard "https://github.com/parthi952/pvms/blob/main/src/pages/Dashbord/Admin.tsx"
click node_visitor_screens "https://github.com/parthi952/pvms/blob/main/src/pages/RegisterVisitor.tsx"
click node_administration "https://github.com/parthi952/pvms/blob/main/src/pages/Users.tsx"
click node_reporting "https://github.com/parthi952/pvms/blob/main/src/pages/Reports.tsx"
click node_ui "https://github.com/parthi952/pvms/blob/main/src/components/DataTable.tsx"
click node_theme "https://github.com/parthi952/pvms/blob/main/src/Themes/ThemeContext.tsx"
click node_store "https://github.com/parthi952/pvms/blob/main/src/context/Api/store.ts"
click node_auth_state "https://github.com/parthi952/pvms/blob/main/src/context/Api/authSlice.ts"
click node_base_api "https://github.com/parthi952/pvms/blob/main/src/context/Api/baseApi.ts"
click node_auth_api "https://github.com/parthi952/pvms/blob/main/src/context/Api/authApi.ts"
click node_visitor_api "https://github.com/parthi952/pvms/blob/main/src/context/Api/visitorsApi.ts"
click node_users_api "https://github.com/parthi952/pvms/blob/main/src/context/Api/usersApi.ts"
click node_backend "https://github.com/parthi952/pvms/blob/main/ApiLink.tsx"
click node_vite "https://github.com/parthi952/pvms/blob/main/vite.config.ts"

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_main,node_app,node_router,node_vite toneBlue
class node_login,node_protected,node_shell,node_dashboard toneAmber
class node_visitor_screens,node_administration,node_reporting,node_ui,node_theme toneMint
class node_store,node_auth_state,node_base_api,node_auth_api,node_visitor_api,node_users_api toneRose
class node_backend toneNeutral
```

## Components

### Browser Runtime

- [React bootstrap](https://github.com/parthi952/pvms/blob/main/src/main.tsx): entry point · Mounts providers and application. · `src/main.tsx`
- [App wrapper](https://github.com/parthi952/pvms/blob/main/src/App.tsx): root component · `src/App.tsx`
- [Route map](https://github.com/parthi952/pvms/blob/main/src/Router.tsx): routing · Separates public and protected pages with fallback handling. · `src/Router.tsx`
- [Vite build & dev proxy](https://github.com/parthi952/pvms/blob/main/vite.config.ts): build runtime · Builds static SPA and proxies development API requests. · `vite.config.ts`

### Access & Workspace

- [Login](https://github.com/parthi952/pvms/blob/main/src/Auth/Loginpage.tsx): public screen · `src/Auth/Loginpage.tsx`
- [Protected routes](https://github.com/parthi952/pvms/blob/main/src/components/ProtectedRoute.tsx): auth guard · Gates authenticated navigation and authorization. · `src/components/ProtectedRoute.tsx`
- [Main workspace shell](https://github.com/parthi952/pvms/blob/main/src/Root/MainLayout.tsx): layout · Shared navbar and sidebar around authenticated views. · `src/Root/MainLayout.tsx`
- [Role dashboards](https://github.com/parthi952/pvms/blob/main/src/pages/Dashbord/Admin.tsx): workspace view · Admin, employee, and reception-oriented dashboards. · `src/pages/Dashbord/Admin.tsx`

### Operational Views

- [Visitor lifecycle screens](https://github.com/parthi952/pvms/blob/main/src/pages/RegisterVisitor.tsx): route views · Registration, list/detail management, and pending approvals. · `src/pages/RegisterVisitor.tsx`
- [Administration](https://github.com/parthi952/pvms/blob/main/src/pages/Users.tsx): route views · User and employee management. · `src/pages/Users.tsx`
- [Reports & activity](https://github.com/parthi952/pvms/blob/main/src/pages/Reports.tsx): route views · `src/pages/Reports.tsx`
- [Reusable UI](https://github.com/parthi952/pvms/blob/main/src/components/DataTable.tsx): component system · Tables, filters, forms, and loading presentation. · `src/components/DataTable.tsx`
- [Theme context](https://github.com/parthi952/pvms/blob/main/src/Themes/ThemeContext.tsx): visual state · Application-wide theme behavior. · `src/Themes/ThemeContext.tsx`

### State & API

- [Redux store](https://github.com/parthi952/pvms/blob/main/src/context/Api/store.ts): client state · Provides Redux Toolkit and RTK Query state. · `src/context/Api/store.ts`
- [Auth state & permissions](https://github.com/parthi952/pvms/blob/main/src/context/Api/authSlice.ts): authorization state · Persists credentials and supports role decisions. · `src/context/Api/authSlice.ts`
- [Base API](https://github.com/parthi952/pvms/blob/main/src/context/Api/baseApi.ts): RTK Query transport · Adds JSON behavior, bearer authorization, and shared tags. · `src/context/Api/baseApi.ts`
- [Auth API](https://github.com/parthi952/pvms/blob/main/src/context/Api/authApi.ts): endpoint service · `src/context/Api/authApi.ts`
- [Visitor API](https://github.com/parthi952/pvms/blob/main/src/context/Api/visitorsApi.ts): endpoint service · Creates, updates, deletes, retrieves, and approves visitor records. · `src/context/Api/visitorsApi.ts`
- [Users API](https://github.com/parthi952/pvms/blob/main/src/context/Api/usersApi.ts): endpoint service · `src/context/Api/usersApi.ts`

### Other components

- [HTTP backend](https://github.com/parthi952/pvms/blob/main/ApiLink.tsx): external service · Separate backend reached through configured API base URL. · `ApiLink.tsx`

## Connections

- React bootstrap → Redux store: provides
- React bootstrap → App wrapper: mounts
- App wrapper → Route map: renders
- Route map → Login: public route
- Route map → Protected routes: protected routes
- Protected routes → Main workspace shell: allows authenticated access
- Main workspace shell → Role dashboards: hosts
- Main workspace shell → Visitor lifecycle screens: hosts
- Main workspace shell → Administration: hosts
- Main workspace shell → Reports & activity: hosts
- Login → Auth API: authenticates
- Auth API → Auth state & permissions: stores credentials
- Auth state & permissions → Protected routes: supplies identity
- Redux store → Base API: registers query state
- Auth API → Base API: injects endpoints
- Visitor API → Base API: injects endpoints
- Users API → Base API: injects endpoints
- Visitor lifecycle screens → Visitor API: queries and mutates
- Administration → Users API: queries and mutates
- Base API → HTTP backend: authenticated HTTP
- Vite build & dev proxy → HTTP backend: development /api proxy
- Reusable UI → Visitor lifecycle screens: supports
- Theme context → App wrapper: styles
