How tanishkokane2006-afk/smartpark_sytem_for_pune works
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: booking.routes.js API Routes · AppLayout.jsx App Shell · booking.service.js Booking Service · parking.service.js Parking Service
Components 22
Frontend
React/Vite application with role-based UX and feature modules.
- App Shell · Top-level client layout, workspace framing, and navigation composition.
client/src/app/AppLayout.jsx - Route Guards · Redirects and protection for authenticated and role-based access.
client/src/routes/ProtectedRoute.jsx - Auth · Login, register, auth context, and validation for session handling.
client/src/features/auth/AuthProvider.jsx - Bookings · Booking modals, booking pages, and client-side booking intent helpers.
client/src/features/bookings/BookingModal.jsx - Parkings · Parking search, listing, forms, detail views, and upload workflows.
client/src/features/parkings/ParkingListPage.jsx - Map · Map view, markers, landmarks, and nearby/recommendation panels.
client/src/features/map/MapView.jsx - Profile · Account settings, phone display, and profile-related utilities.
client/src/features/profile/AccountSettingsPanel.jsx - Notifications · Notification bell, notifications page, and client notification service.
client/src/features/notifications/NotificationBell.jsx - Admin UX · Admin dashboard and admin-facing API orchestration.
client/src/features/admin/AdminDashboardPage.jsx - Owner UX · Owner parking detail and owner-focused API orchestration.
client/src/features/owner/OwnerParkingDetail.jsx - API Sync · 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 · Express app startup, config loading, middleware setup, and socket wiring.
server/src/app.js - Middleware · Auth, role checks, validation, rate limiting, database checks, and error handling.
server/src/middleware/authenticate.js - API Routes · Resource endpoints for auth, bookings, parking, payments, reviews, search, admin, owner, analytics, and notifications.
server/src/routes/booking.routes.js - Auth Service · JWT-based authentication, user session logic, and related controllers and validators.
server/src/services/auth.service.js - Parking Service · Parking listing lifecycle, moderation, search support, and owner management.
server/src/services/parking.service.js - Booking Service · Reservation lifecycle, booking validation, verification, completion, cancellation, and code generation.
server/src/services/booking.service.js - Availability · Reservation-aware slot calculation and occupancy rules to prevent overbooking.
server/src/services/occupancy.service.js - Payments · Razorpay payment flow and synchronization with booking state.
server/src/services/payment.service.js - Reviews · Review creation, moderation, and owner/admin review views.
server/src/services/review.service.js - Notifications · Notification generation and formatting for booking, owner, and admin events.
server/src/services/notification.service.js - Analytics · Occupancy, revenue, booking, and platform reporting for owner/admin dashboards.
server/src/services/analytics.service.js
Connections 27
- 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.