# santoshkumar555/private architecture

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

- Interactive diagram: https://gitdiagram.com/santoshkumar555/private
- Repository: https://github.com/santoshkumar555/private

## Overview

1. This is a three-part travel/booking system: a public customer-facing frontend, a separate admin dashboard, and a shared Node.js backend API. The backend is the source of truth for domain data such as users, hotels, locations, packages, bookings, and payments.

2. The public frontend lives in `frontend/` and uses Next.js App Router. Its route groups split the site into `(public)` pages and `(auth)` pages, with route-level layouts for authenticated vs unauthenticated experiences. The app mixes server-rendered pages with client components for interactive flows like search, checkout, wishlist, and booking management.

3. The admin dashboard lives in `admin/` and is a separate React + Vite application. It has its own routing, layouts, and UI components for operational work: dashboard stats, CRUD screens for hotels/locations/packages/users, booking review, and profile/settings management. It talks directly to the backend through dedicated service modules.

4. The backend in `backend/` is an Express API organized by domain and audience. Routes are split into `auth`, `user`, `admin`, `payment`, and `health`, and controllers are grouped under matching folders. This makes the API boundary explicit: public/user operations are separated from privileged admin operations.

5. Core data entities are modeled in `backend/models/` as `user`, `booking`, `hotel`, `location`, and `package`. The API shape mirrors these entities: each domain has create/read/update/delete controllers for admin use, and read-only or self-service controllers for end users.

6. The main request pipeline on the backend is layered: routes → middleware → validation → controller → services/models. Middleware handles authentication, admin authorization, body parsing, logging, rate limiting, uploads, and error handling. Validation is split by domain so bad requests are rejected before business logic runs.

7. Several external integrations materially shape the architecture:
   - Cloudinary for media/file uploads.
   - Razorpay for payment order creation, payment verification, and webhook handling.
   - Email/OTP services for registration, verification, password reset, and related auth flows.
   These integrations are isolated in `backend/services/` and called from controllers.

8. Authentication and user identity are multi-channel. The backend exposes login/register/admin-login, refresh token, logout, OTP verification, password reset, and email verification endpoints. The frontend stores auth state in context/storage utilities and uses protected routes and cookie/token helpers; the admin app has its own login flow and access checks.

9. Booking is a cross-cutting workflow spanning all three layers. Users browse packages/hotels/locations in the public frontend, create bookings through the backend, and may pay through the payment service. Users can later view/cancel bookings, while admins can inspect and update booking status from the dashboard.

10. Public browsing features are driven by search and content endpoints. The frontend has dedicated API wrappers for packages, hotels, locations, and payments, plus UI components for destination pages, listing filters, featured packages, and hotel/package detail pages. This suggests most browsing pages are data-driven and parameterized by slugs/ids.

11. State management differs by app. The public frontend uses Redux slices for UI/toasts/wishlist/booking state plus an auth context; the admin app is more page-local and service-driven. Both apps centralize API calls in service modules rather than calling fetch/axios directly from views.

12. The repository also includes operational support artifacts: seeders for bootstrapping admins, users, hotels, locations, packages, and bookings; Postman docs for the API; and environment/config modules for DB, CORS, and cloud services. These pieces indicate the backend is designed to be deployable and testable independently of the frontends.

13. For an architecture diagram, the key boundaries are: public customer UI, admin UI, backend API, database/models, and external services. The dominant data flows are browse/search → read APIs, auth/session flows, booking/payment flows, and admin CRUD flows, all converging on the backend as the shared business layer.

