How dyancheng/web4in1-s5- works
1. Overall shape
This is a three-service travel/booking platform: a Next.js frontend, an ASP.NET Core Web API backend, and a Python FastAPI AI service, with Supabase/PostgreSQL as the main data store. The backend is the core application boundary; the frontend is mostly presentation and client state; the AI service is a separate auxiliary service.
2. Frontend subsystem
The frontend/ app is a Next.js 13+ style route-based UI (src/app/...) that covers the main customer flows: hotels, tours, flights, buses/vehicles, cart, checkout, payment, login/register, favorites, and role-specific dashboards such as admin, employee, accountant, and hotel-owner. This strongly suggests one unified web client serving both end users and internal staff.
3. Frontend state and API integration
The frontend uses React context for cross-cutting state: AuthContext, CartContext, and ThemeContext. It also has small client-side storage/API helper modules in src/lib/ for backend URL resolution, checkout, hotel storage, and tour storage, which implies the UI talks to the backend for transactions while also keeping some transient selections locally.
4. Backend subsystem
The backend/ project is the central business layer. It exposes domain controllers for Auth, Bookings, Bus, Discount, HotelBookings, Hotels, Orders, Payments, Rooms, and Tours. That split indicates the backend is organized by business capability rather than by technical layer.
5. Backend service layer
The backend’s Services/ folder contains the real orchestration and persistence logic: CheckoutService, DataStoreService, domain DB services for auth/hotels/tours/payments, BusService, DiscountService, EmailService, GoogleAuthService, and SePayService. This points to a service-oriented API design where controllers are thin and business rules/payment/auth flows are centralized in services.
6. Data and persistence boundary
Supabase/PostgreSQL is the main persistence boundary. The presence of SQL setup files (schema.sql, schema-payments.sql, setup_hotel_bookings.sql, update_rpcs.sql, seed scripts) suggests the backend relies on explicit database schema management and probably some PostgreSQL RPC/functions in addition to normal CRUD. The architecture therefore includes a clear application-to-database boundary with database-level features used for parts of the workflow.
7. Identity and external integrations
Authentication is not purely local: there is GoogleAuthService, and the readme calls out Supabase keys and URL configuration. Payments are also externalized via SePayService, and EmailService indicates transactional notifications are part of the backend workflow. These integrations are likely invoked from checkout/payment-related endpoints.
8. Domain model boundaries
The model layer includes User, Booking, Hotel, Room, Tour, BusTrip, BusBooking, and HotelBooking, which maps closely to the major business entities in the UI and controllers. This suggests the system is built around travel inventory plus reservation/order management, with separate booking concepts per product type.
9. AI service boundary
ai_service/ is a separate FastAPI app with its own container and Python dependencies. The repo doesn’t show mature AI logic yet, but the existence of Chatbot.tsx on the frontend and a dedicated service implies AI features are isolated from the main backend, likely as a standalone API that the frontend can call independently.
10. Runtime and deployment model
The repository is designed for containerized local development with Docker Compose, exposing the frontend on 3000, backend on 5000, and AI service on 8000. The readme also frames the frontend for Vercel deployment, which means the frontend can be deployed separately while still depending on the backend API and Supabase.
11. Operational tooling and environment
Environment configuration is centralized through .env and .env.example, with CI defined in GitHub Actions and container build files per service. This indicates the repository is meant to be deployed as independently built services, not as a single monolith.
12. How data likely flows
The usual request path is: user interacts with the Next.js app → frontend calls the ASP.NET API for auth, inventory, booking, checkout, payment, or profile actions → backend reads/writes Supabase/PostgreSQL and triggers integrations like email, Google auth, or SePay → frontend reflects the result in the relevant page or dashboard. The AI service is an optional parallel path for chatbot/AI requests rather than part of the core transaction flow.
Main entry points: Program.cs API layer · Services Service layer · app Web app · docker-compose.yml Compose stack
Components 18
Frontend
Next.js customer and staff UI
- Web app · Route-based customer and staff interface
frontend/src/app - Auth state · Session and sign-in state across the UI
frontend/src/contexts/AuthContext.tsx - Cart state · Shared cart and checkout selections
frontend/src/contexts/CartContext.tsx - Theme state · UI theme toggling and persistence
frontend/src/contexts/ThemeContext.tsx - API helpers · Backend URL, checkout, hotel, and tour helpers
frontend/src/lib - Chatbot UI · Frontend entry point for AI-assisted conversations
frontend/src/components/Chatbot.tsx
Backend
ASP.NET Core business API and persistence services
- API layer · Main application boundary exposing business endpoints
backend/Program.cs - Auth API · Login, registration, and identity flows
backend/Controllers/AuthController.cs - Booking API · Core reservation and order workflows
backend/Controllers/BookingsController.cs - Inventory APIs · Hotels, rooms, tours, buses, and hotel bookings
backend/Controllers/HotelsController.cs - Payment API · Payment and payment-status endpoints
backend/Controllers/PaymentsController.cs - Service layer · Business rules, checkout, auth, email, and gateway integrations
backend/Services - Data store · Database access for auth, hotels, tours, payments, and generic storage
backend/Services/DataStoreService.cs - Domain models · User, booking, hotel, room, tour, and bus booking objects
backend/Models
AI Service
Standalone FastAPI chatbot service
- FastAPI app · Standalone AI service for chatbot-style requests
ai_service/main.py
Data
Supabase/PostgreSQL schema and scripts
- Schema scripts · Database schema, seeds, and RPC updates
backend/schema.sql - Supabase/Postgres · Primary persistence boundary and RPC-backed workflows
Other components
- Compose stack · Local multi-service runtime for frontend, backend, and AI
docker-compose.yml
Connections 21
- Web app → Auth state: uses · UI reads auth/session state
- Web app → Cart state: uses · UI shares cart and checkout state
- Web app → Theme state: uses · UI applies theme state
- Web app → API helpers: calls · Pages call backend-facing helpers
- Web app → API layer: HTTP · Customer and staff screens call the main API
- Chatbot UI → FastAPI app: HTTP · Chatbot component talks to the AI service
- API layer → Auth API: routes · Auth endpoints are exposed through controllers
- API layer → Booking API: routes · Booking and order workflows are exposed through controllers
- API layer → Inventory APIs: routes · Inventory and product controllers
- API layer → Payment API: routes · Payment-related endpoints
- API layer → Service layer: orchestrates · Controllers delegate business logic to services
- Service layer → Data store: reads/writes · Services persist and load business data
- Service layer → Domain models: uses · Services operate on domain entities
- Data store → Supabase/Postgres: persists · Database access targets Supabase/PostgreSQL
- Schema scripts → Supabase/Postgres: defines · Schema and seed scripts shape the database
- Service layer → Schema scripts: depends on · Service behavior assumes schema and RPC setup
- Service layer → Payment API: integrates · Payment flows connect to external gateways and receipts
- Service layer → Auth API: integrates · Auth services include local and Google sign-in
- Compose stack → Web app: runs · Containerized frontend service
- Compose stack → API layer: runs · Containerized backend service
- Compose stack → FastAPI app: runs · Containerized AI service