Production-grade hotel reservation system built with NestJS microservices
Features β’ Quick Start β’ Architecture β’ Deployment
- Overview
- Features
- Tech Stack
- Architecture
- Quick Start
- Project Structure
- Microservices
- Development
- Testing
- Deployment
- Google Cloud Platform
- Kubernetes
- Contributing
- License
Wiser is a comprehensive hotel reservation platform demonstrating enterprise-grade microservices architecture using NestJS. The project showcases modern backend development practices including dependency injection, event-driven communication, database per service pattern, and cloud-native deployment.
- β NestJS Best Practices: Modules, services, controllers, guards, interceptors
- β Cloud-Native: Designed for Google Cloud Platform with Kubernetes
- β Production-Ready: Authentication, validation, error handling, logging
- β Scalable Architecture: Independent services, horizontal scaling
- β CI/CD Pipeline: Automated builds and deployments with CloudBuild
- β Educational: Clean code, comprehensive documentation, real-world patterns
- π Authentication & Authorization: JWT-based auth with passport.js
- π¨ Reservation Management: Create, update, cancel hotel bookings
- π³ Payment Processing: Payment integration with Stripe
- π§ Notification System: Email notifications for bookings, cancellations
- π Admin Dashboard: Manage reservations, users, hotels
- π― Microservices Architecture: Independent, deployable services
- π Event-Driven Communication: RabbitMQ/NATS for async messaging
- πΎ Database Per Service: MongoDB with Mongoose
- π³ Containerized: Docker for local development
- βΈοΈ Kubernetes-Ready: Helm charts for production deployment
- π GCP Integration: Cloud Build, Artifact Registry, GKE
- NestJS 10.x - Progressive Node.js framework
- TypeScript 5.x - Type-safe development
- Node.js 20.x - Runtime environment
| Service | Responsibility | Database |
|---|---|---|
| Reservations | Booking management | MongoDB |
| Auth | Authentication & authorization | MongoDB |
| Payments | Payment processing | MongoDB |
| Notifications | Email/SMS alerts | MongoDB |
- Database: MongoDB with Mongoose ODM
- Message Broker: RabbitMQ / NATS
- Containerization: Docker & Docker Compose
- Orchestration: Kubernetes with Helm
- Cloud Platform: Google Cloud Platform (GCP)
- Google Artifact Registry
- Google Kubernetes Engine (GKE)
- Cloud Build for CI/CD
- Unit Tests: Jest
- E2E Tests: Supertest
- Integration Tests: Testcontainers
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Client Layer β
β (Web App, Mobile App, Admin Panel) β
βββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β HTTPS/REST
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β API Gateway β
β ββββββββββββ ββββββββββββ ββββββββββββββββ β
β β Auth βββΆβ Rate βββΆβ Routing β β
β β Guard β β Limit β β Logic β β
β ββββββββββββ ββββββββββββ ββββββββββββββββ β
βββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βββββββββββββΌββββββββββββ
βΌ βΌ βΌ
βββββββββββ βββββββββββ βββββββββββ βββββββββββ
β Auth β βReserva- β βPayments β β Notif β
β Service β β tions β β Service β β Service β
β β β Service β β β β β
ββββββ¬βββββ ββββββ¬βββββ ββββββ¬βββββ ββββββ¬βββββ
β β β β
βββββββββββββ΄ββββββββββββ΄ββββββββββββ
β
βββββββ΄ββββββ
βΌ βΌ
ββββββββββββ ββββββββββββ
β RabbitMQ β β MongoDB β
β (Events) β β(Per Svc) β
ββββββββββββ ββββββββββββ
- Synchronous: REST API for immediate responses
- Asynchronous: RabbitMQ/NATS for events (booking confirmation, payments)
- Database Per Service: Each service owns its data
Get Wiser running locally in 5 minutes:
- Node.js >= 20.x
- Docker & Docker Compose
- Git
# 1. Clone the repository
git clone https://github.com/hassonor/wiser.git
cd wiser
# 2. Install dependencies
npm install
# 3. Start MongoDB and RabbitMQ via Docker
docker-compose up -d
# 4. Set up environment variables
cp .env.example .env
# Edit .env with your configuration
# 5. Run database migrations (if any)
npm run migration:run
# 6. Start all microservices in development mode
npm run start:dev
# Access the API at http://localhost:3000# Health check
curl http://localhost:3000/health
# Test authentication
curl -X POST http://localhost:3000/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"test@example.com","password":"password"}'wiser/
βββ apps/ # Microservices
β βββ reservations/ # Reservation service
β β βββ src/
β β β βββ dto/ # Data transfer objects
β β β βββ entities/ # Database entities
β β β βββ reservations.controller.ts
β β β βββ reservations.service.ts
β β β βββ reservations.module.ts
β β β βββ main.ts
β β βββ test/
β β βββ Dockerfile
β β
β βββ auth/ # Authentication service
β β βββ src/
β β β βββ strategies/ # Passport strategies (JWT, local)
β β β βββ guards/ # Auth guards
β β β βββ auth.controller.ts
β β β βββ auth.service.ts
β β β βββ main.ts
β β βββ Dockerfile
β β
β βββ payments/ # Payment service
β βββ notifications/ # Notification service
β
βββ libs/ # Shared libraries
β βββ common/ # Common utilities
β β βββ database/ # Database connection
β β βββ decorators/ # Custom decorators
β β βββ filters/ # Exception filters
β β βββ interceptors/ # Logging, transform
β β βββ guards/ # Shared guards
β βββ config/ # Configuration module
β
βββ k8s/ # Kubernetes manifests
β βββ wiser/ # Helm chart
β βββ Chart.yaml
β βββ values.yaml
β βββ templates/
β βββ reservations/
β β βββ deployment.yaml
β β βββ service.yaml
β βββ auth/
β βββ payments/
β
βββ .cursorrules # AI coding standards
βββ .github/
β βββ dependabot.yml # Automated dependency updates
β βββ workflows/ # CI/CD pipelines
β
βββ cloudbuild.yaml # Google Cloud Build config
βββ docker-compose.yaml # Local development
βββ nest-cli.json # NestJS configuration
βββ package.json # Dependencies
βββ README.md
Manages hotel bookings
Endpoints:
POST /reservations # Create booking
GET /reservations # List all bookings
GET /reservations/:id # Get booking details
PATCH /reservations/:id # Update booking
DELETE /reservations/:id # Cancel booking
Events Published:
reservation.createdreservation.updatedreservation.cancelled
JWT-based authentication
Endpoints:
POST /auth/register # User registration
POST /auth/login # User login
POST /auth/refresh # Refresh access token
GET /auth/profile # Get user profile
Guards:
JwtAuthGuard- Protect routes with JWTLocalAuthGuard- Email/password authentication
Stripe integration
Endpoints:
POST /payments/charge # Process payment
POST /payments/refund # Refund payment
GET /payments/:id # Get payment details
Email/SMS notifications
Events Consumed:
reservation.createdβ Send confirmation emailreservation.cancelledβ Send cancellation emailpayment.completedβ Send receipt
# Start specific service
npm run start:dev reservations
# Build for production
npm run build reservations
# Run tests
npm run test reservations
npm run test:e2e reservationsEach service requires environment variables:
# Reservations Service
MONGODB_URI=mongodb://localhost:27017/reservations
RABBITMQ_URL=amqp://localhost:5672
JWT_SECRET=your-secret-key
PORT=3001
# Auth Service
MONGODB_URI=mongodb://localhost:27017/auth
JWT_SECRET=your-secret-key
JWT_EXPIRES_IN=1h
PORT=3002
# Payments Service
STRIPE_SECRET_KEY=sk_test_...
MONGODB_URI=mongodb://localhost:27017/payments
PORT=3003# Generate new module
nest g module users apps/reservations
# Generate service
nest g service users apps/reservations
# Generate controller
nest g controller users apps/reservations# Run all tests
npm run test
# Watch mode
npm run test:watch
# Coverage
npm run test:cov# Run E2E tests for a service
npm run test:e2e reservations# Uses Testcontainers for real MongoDB
npm run test:integration# Build and start all services
docker-compose up --build
# Scale a service
docker-compose up --scale reservations=3
# View logs
docker-compose logs -f reservations
# Stop all
docker-compose down# Enable Container Registry and Artifact Registry
gcloud services enable containerregistry.googleapis.com
gcloud services enable artifactregistry.googleapis.com# Set your project
gcloud config set project YOUR_PROJECT_ID
# Create repository for each service
gcloud artifacts repositories create reservations \
--repository-format=docker \
--location=us-central1 \
--description="Reservations service images"
# Repeat for auth, payments, notifications# Authenticate Docker
gcloud auth configure-docker us-central1-docker.pkg.dev
# Build and push (example for reservations)
cd apps/reservations/
docker build -t reservations -f ./Dockerfile ../../
docker tag reservations us-central1-docker.pkg.dev/YOUR_PROJECT/reservations/production
docker push us-central1-docker.pkg.dev/YOUR_PROJECT/reservations/productionCreate cloudbuild.yaml at project root:
steps:
# Build reservations service
- name: 'gcr.io/cloud-builders/docker'
args:
- 'build'
- '-t'
- 'us-central1-docker.pkg.dev/$PROJECT_ID/reservations/production'
- '-f'
- './apps/reservations/Dockerfile'
- '.'
# Push reservations service
- name: 'gcr.io/cloud-builders/docker'
args:
- 'push'
- 'us-central1-docker.pkg.dev/$PROJECT_ID/reservations/production'
# Repeat for other services...
images:
- 'us-central1-docker.pkg.dev/$PROJECT_ID/reservations/production'
- 'us-central1-docker.pkg.dev/$PROJECT_ID/auth/production'
- 'us-central1-docker.pkg.dev/$PROJECT_ID/payments/production'
- 'us-central1-docker.pkg.dev/$PROJECT_ID/notifications/production'Set up Cloud Build Trigger:
- Go to Cloud Build β Triggers
- Connect your GitHub repository
- Create trigger to run on push to
mainbranch - Use
cloudbuild.yamlas build configuration
# Enable Kubernetes in Docker Desktop
# Settings β Kubernetes β Enable Kubernetes
# Install Helm
brew install helm # macOS
choco install helm # Windows
# Verify installation
kubectl version
helm version# Create Helm chart
cd k8s/
helm create wiser
# Create deployments for each service
kubectl create deployment reservations \
--image=us-central1-docker.pkg.dev/PROJECT/reservations/production \
--dry-run=client -o yaml > ./wiser/templates/reservations/deployment.yaml
# Create services
kubectl create service clusterip reservations \
--tcp=3001:3001 \
--dry-run=client -o yaml > ./wiser/templates/reservations/service.yaml
# Repeat for other services# Install/upgrade the Helm chart
helm upgrade --install wiser ./k8s/wiser \
--set reservations.image=us-central1-docker.pkg.dev/PROJECT/reservations/production \
--set auth.image=us-central1-docker.pkg.dev/PROJECT/auth/production
# Check deployment status
kubectl get pods
kubectl get services
# View logs
kubectl logs -f deployment/reservations
# Scale deployment
kubectl scale deployment reservations --replicas=3# Create GKE cluster
gcloud container clusters create wiser-cluster \
--zone=us-central1-a \
--num-nodes=3 \
--machine-type=n1-standard-2
# Get credentials
gcloud container clusters get-credentials wiser-cluster --zone=us-central1-a
# Deploy using Helm
helm upgrade --install wiser ./k8s/wiser
# Set up Ingress for external access
kubectl apply -f k8s/ingress.yamlContributions are welcome! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes following
.cursorrules - Write/update tests
- Run linter:
npm run lint - Commit:
git commit -m "feat: add amazing feature" - Push:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with NestJS - A progressive Node.js framework
- Inspired by production hotel booking platforms
- Created for educational purposes to demonstrate microservices architecture
Made with β€οΈ by Or Hasson
β Star this repo if you find it helpful!