How dhruvmoradiya69/deployment-mern-stack-hotel-booking-application works
Project Type and Purpose
• Full-stack web application: React frontend (SPA), Node/Express backend, MongoDB database.
• Deployed locally via Docker Compose or in Kubernetes (Kind) clusters.
• Cloud-related provisioning via Terraform.
• Integrates external services: Cloudinary (image storage), Stripe (payments), JWT authentication.
File Structure
• Top-level ‘backend’ folder: Node/Express in TypeScript, structured by models, middleware, and routes (MVC pattern).
• Top-level ‘frontend’ folder: React + TypeScript, structured by pages, components, contexts, forms, layouts, with Nginx for static hosting.
• ‘docker-compose.yml’: multi-container setup for local dev (frontend, backend, MongoDB).
• ‘k8s’ folder: Kubernetes deployment/service YAMLs for all components plus Ingress.
• ‘terraform’ folder: scripts and Terraform configs to provision infrastructure (e.g., cloud VPCs, clusters).
README Insights
• Purpose: hotel booking with authentication, hotel management, image uploads, filtering, Stripe payments.
• Deployment options: Docker Compose and Kubernetes (Kind) with clear step-by-step commands.
• Environment variables outline external dependencies (MongoDB URI, JWT secret, Cloudinary, Stripe keys).
Main Components and Their Relationships
a. Presentation Layer (Frontend)
• User’s Web Browser
• Nginx (serving static React bundle)
• React SPA (AppContext, SearchContext, components, pages)
b. Application Layer (Backend)
• Node.js + Express server
• Middleware (Authentication)
• Routes/Controllers (auth, hotels, bookings, users, profiles)
• Models (User, Hotel)
c. Data Layer
• MongoDB (persistent storage via a StatefulSet/PVC in K8s or container in Compose)
d. External Services
• Cloudinary (image upload/storage)
• Stripe (payment gateway)
e. Orchestration/Infrastructure
• Docker Compose network
• Kubernetes cluster (Deployments, Services, Ingress)
• Terraform-managed cloud resources (optional)
Interactions:
• Browser → HTTP(S) → Nginx → serves React → API calls to Backend.
• Backend ↔ MongoDB (CRUD).
• Backend ↔ Cloudinary (upload/download images).
• Backend ↔ Stripe (create and confirm payments).
• Terraform provisions Kubernetes cluster, networking, secrets.
Architectural Patterns and Principles
• Backend follows MVC: models in /models, controllers in /routes, cross-cutting concerns in /middleware.
• Frontend uses component-based architecture with Context API for global/state management and form modules.
• Separation of concerns: distinct layers for presentation, business logic, and data.
• Infrastructure as Code: Terraform for provisioning; Kubernetes YAML for declarative deployments.
Essential Elements
• Components: Browser, Nginx, React, Express API, MongoDB, Cloudinary, Stripe, Docker/K8s, Terraform.