How santoshkumar555/private works
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: routes API routes · (public) Public routes · api API clients · models Domain models
Components 20
Public frontend
Next.js customer-facing travel and booking experience
- Frontend app · Public customer-facing application with public and auth route groups
frontend/app - Public routes · Browse, destination, hotel, package, checkout, wishlist, booking, and profile pages
frontend/app/(public) - Auth routes · Login, register, forgot-password, and reset-password flows
frontend/app/(auth) - UI components · Shared page sections, detail views, filters, and booking widgets
frontend/components - Client state · Auth context, redux slices, and storage/token helpers
frontend/store - API clients · 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 · Separate admin dashboard for staff operations
admin/src - Admin routing · App router and protected/auth layout composition
admin/src/routes - Admin pages · Dashboard, CRUD, bookings, profile, and settings pages
admin/src/pages - Admin services · Dedicated service modules for backend calls from the dashboard
admin/src/services
Backend API
Express domain API and business logic
- API entry · Server bootstrap and request pipeline assembly
backend/app.js - API routes · Top-level routing split by auth, user, admin, payment, and health
backend/routes - Middleware stack · Authentication, authorization, validation, uploads, logging, rate limiting, and errors
backend/middleware - Auth domain · Register, login, admin login, token refresh, OTP, email verification, reset, and logout
backend/controllers/auth - User domain · Self-service profile, hotel/location/package browsing, and bookings
backend/controllers/user - Admin domain · Admin CRUD for users, hotels, locations, packages, bookings, and profile/stats
backend/controllers/admin - Payment domain · Payment order creation, verification, and webhook processing
backend/controllers/payment - Domain models · User, booking, hotel, location, and package data models
backend/models - Integrations · Cloudinary, email/OTP, and Razorpay service wrappers
backend/services
External services
Third-party services and operational dependencies
- Third-party systems · Cloudinary, email delivery, OTP, and Razorpay providers
Connections 25
- 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