How advanced-computer-lab-2024/trip-genie works
Main Components
• Frontend (Client Side)
• Built in React (with Vite) and styled using Tailwind CSS.
• Organized into key folders such as “src”, “components”, “pages”, “assets”, and “hooks.”
• Handles user interfaces, routing, authentication, and dynamic interactions (for activities, itineraries, products, etc.).
• Backend (Server Side)
• Built with Node.js and Express.js.
• Contains directories like “controllers”, “models”, “routes”, “middlewares”, “services”, and “utils.”
• Implements role-specific APIs for different endpoints (tourist, tour-guide, advertiser, seller, tourism governor, admin).
• Includes error handling, file uploads, cloud services integration (Cloudinary for images) and uses external APIs (Amadeus for flights, Stripe for payments, Booking.com for hotels).
• Database
• Although not explicitly depicted in the file tree, the README mentions MongoDB as the technology used.
• The data models (in “backend/models”) represent the data structure for users, activities, itineraries, products, currencies, and more.
• External Services
• Payment Service: Stripe for payment processing.
• Flight/Hotel API: Amadeus and Booking.com connected via REST endpoints.
• Image Storage: Cloudinary uploads from various endpoints (e.g., product images & activity images).
• Authentication: Uses JWT stored in cookies with role-based access middleware.
Diagramming Relationships and Interactions
• User Flow / Client Interaction:
• Users interact with the Frontend (browser) which sends API requests to the backend.
• Role-based access is clearly enforced. For example, tourists, tour guides, sellers, advertisers, and admins have specific routes and controllers.
• The frontend components (React pages and common UI components) handle the presentation and call appropriate API endpoints based on role.
• Backend API Layer:
• Controllers receive requests through Express routes. Each controller (e.g., authController, activityController, productController) processes the logic for its specific domain.
• Middlewares (authMiddleware) ensure authentication and authorization before reaching the controllers.
• Service layer (e.g., emailService) and utility modules (e.g., cloudinary functions) provide additional support and integration with external services.
• Database Communication:
• Controllers interact with MongoDB through Mongoose models (found in “backend/models”), handling CRUD operations for various entities like activities, itineraries, products, bookings, etc.
• External Systems:
• The backend communicates with external APIs (Amadeus, Stripe, and Booking.com) to fetch flight/hotel information, process payments, or manage booking details.
• Cloudinary is used for uploading and storing images, managed by dedicated functions in “backend/utils”.
Important Architectural Patterns/Design Principles
• Modular Structure: Separation between controllers, models, routes, and services enables maintainability and scalability.
• Role-Based Access Control: Different endpoints and authentication logic tailored for each distinct user role.
• Service-Oriented Integrations: External APIs and micro-services (payment, image storage, flight data) integrated with dedicated modules.
• Component-Based Frontend: React components distributed across pages and UI libraries with clear folder separation.
Diagramming the Specific Project Architecture
[Browser/Client]
│
▼
[Frontend (React App)]
│ (Authenticated API requests based on user role)
▼
[Backend API Server (Express)]
├── [Authentication & Role Middleware]
├── [Controllers (e.g., Auth, Activity, Itinerary, Product, Booking)]
└── [Services & Utilities (Email, Cloudinary, etc.)]
│
├──→ [Database (MongoDB)]
└──→ [External Services]
• Payment: Stripe
• Flight/Hotel: Amadeus & Booking APIs
• File Storage: Cloudinary
Additional Details
• Be sure to include any configuration or deployment elements such as “vercel.json” from the backend for deployment setup.
• Mention that multiple testing strategies exist (e.g., Postman tests, backend test scripts) which validate API endpoints.