# tanishkokane2006-afk/smartpark_sytem_for_pune architecture

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

- Interactive diagram: https://gitdiagram.com/tanishkokane2006-afk/smartpark_sytem_for_pune
- Repository: https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune

## Overview

1. **Repository shape**
   - SmartPark is a two-tier monorepo: a **React/Vite frontend** in `client/` and a **Node/Express backend** in `server/`.
   - The backend owns persistence, business rules, authentication, payments, and notifications; the frontend owns role-specific UX and API orchestration.

2. **Primary user-facing domains**
   - The product is organized around three roles: **Driver**, **Owner**, and **Admin**.
   - These roles map to separate dashboards and workflows, with shared authentication and role-based route protection.

3. **Frontend application shell**
   - `client/src/app/` defines the top-level layout and navigation structure, including role workspace layout and route navigation.
   - `client/src/routes/` contains routing guards and redirect logic, so access control is enforced before users reach role pages.

4. **Feature-based frontend architecture**
   - The client is split by business capability under `client/src/features/` rather than by technical layer.
   - Major feature groups include **auth**, **bookings**, **parkings**, **map**, **reviews**, **profile**, **notifications**, **admin**, **owner**, **analytics**, **theme**, and **account**.
   - Each feature typically bundles UI, helper logic, and API access together, which keeps each domain diagrammed as a self-contained subsystem.

5. **Frontend data flow**
   - UI pages under `client/src/pages/` assemble feature components into screens such as home, dashboard, map, profile, and role-specific dashboards.
   - Shared API communication is centralized in `client/src/lib/apiClient.js` and `client/src/services/api.js`, with socket support in `client/src/services/socket.js`.
   - A `useDataSync` hook indicates that some UI state is synchronized with server-side events, not just fetched on page load.

6. **Backend request pipeline**
   - `server/src/app.js` and `server/src/server.js` bootstrap the Express app, connect config, middleware, routes, and sockets.
   - Requests flow through middleware for auth, authorization, validation, rate limiting, error handling, and database availability before reaching controllers.

7. **Backend layered domain model**
   - The backend is organized into **routes → controllers → services → models**.
   - Controllers handle HTTP concerns, services implement business logic, models define MongoDB data structures, and validators/middleware enforce input and access rules.
   - This separation is important for the architecture diagram because the business rules are concentrated in services, not controllers.

8. **Core business subsystems**
   - **Parking management** handles listing creation, updates, moderation, search, and discovery.
   - **Booking management** handles reservation lifecycle, slot availability, completion/cancellation, and booking verification.
   - **Payments** integrate with Razorpay and synchronize payment state with booking state.
   - **Reviews**, **notifications**, **analytics**, and **admin/owner dashboards** are additional domain subsystems built on top of bookings and parking data.

9. **Reservation and availability logic**
   - Slot availability is not a simple inventory count; it is reservation-aware and depends on booking status.
   - The backend contains dedicated utilities and services for booking validation, code generation, occupancy, slot calculation, and booking lifecycle consistency.
   - This logic is central to the system boundary because it prevents overbooking and drives the owner/admin metrics.

10. **Real-time and event-driven behavior**
    - The platform includes an in-app notification system and socket configuration on the backend, so some events can propagate beyond a simple REST response.
    - Notifications are generated for booking, cancellation, completion, and owner/admin events, which means the system has both synchronous API flow and asynchronous event-style updates.

11. **External integrations**
    - **MongoDB/Mongoose** is the primary persistence layer.
    - **Razorpay** is the external payment gateway, and payment verification is part of the booking flow.
    - **Cloudinary** is configured on the backend, indicating image upload/storage for parking listings.

12. **Cross-cutting security and validation**
    - Authentication is JWT-based, with role-based access control for driver/owner/admin boundaries.
    - Input validation is explicit in `validators/`, while reusable validation and formatting utilities cover email, phone, booking state, and error messaging.
    - Rate limiting, optional authentication, and file upload protection are part of the security boundary.

13. **Observability, analytics, and reporting**
    - Both owner and admin views depend on analytics services and endpoints, so reporting is a first-class backend concern.
    - Analytics cover occupancy, revenue, bookings, and platform oversight rather than being a purely frontend calculation.

