How parthi952/pvms works
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: MainLayout.tsx Main workspace shell · baseApi.ts Base API · Router.tsx Route map · authApi.ts Auth API
Components 20
Browser Runtime
- React bootstrap · Mounts providers and application.
src/main.tsx - App wrapper
src/App.tsx - Route map · Separates public and protected pages with fallback handling.
src/Router.tsx - Vite build & dev proxy · Builds static SPA and proxies development API requests.
vite.config.ts
Access & Workspace
- Login
src/Auth/Loginpage.tsx - Protected routes · Gates authenticated navigation and authorization.
src/components/ProtectedRoute.tsx - Main workspace shell · Shared navbar and sidebar around authenticated views.
src/Root/MainLayout.tsx - Role dashboards · Admin, employee, and reception-oriented dashboards.
src/pages/Dashbord/Admin.tsx
Operational Views
- Visitor lifecycle screens · Registration, list/detail management, and pending approvals.
src/pages/RegisterVisitor.tsx - Administration · User and employee management.
src/pages/Users.tsx - Reports & activity
src/pages/Reports.tsx - Reusable UI · Tables, filters, forms, and loading presentation.
src/components/DataTable.tsx - Theme context · Application-wide theme behavior.
src/Themes/ThemeContext.tsx
State & API
- Redux store · Provides Redux Toolkit and RTK Query state.
src/context/Api/store.ts - Auth state & permissions · Persists credentials and supports role decisions.
src/context/Api/authSlice.ts - Base API · Adds JSON behavior, bearer authorization, and shared tags.
src/context/Api/baseApi.ts - Auth API
src/context/Api/authApi.ts - Visitor API · Creates, updates, deletes, retrieves, and approves visitor records.
src/context/Api/visitorsApi.ts - Users API
src/context/Api/usersApi.ts
Other components
- HTTP backend · Separate backend reached through configured API base URL.
ApiLink.tsx
Connections 23
- 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