Main entry points: [`backend/routes`](https://github.com/santoshkumar555/private/tree/main/backend/routes) (API routes), [`frontend/app/(public)`](https://github.com/santoshkumar555/private/tree/main/frontend/app/(public)) (Public routes), [`frontend/lib/api`](https://github.com/santoshkumar555/private/tree/main/frontend/lib/api) (API clients), [`backend/models`](https://github.com/santoshkumar555/private/tree/main/backend/models) (Domain models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Public frontend"]
  node_frontend_app["Frontend app<br/>Next.js UI"]
  node_frontend_public["Public routes<br/>server/client pages"]
  node_frontend_auth["Auth routes<br/>auth pages"]
  node_frontend_components["UI components<br/>presentation"]
  node_frontend_state["Client state<br/>redux/context"]
  node_frontend_api["API clients<br/>frontend data access"]
end

subgraph group_admin["Admin dashboard"]
  node_admin_app["Admin app<br/>React + Vite"]
  node_admin_routes["Admin routing<br/>route shell"]
  node_admin_pages["Admin pages<br/>ops screens"]
  node_admin_services["Admin services<br/>API clients"]
end

subgraph group_backend["Backend API"]
  node_backend_app["API entry<br/>express app<br/>[app.js]"]
  node_backend_routes["API routes<br/>route boundary"]
  node_backend_middleware["Middleware stack<br/>pipeline layers"]
  node_backend_auth["Auth domain<br/>identity flow"]
  node_backend_user["User domain<br/>customer flow"]
  node_backend_admin["Admin domain<br/>ops flow"]
  node_backend_payment["Payment domain<br/>checkout flow"]
  node_backend_models[("Domain models<br/>mongoose models")]
  node_backend_services["Integrations<br/>service layer"]
end

subgraph group_integrations["External services"]
  node_external(("Third-party systems<br/>cloud/email/payments"))
end

node_frontend_app -->|"renders"| node_frontend_public
node_frontend_app -->|"renders"| node_frontend_auth
node_frontend_public -->|"uses"| node_frontend_components
node_frontend_public -->|"shares state"| node_frontend_state
node_frontend_public -->|"calls"| node_frontend_api
node_frontend_auth -->|"calls"| node_frontend_api
node_admin_app -->|"routes through"| node_admin_routes
node_admin_routes -->|"shows"| node_admin_pages
node_admin_pages -->|"calls"| node_admin_services
node_backend_app -->|"mounts"| node_backend_routes
node_backend_app -->|"applies"| node_backend_middleware
node_backend_routes -->|"exposes"| node_backend_auth
node_backend_routes -->|"exposes"| node_backend_user
node_backend_routes -->|"exposes"| node_backend_admin
node_backend_routes -->|"exposes"| node_backend_payment
node_backend_auth -->|"uses"| node_backend_services
node_backend_user -->|"reads/writes"| node_backend_models
node_backend_admin -->|"reads/writes"| node_backend_models
node_backend_payment -->|"uses"| node_backend_services
node_backend_services -->|"integrates with"| node_external
node_backend_models -.->|"supports"| node_backend_services
node_frontend_api -->|"consumes"| node_backend_routes
node_admin_services -->|"consumes"| node_backend_routes
node_frontend_state -.->|"orchestrates"| node_frontend_api
node_backend_middleware -.->|"guards"| node_backend_models

click node_frontend_app "https://github.com/santoshkumar555/private/tree/main/frontend/app"
click node_frontend_public "https://github.com/santoshkumar555/private/tree/main/frontend/app/(public)"
click node_frontend_auth "https://github.com/santoshkumar555/private/tree/main/frontend/app/(auth)"
click node_frontend_components "https://github.com/santoshkumar555/private/tree/main/frontend/components"
click node_frontend_state "https://github.com/santoshkumar555/private/tree/main/frontend/store"
click node_frontend_api "https://github.com/santoshkumar555/private/tree/main/frontend/lib/api"
click node_admin_app "https://github.com/santoshkumar555/private/tree/main/admin/src"
click node_admin_routes "https://github.com/santoshkumar555/private/tree/main/admin/src/routes"
click node_admin_pages "https://github.com/santoshkumar555/private/tree/main/admin/src/pages"
click node_admin_services "https://github.com/santoshkumar555/private/tree/main/admin/src/services"
click node_backend_app "https://github.com/santoshkumar555/private/blob/main/backend/app.js"
click node_backend_routes "https://github.com/santoshkumar555/private/tree/main/backend/routes"
click node_backend_middleware "https://github.com/santoshkumar555/private/tree/main/backend/middleware"
click node_backend_auth "https://github.com/santoshkumar555/private/tree/main/backend/controllers/auth"
click node_backend_user "https://github.com/santoshkumar555/private/tree/main/backend/controllers/user"
click node_backend_admin "https://github.com/santoshkumar555/private/tree/main/backend/controllers/admin"
click node_backend_payment "https://github.com/santoshkumar555/private/tree/main/backend/controllers/payment"
click node_backend_models "https://github.com/santoshkumar555/private/tree/main/backend/models"
click node_backend_services "https://github.com/santoshkumar555/private/tree/main/backend/services"

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_frontend_app,node_frontend_public,node_frontend_auth,node_frontend_components,node_frontend_state,node_frontend_api toneBlue
class node_admin_app,node_admin_routes,node_admin_pages,node_admin_services toneAmber
class node_backend_app,node_backend_routes,node_backend_middleware,node_backend_auth,node_backend_user,node_backend_admin,node_backend_payment,node_backend_models,node_backend_services toneMint
class node_external toneRose
```

## Components

### Public frontend

Next.js customer-facing travel and booking experience

- [Frontend app](https://github.com/santoshkumar555/private/tree/main/frontend/app): Next.js UI · Public customer-facing application with public and auth route groups · `frontend/app`
- [Public routes](https://github.com/santoshkumar555/private/tree/main/frontend/app/(public)): server/client pages · Browse, destination, hotel, package, checkout, wishlist, booking, and profile pages · `frontend/app/(public)`
- [Auth routes](https://github.com/santoshkumar555/private/tree/main/frontend/app/(auth)): auth pages · Login, register, forgot-password, and reset-password flows · `frontend/app/(auth)`
- [UI components](https://github.com/santoshkumar555/private/tree/main/frontend/components): presentation · Shared page sections, detail views, filters, and booking widgets · `frontend/components`
- [Client state](https://github.com/santoshkumar555/private/tree/main/frontend/store): redux/context · Auth context, redux slices, and storage/token helpers · `frontend/store`
- [API clients](https://github.com/santoshkumar555/private/tree/main/frontend/lib/api): frontend data access · Browser/server request wrappers for auth, browse, booking, and payment APIs · `frontend/lib/api`

### Admin dashboard

Vite-based operational dashboard for staff workflows

- [Admin app](https://github.com/santoshkumar555/private/tree/main/admin/src): React + Vite · Separate admin dashboard for staff operations · `admin/src`
- [Admin routing](https://github.com/santoshkumar555/private/tree/main/admin/src/routes): route shell · App router and protected/auth layout composition · `admin/src/routes`
- [Admin pages](https://github.com/santoshkumar555/private/tree/main/admin/src/pages): ops screens · Dashboard, CRUD, bookings, profile, and settings pages · `admin/src/pages`
- [Admin services](https://github.com/santoshkumar555/private/tree/main/admin/src/services): API clients · Dedicated service modules for backend calls from the dashboard · `admin/src/services`

### Backend API

Express domain API and business logic

- [API entry](https://github.com/santoshkumar555/private/blob/main/backend/app.js): express app · Server bootstrap and request pipeline assembly · `backend/app.js`
- [API routes](https://github.com/santoshkumar555/private/tree/main/backend/routes): route boundary · Top-level routing split by auth, user, admin, payment, and health · `backend/routes`
- [Middleware stack](https://github.com/santoshkumar555/private/tree/main/backend/middleware): pipeline layers · Authentication, authorization, validation, uploads, logging, rate limiting, and errors · `backend/middleware`
- [Auth domain](https://github.com/santoshkumar555/private/tree/main/backend/controllers/auth): identity flow · Register, login, admin login, token refresh, OTP, email verification, reset, and logout · `backend/controllers/auth`
- [User domain](https://github.com/santoshkumar555/private/tree/main/backend/controllers/user): customer flow · Self-service profile, hotel/location/package browsing, and bookings · `backend/controllers/user`
- [Admin domain](https://github.com/santoshkumar555/private/tree/main/backend/controllers/admin): ops flow · Admin CRUD for users, hotels, locations, packages, bookings, and profile/stats · `backend/controllers/admin`
- [Payment domain](https://github.com/santoshkumar555/private/tree/main/backend/controllers/payment): checkout flow · Payment order creation, verification, and webhook processing · `backend/controllers/payment`
- [Domain models](https://github.com/santoshkumar555/private/tree/main/backend/models): mongoose models · User, booking, hotel, location, and package data models · `backend/models`
- [Integrations](https://github.com/santoshkumar555/private/tree/main/backend/services): service layer · Cloudinary, email/OTP, and Razorpay service wrappers · `backend/services`

### External services

Third-party services and operational dependencies

- **Third-party systems**: cloud/email/payments · Cloudinary, email delivery, OTP, and Razorpay providers

## Connections

- Frontend app → Public routes: renders · Public route group is mounted inside the Next.js app shell
- Frontend app → Auth routes: renders · Auth route group is mounted inside the Next.js app shell
- Public routes → UI components: uses · Public pages are composed from shared UI sections and client widgets
- Public routes → Client state: shares state · Auth, wishlist, booking, and toast state support public flows
- Public routes → API clients: calls · Browsing, booking, and payment pages use API wrappers
- Auth routes → API clients: calls · Authentication pages submit through frontend auth API clients
- Admin app → Admin routing: routes through · Admin shell delegates navigation and access control to route setup
- Admin routing → Admin pages: shows · Protected and auth layouts wrap operational pages
- Admin pages → Admin services: calls · Dashboard screens use service modules for backend requests
- API entry → API routes: mounts · Express app mounts domain routes
- API entry → Middleware stack: applies · Global middleware runs before route handlers
- API routes → Auth domain: exposes · Auth routes map to identity controllers
- API routes → User domain: exposes · User routes map to customer-facing controllers
- API routes → Admin domain: exposes · Admin routes map to privileged controllers
- API routes → Payment domain: exposes · Payment routes map to checkout controllers
- Auth domain → Integrations: uses · OTP and email flows call shared services
- User domain → Domain models: reads/writes · Booking and profile actions persist domain data through models
- Admin domain → Domain models: reads/writes · Admin CRUD and booking updates operate on core entities
- Payment domain → Integrations: uses · Payment controllers use Razorpay integration helpers
- Integrations → Third-party systems: integrates with · Service layer isolates Cloudinary, mail/OTP, and Razorpay providers
- Domain models → Integrations: supports · Uploads, payments, and messaging augment domain workflows
- API clients → API routes: consumes · Public frontend requests the shared backend API surface
- Admin services → API routes: consumes · Admin dashboard talks directly to backend endpoints
- Client state → API clients: orchestrates · Client state and storage/token helpers coordinate authenticated requests
- Middleware stack → Domain models: guards · Validation and authorization protect model mutations
