A scalable, production-ready flight booking system built with Node.js, MongoDB, and Redis. This project demonstrates a modular microservices architecture with authentication, caching, containerization, and cloud deployment capabilities.
- π JWT-based Authentication - Secure token-based user authentication
- π« Flight Management - Create and manage flight schedules
- πΊ Seat Booking - Real-time seat availability and booking system
- β‘ Redis Caching - High-performance caching layer for improved response times
- π³ Docker Support - Containerized deployment ready
- βοΈ AWS Integration - ECS, S3, Kinesis Firehose, and Kibana integration
- π§ͺ Unit Testing - Comprehensive test coverage with Jest
- π Health Monitoring - Health check endpoints for container orchestration
- π Structured Logging - Centralized logging with AWS Kinesis Firehose
- Runtime: Node.js (v14+)
- Database: MongoDB - Primary data store
- Cache: Redis - Caching layer for performance optimization
- Authentication: JWT (JSON Web Tokens)
- Framework: Express.js
- Testing: Jest + Supertest
- Containerization: Docker
- Cloud Services:
- Amazon ECS - Container orchestration
- AWS S3 - File storage
- AWS Kinesis Firehose - Log streaming
- Kibana - Log visualization
- Node.js 14+ (recommended: Node.js 16)
- MongoDB instance (local or remote)
- Redis instance (local or remote)
- npm or yarn
-
Clone the repository
git clone https://github.com/LiteLife99/Nodejs-Mongo-POC.git cd Nodejs-Mongo-POC -
Install dependencies
npm install
-
Configure environment
Update
config/config.jsonwith your MongoDB and Redis connection details:{ "test": { "mongodb": { "MONGO_URI": "mongodb://localhost:27017/SukasaAir" }, "redis": { "host": "localhost", "port": 6379 } } }β οΈ Security Note: In production, use environment variables or AWS Secrets Manager instead of hardcoded config files. -
Start MongoDB and Redis
Ensure MongoDB and Redis are running on your system:
# MongoDB mongod # Redis redis-server
-
Run the application
# Production mode npm start # Development mode with auto-reload npm run dev # Custom port PORT=5000 npm start
The server will start on
http://localhost:8081(default port). -
Run tests
npm run test
The application follows a service-oriented architecture with clear separation of concerns:
loginService- Handles user authentication and JWT token generationflightService- Manages flight creation, scheduling, and flight data operationsseatService- Handles seat availability checks and booking operations
- Redis Cache - Caches frequently accessed MongoDB queries for improved performance
- Middleware - Authentication and logging middleware for request processing
- Routers - RESTful API endpoints organized by domain
- Models - MongoDB Mongoose schemas for data persistence
- Docker - Containerized application for consistent deployments
- Amazon ECS - Container orchestration and scaling
- Load Balancer - Request distribution across multiple instances
- Kibana - Centralized log aggregation and monitoring
POST /auth/login- User login and token generation
POST /flight/schedule- Create a new flight scheduleGET /flight/:id- Get flight details
GET /seat/:flightId- Get available seats for a flightPOST /seat/book- Book a seat
GET /healthCheck- Application health status
| Field | Type | Description |
|---|---|---|
| _id | ObjectId | Unique user ID |
| name | String | User's full name |
| String | Unique email address | |
| password | String | Encrypted password |
| Field | Type | Description |
|---|---|---|
| _id | ObjectId | Unique flight ID |
| airlines | String | Airline name |
| numOfSeats | Number | Total number of seats |
| numOfBookedSeats | Number | Number of booked seats |
| Field | Type | Description |
|---|---|---|
| _id | ObjectId | Unique seat ID |
| seatNumber | Number | Seat number |
| available | Boolean | Seat availability status |
| flightId | ObjectId | Reference to parent flight |
| passengerId | String | ID of passenger (if booked) |
| passengerName | String | Passenger name (if booked) |
| passengerAge | Number | Passenger age (if booked) |
| passengerPhone | Number | Passenger phone (if booked) |
SkyStack/
βββ __tests__/ # Unit tests
β βββ flights.test.js
β βββ seats.test.js
β βββ users.test.js
βββ config/ # Configuration files
β βββ config.json
βββ middleware/ # Express middleware
β βββ authMiddleware.js
β βββ loggerMiddleware.js
βββ mongodbModels/ # MongoDB schemas
β βββ connection.js
β βββ Flight.js
β βββ Seat.js
β βββ Users.js
βββ router/ # API routes
β βββ flightRouter.js
β βββ loginRouter.js
β βββ seatRouter.js
βββ services/ # Business logic
β βββ flightService.js
β βββ loginService.js
β βββ seatService.js
βββ utils/ # Utility functions
β βββ fetchDummyToken.js
β βββ firehoseUtil.js
β βββ redisUtil.js
βββ app.js # Express app configuration
βββ server.js # Server entry point
βββ Dockerfile # Docker configuration
βββ package.json
βββ README.md
- User sends credentials to
/auth/login - Server validates credentials and generates a JWT token
- Client stores the token and includes it in subsequent requests
- Protected routes validate the token using
Authorization: Bearer <token>header
docker build -t skystack-flight-booking .docker run -p 8081:8081 skystack-flight-bookingA docker-compose.yml file can be added to orchestrate MongoDB, Redis, and the application together.
- Health Checks:
/healthCheckendpoint for container health monitoring - Structured Logging: All logs are streamed to AWS Kinesis Firehose
- Log Visualization: Kibana dashboards for log analysis
- Request Logging: Middleware logs all incoming requests and responses
Run the test suite:
npm run testTests include:
- User authentication tests
- Flight management tests
- Seat booking tests
- Coverage reports
- Passwords are hashed using
bcryptjs - JWT tokens for stateless authentication
- CORS configured for cross-origin requests
- Environment-based configuration separation
- Important: Never commit production secrets to the repository
- Kafka event bus for inter-service communication
- CI/CD pipeline with GitHub Actions
- Swagger/OpenAPI documentation
- Docker Compose with production-grade configs
- Rate limiting middleware
- GraphQL API support
- WebSocket support for real-time updates
- Integration tests
- Performance benchmarking
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Arnab Mukherjee
Software Development Engineer | ML Enthusiast
4+ years experience in B2B, B2C, and B2B2C systems
Domains: Healthcare, Logistics, Transportation
This project is licensed under the MIT License.
- Express.js community
- MongoDB and Redis documentation
- AWS cloud services