14. **Testing and domain safeguards**
    - The repository has meaningful tests around booking validation, code generation, auth/authorization, occupancy, search, routes, and end-to-end flows.
    - The presence of these tests suggests the most important architectural risk areas are state transitions, permissions, and payment/booking consistency.

15. **Operational tooling and scripts**
    - The backend includes seed and migration scripts for parking data and booking code maintenance, which implies operational workflows beyond runtime API handling.
    - Documentation under `docs/` captures the business contracts and lifecycle rules, and is useful as an architecture companion for understanding the data and booking model.

Main entry points: [`server/src/routes/booking.routes.js`](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/routes/booking.routes.js) (API Routes), [`client/src/app/AppLayout.jsx`](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/client/src/app/AppLayout.jsx) (App Shell), [`server/src/services/booking.service.js`](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/services/booking.service.js) (Booking Service), [`server/src/services/parking.service.js`](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/services/parking.service.js) (Parking Service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Frontend"]
  node_client_app["App Shell<br/>layout/navigation<br/>[AppLayout.jsx]"]
  node_client_routes["Route Guards<br/>routing/access<br/>[ProtectedRoute.jsx]"]
  node_client_auth["Auth<br/>identity/ui<br/>[AuthProvider.jsx]"]
  node_client_bookings["Bookings<br/>reservation/ui<br/>[BookingModal.jsx]"]
  node_client_parkings["Parkings<br/>discovery/owner-ui"]
  node_client_map["Map<br/>geo/discovery<br/>[MapView.jsx]"]
  node_client_profile["Profile<br/>account/ui"]
  node_client_notifications["Notifications<br/>events/ui"]
  node_client_admin["Admin UX<br/>admin/dashboard"]
  node_client_owner["Owner UX<br/>owner/dashboard"]
  node_client_data["API Sync<br/>client/data<br/>[apiClient.js]"]
end

subgraph group_server["Backend"]
  node_server_app["Server Bootstrap<br/>express/bootstrap<br/>[app.js]"]
  node_server_mw["Middleware<br/>security/pipeline<br/>[authenticate.js]"]
  node_server_routes["API Routes<br/>http/routing<br/>[booking.routes.js]"]
  node_server_auth["Auth Service<br/>identity/service<br/>[auth.service.js]"]
  node_server_parking["Parking Service<br/>listing/service<br/>[parking.service.js]"]
  node_server_booking["Booking Service<br/>reservation/service<br/>[booking.service.js]"]
  node_server_occupancy["Availability<br/>slot/occupancy"]
  node_server_payment["Payments<br/>gateway/service<br/>[payment.service.js]"]
  node_server_review["Reviews<br/>feedback/service<br/>[review.service.js]"]
  node_server_notify["Notifications<br/>events/service"]
  node_server_analytics["Analytics<br/>reporting/service"]
end

node_client_app -->|"renders via"| node_client_routes
node_client_routes -->|"gates"| node_client_auth
node_client_app -->|"hosts"| node_client_bookings
node_client_app -->|"hosts"| node_client_parkings
node_client_app -->|"hosts"| node_client_map
node_client_app -->|"hosts"| node_client_profile
node_client_app -->|"hosts"| node_client_notifications
node_client_app -->|"specializes"| node_client_admin
node_client_app -->|"specializes"| node_client_owner
node_client_data -->|"calls"| node_server_routes
node_server_app -->|"applies"| node_server_mw
node_server_app -->|"mounts"| node_server_routes
node_server_routes -->|"delegates"| node_server_auth
node_server_routes -->|"delegates"| node_server_parking
node_server_routes -->|"delegates"| node_server_booking
node_server_routes -->|"delegates"| node_server_payment
node_server_routes -->|"delegates"| node_server_review
node_server_routes -->|"delegates"| node_server_notify
node_server_routes -->|"delegates"| node_server_analytics
node_server_booking -->|"depends on"| node_server_occupancy
node_server_booking -->|"syncs with"| node_server_payment
node_server_booking -->|"emits"| node_server_notify
node_server_parking -->|"uses"| node_server_occupancy
node_server_review -->|"references"| node_server_parking
node_server_analytics -->|"aggregates"| node_server_booking
node_server_analytics -->|"aggregates"| node_server_parking
node_server_notify -.->|"reacts to"| node_server_booking

click node_client_app "https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/client/src/app/AppLayout.jsx"
click node_client_routes "https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/client/src/routes/ProtectedRoute.jsx"
click node_client_auth "https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/client/src/features/auth/AuthProvider.jsx"
click node_client_bookings "https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/client/src/features/bookings/BookingModal.jsx"
click node_client_parkings "https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/client/src/features/parkings/ParkingListPage.jsx"
click node_client_map "https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/client/src/features/map/MapView.jsx"
click node_client_profile "https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/client/src/features/profile/AccountSettingsPanel.jsx"
click node_client_notifications "https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/client/src/features/notifications/NotificationBell.jsx"
click node_client_admin "https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/client/src/features/admin/AdminDashboardPage.jsx"
click node_client_owner "https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/client/src/features/owner/OwnerParkingDetail.jsx"
click node_client_data "https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/client/src/lib/apiClient.js"
click node_server_app "https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/app.js"
click node_server_mw "https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/middleware/authenticate.js"
click node_server_routes "https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/routes/booking.routes.js"
click node_server_auth "https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/services/auth.service.js"
click node_server_parking "https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/services/parking.service.js"
click node_server_booking "https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/services/booking.service.js"
click node_server_occupancy "https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/services/occupancy.service.js"
click node_server_payment "https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/services/payment.service.js"
click node_server_review "https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/services/review.service.js"
click node_server_notify "https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/services/notification.service.js"
click node_server_analytics "https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/services/analytics.service.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_client_app,node_client_routes,node_client_auth,node_client_bookings,node_client_parkings,node_client_map,node_client_profile,node_client_notifications,node_client_admin,node_client_owner,node_client_data toneBlue
class node_server_app,node_server_mw,node_server_routes,node_server_auth,node_server_parking,node_server_booking,node_server_occupancy,node_server_payment,node_server_review,node_server_notify,node_server_analytics toneAmber
```

## Components

### Frontend

React/Vite application with role-based UX and feature modules.

- [App Shell](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/client/src/app/AppLayout.jsx): layout/navigation · Top-level client layout, workspace framing, and navigation composition. · `client/src/app/AppLayout.jsx`
- [Route Guards](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/client/src/routes/ProtectedRoute.jsx): routing/access · Redirects and protection for authenticated and role-based access. · `client/src/routes/ProtectedRoute.jsx`
- [Auth](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/client/src/features/auth/AuthProvider.jsx): identity/ui · Login, register, auth context, and validation for session handling. · `client/src/features/auth/AuthProvider.jsx`
- [Bookings](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/client/src/features/bookings/BookingModal.jsx): reservation/ui · Booking modals, booking pages, and client-side booking intent helpers. · `client/src/features/bookings/BookingModal.jsx`
- [Parkings](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/client/src/features/parkings/ParkingListPage.jsx): discovery/owner-ui · Parking search, listing, forms, detail views, and upload workflows. · `client/src/features/parkings/ParkingListPage.jsx`
- [Map](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/client/src/features/map/MapView.jsx): geo/discovery · Map view, markers, landmarks, and nearby/recommendation panels. · `client/src/features/map/MapView.jsx`
- [Profile](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/client/src/features/profile/AccountSettingsPanel.jsx): account/ui · Account settings, phone display, and profile-related utilities. · `client/src/features/profile/AccountSettingsPanel.jsx`
- [Notifications](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/client/src/features/notifications/NotificationBell.jsx): events/ui · Notification bell, notifications page, and client notification service. · `client/src/features/notifications/NotificationBell.jsx`
- [Admin UX](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/client/src/features/admin/AdminDashboardPage.jsx): admin/dashboard · Admin dashboard and admin-facing API orchestration. · `client/src/features/admin/AdminDashboardPage.jsx`
- [Owner UX](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/client/src/features/owner/OwnerParkingDetail.jsx): owner/dashboard · Owner parking detail and owner-focused API orchestration. · `client/src/features/owner/OwnerParkingDetail.jsx`
- [API Sync](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/client/src/lib/apiClient.js): client/data · Shared API client, socket transport, and data synchronization hook. · `client/src/lib/apiClient.js`

### Backend

Express API with layered domain logic, persistence, and integrations.

- [Server Bootstrap](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/app.js): express/bootstrap · Express app startup, config loading, middleware setup, and socket wiring. · `server/src/app.js`
- [Middleware](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/middleware/authenticate.js): security/pipeline · Auth, role checks, validation, rate limiting, database checks, and error handling. · `server/src/middleware/authenticate.js`
- [API Routes](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/routes/booking.routes.js): http/routing · Resource endpoints for auth, bookings, parking, payments, reviews, search, admin, owner, analytics, and notifications. · `server/src/routes/booking.routes.js`
- [Auth Service](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/services/auth.service.js): identity/service · JWT-based authentication, user session logic, and related controllers and validators. · `server/src/services/auth.service.js`
- [Parking Service](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/services/parking.service.js): listing/service · Parking listing lifecycle, moderation, search support, and owner management. · `server/src/services/parking.service.js`
- [Booking Service](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/services/booking.service.js): reservation/service · Reservation lifecycle, booking validation, verification, completion, cancellation, and code generation. · `server/src/services/booking.service.js`
- [Availability](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/services/occupancy.service.js): slot/occupancy · Reservation-aware slot calculation and occupancy rules to prevent overbooking. · `server/src/services/occupancy.service.js`
- [Payments](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/services/payment.service.js): gateway/service · Razorpay payment flow and synchronization with booking state. · `server/src/services/payment.service.js`
- [Reviews](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/services/review.service.js): feedback/service · Review creation, moderation, and owner/admin review views. · `server/src/services/review.service.js`
- [Notifications](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/services/notification.service.js): events/service · Notification generation and formatting for booking, owner, and admin events. · `server/src/services/notification.service.js`
- [Analytics](https://github.com/tanishkokane2006-afk/smartpark_sytem_for_pune/blob/main/server/src/services/analytics.service.js): reporting/service · Occupancy, revenue, booking, and platform reporting for owner/admin dashboards. · `server/src/services/analytics.service.js`

## Connections

- App Shell → Route Guards: renders via · The app shell is governed by route-level protection and redirects.
- Route Guards → Auth: gates · Authentication state determines access and redirects.
- App Shell → Bookings: hosts · Role workspaces surface booking workflows within the shell.
- App Shell → Parkings: hosts · Listing and discovery screens are assembled under the app layout.
- App Shell → Map: hosts · Map-based discovery is part of the main client experience.
- App Shell → Profile: hosts · Profile and account settings live in the shared workspace.
- App Shell → Notifications: hosts · Notification UI is exposed alongside role workspaces.
- App Shell → Admin UX: specializes · Admin dashboard is a role-specific workspace.
- App Shell → Owner UX: specializes · Owner workspace is a role-specific surface.
- API Sync → API Routes: calls · Frontend API client and socket sync communicate with backend endpoints.
- Server Bootstrap → Middleware: applies · Incoming requests pass through security and validation middleware.
- Server Bootstrap → API Routes: mounts · Bootstrap attaches the API route surface.
- API Routes → Auth Service: delegates · Auth endpoints map into auth controllers and services.
- API Routes → Parking Service: delegates · Parking endpoints rely on parking domain services.
- API Routes → Booking Service: delegates · Booking endpoints execute reservation lifecycle logic.
- API Routes → Payments: delegates · Payment endpoints drive gateway verification and state sync.
- API Routes → Reviews: delegates · Review endpoints handle feedback workflows.
- API Routes → Notifications: delegates · Notification endpoints expose event-driven messaging.
- API Routes → Analytics: delegates · Analytics endpoints serve reporting for owner/admin views.
- Booking Service → Availability: depends on · Reservation logic uses occupancy and slot availability rules.
- Booking Service → Payments: syncs with · Booking state is coordinated with payment verification and completion.
- Booking Service → Notifications: emits · Booking lifecycle events generate notifications.
- Parking Service → Availability: uses · Discovery and availability depend on reservation-aware slot data.
- Reviews → Parking Service: references · Reviews are anchored to parking listings.
- Analytics → Booking Service: aggregates · Reporting derives from booking lifecycle data.
- Analytics → Parking Service: aggregates · Reporting also depends on parking inventory and utilization data.
- Notifications → Booking Service: reacts to · Notifications are triggered by booking and cancellation events.
