This project implements a modern, scalable flight booking system using microservices architecture. The system consists of multiple services that handle different aspects of flight booking, from searching flights to managing bookings and sending notifications.
-
Booking Service (Port: 8081)
- Handles flight searches and booking management
- Integrates with AviationStack API for real-time flight data
- Manages booking creation and retrieval
- Communicates with Notification Service via RabbitMQ
-
Notification Service (Port: 8082)
- Handles email notifications for booking confirmations
- Processes booking events from RabbitMQ
- Sends confirmation emails to customers
-
Frontend Service (Port: 3000)
- React-based user interface
- Provides intuitive booking experience
- Real-time flight search and booking management
-
PostgreSQL Database
- Stores booking and user data
- Runs on port 5432
- Database name: flightbooking
- Default credentials:
- Username: postgres
- Password: password
-
RabbitMQ
- Message broker for inter-service communication
- Runs on port 5672
- Management interface on port 15672
- Default credentials:
- Username: admin
- Password: admin
- Java 17
- Spring Boot 3.x
- Spring Data JPA
- Spring WebFlux
- PostgreSQL
- RabbitMQ
- Maven
- React
- TypeScript
- Material-UI
- Axios
- Docker
- Docker Compose
- Git
All endpoints are prefixed with /api
-
Search Flights
POST /flights/search Content-Type: application/json Request: { "fromCity": "new york", "toCity": "london" } Response: { "flights": [ { "flightNumber": "AA123", "airline": "American Airlines", "departureCity": "New York", "arrivalCity": "London", "departureTime": "2024-03-20T10:00:00", "arrivalTime": "2024-03-20T22:00:00", "price": 499.99 } ] } -
Create Booking
POST /bookings Content-Type: application/json Request: { "flightNumber": "AA123", "passengerName": "John Doe", "passengerEmail": "john@example.com", "departureDate": "2024-03-20" } Response: { "id": 1, "flightNumber": "AA123", "passengerName": "John Doe", "passengerEmail": "john@example.com", "departureDate": "2024-03-20", "bookingDate": "2024-03-15T14:30:00", "status": "CONFIRMED" } -
Get All Bookings
GET /bookings Response: [ { "id": 1, "flightNumber": "AA123", "passengerName": "John Doe", "passengerEmail": "john@example.com", "departureDate": "2024-03-20", "bookingDate": "2024-03-15T14:30:00", "status": "CONFIRMED" } ] -
Get Booking by ID
GET /bookings/{id} Response: { "id": 1, "flightNumber": "AA123", "passengerName": "John Doe", "passengerEmail": "john@example.com", "departureDate": "2024-03-20", "bookingDate": "2024-03-15T14:30:00", "status": "CONFIRMED" } -
Get Bookings by Email
GET /bookings/email/{email} Response: [ { "id": 1, "flightNumber": "AA123", "passengerName": "John Doe", "passengerEmail": "john@example.com", "departureDate": "2024-03-20", "bookingDate": "2024-03-15T14:30:00", "status": "CONFIRMED" } ] -
Get Supported Cities
GET /cities Response: { "cities": [ "New York", "London", "Paris", "Tokyo", "Sydney" ] }
-
Send Email Notification
POST /api/notifications/email Content-Type: application/json Request: { "to": "john@example.com", "subject": "Flight Booking Confirmation", "body": "Your flight booking has been confirmed..." } Response: { "status": "SENT", "message": "Email notification sent successfully" } -
Get Notification Status
GET /api/notifications/{id} Response: { "id": 1, "status": "SENT", "sentAt": "2024-03-15T14:30:00", "recipient": "john@example.com" }
All endpoints may return the following error responses:
-
400 Bad Request
{ "error": "Bad Request", "message": "Invalid input parameters", "timestamp": "2024-03-15T14:30:00" } -
404 Not Found
{ "error": "Not Found", "message": "Resource not found", "timestamp": "2024-03-15T14:30:00" } -
500 Internal Server Error
{ "error": "Internal Server Error", "message": "An unexpected error occurred", "timestamp": "2024-03-15T14:30:00" }
CREATE TABLE bookings (
id BIGSERIAL PRIMARY KEY,
flight_number VARCHAR(10) NOT NULL,
passenger_name VARCHAR(100) NOT NULL,
passenger_email VARCHAR(100) NOT NULL,
departure_date DATE NOT NULL,
booking_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
status VARCHAR(20) DEFAULT 'CONFIRMED'
);- Docker and Docker Compose
- Java 17
- Maven
- Node.js and npm (for frontend)
Create a .env file in the project root:
AVIATIONSTACK_API_KEY=your_api_key
EMAIL_USERNAME=your_email
EMAIL_PASSWORD=your_email_password
-
Start all services:
docker-compose up --build
-
Access the services:
- Frontend: http://localhost:3000
- Booking Service: http://localhost:8081
- Notification Service: http://localhost:8082
- RabbitMQ Management: http://localhost:15672
- Clone the repository
- Set up environment variables
- Run services individually for development:
# Booking Service cd booking-service mvn spring-boot:run # Notification Service cd notification-service mvn spring-boot:run # Frontend cd frontend npm install npm start
-
Connect to PostgreSQL:
docker exec -it flightservice-postgres-1 psql -U postgres -d flightbooking -
View tables:
\dt
-
View table structure:
\d table_name
Use the provided Postman collection or test endpoints using curl:
# Search flights
curl -X POST http://localhost:8081/api/flights/search \
-H "Content-Type: application/json" \
-d '{"fromCity":"new york","toCity":"london"}'
# Create booking
curl -X POST http://localhost:8081/api/bookings \
-H "Content-Type: application/json" \
-d '{"flightNumber":"AA123","passengerName":"John Doe","passengerEmail":"john@example.com","departureDate":"2024-03-20"}'-
API Security
- Environment variables for sensitive data
- Input validation
- Error handling
-
Database Security
- Secure password storage
- Connection encryption
- Access control
-
Communication Security
- HTTPS for API endpoints
- Secure email configuration
- Message encryption
-
Application Logs
- Spring Boot logging
- Docker container logs
- Error tracking
-
Performance Monitoring
- Service health checks
- Response time monitoring
- Resource utilization
-
Planned Features
- User authentication and authorization
- Payment integration
- Flight schedule management
- Admin dashboard
-
Technical Improvements
- Service discovery
- API gateway
- Circuit breakers
- Caching layer
-
Database Connection
- Check PostgreSQL container status
- Verify credentials
- Check port availability
-
RabbitMQ Issues
- Verify service connectivity
- Check queue status
- Monitor message flow
-
API Integration
- Validate API keys
- Check service health
- Verify request/response format
- Fork the repository
- Create a feature branch
- Commit changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support or queries, please contact the development team.