{"id":29442280,"url":"https://github.com/thejas01/airline-booking-system","last_synced_at":"2026-04-14T06:33:47.293Z","repository":{"id":302855061,"uuid":"1012892464","full_name":"thejas01/airline-booking-system","owner":"thejas01","description":"A modern, microservices-based flight booking system built with Spring Boot, React, and PostgreSQL. The system features JWT authentication, role-based authorization, and a clean, responsive user interface.","archived":false,"fork":false,"pushed_at":"2025-07-24T03:31:45.000Z","size":24081,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-24T06:53:12.666Z","etag":null,"topics":["java","jwt-authorization","microservices","reactjs","spring-boot"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thejas01.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-03T03:51:04.000Z","updated_at":"2025-07-24T03:31:49.000Z","dependencies_parsed_at":"2025-07-04T13:34:06.874Z","dependency_job_id":"c89498f8-2549-45b8-bc9c-271611cd7d32","html_url":"https://github.com/thejas01/airline-booking-system","commit_stats":null,"previous_names":["thejas01/airline-booking-system"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thejas01/airline-booking-system","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thejas01%2Fairline-booking-system","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thejas01%2Fairline-booking-system/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thejas01%2Fairline-booking-system/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thejas01%2Fairline-booking-system/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thejas01","download_url":"https://codeload.github.com/thejas01/airline-booking-system/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thejas01%2Fairline-booking-system/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31785677,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T02:24:21.117Z","status":"ssl_error","status_checked_at":"2026-04-14T02:24:20.627Z","response_time":153,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","jwt-authorization","microservices","reactjs","spring-boot"],"created_at":"2025-07-13T15:43:06.649Z","updated_at":"2026-04-14T06:33:47.289Z","avatar_url":"https://github.com/thejas01.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flight Booking System\n\nA modern, microservices-based flight booking system built with Spring Boot, React, and PostgreSQL. The system features JWT authentication, role-based authorization, and a clean, responsive user interface.\n\n## 🏗️ Architecture Overview\n\nThe system follows a microservices architecture with the following components:\n\n```\nbooking/\n├── api-gateway/          # API Gateway (Port: 8080)\n├── discovery-server/     # Eureka Service Discovery (Port: 8761)\n├── user-service/         # User Authentication Service (Port: 9091)\n├── flight-service/       # Flight Management Service (Port: 9092)\n└── frontend/             # React Frontend (Port: 5173)\n```\n\n## 🚀 Features\n\n- **User Authentication \u0026 Authorization**: JWT-based authentication with refresh tokens\n- **Role-Based Access Control**: ADMIN and USER roles with different permissions\n- **Flight Management**: Search, view, and add flights (ADMIN only)\n- **Microservices Architecture**: Scalable and maintainable service separation\n- **Modern Frontend**: React with TypeScript, responsive design\n- **API Gateway**: Centralized routing and request handling\n- **Service Discovery**: Eureka server for service registration\n\n## 🛠️ Technology Stack\n\n### Backend\n- **Spring Boot 3.5.0**\n- **Spring Security** - Authentication \u0026 Authorization\n- **Spring Data JPA** - Database ORM\n- **Spring Cloud Gateway** - API Gateway\n- **JWT (jjwt 0.9.1)** - Token-based authentication\n- **PostgreSQL** - Database\n- **Lombok** - Code generation\n- **ModelMapper** - Object mapping\n\n### Frontend\n- **React 19** - UI Framework\n- **TypeScript** - Type safety\n- **Vite** - Build tool\n- **React Router v6** - Routing\n- **Axios** - HTTP client\n- **Tailwind CSS** - Styling\n- **TanStack Query** - Data fetching\n- **Lucide React** - Icons\n\n## 📋 Prerequisites\n\n- **Java 17+**\n- **PostgreSQL** (running on port 5432)\n- **Node.js 18+**\n- **Maven**\n\n## ⚙️ Setup \u0026 Installation\n\n### 1. Database Setup\n\nCreate a PostgreSQL database:\n\n```sql\nCREATE DATABASE flight_app;\n```\n\nUpdate database credentials in both services' `application.yml` files if needed:\n\n```yaml\nspring:\n  datasource:\n    url: jdbc:postgresql://localhost:5432/flight_app\n    username: postgres\n    password: 123456\n```\n\n### 2. Running Services\n\nStart services in the following order:\n\n#### Discovery Server (Optional - currently disabled)\n```bash\ncd discovery-server\n./mvnw spring-boot:run\n```\n\n#### User Service\n```bash\ncd user-service\n./mvnw spring-boot:run\n```\n- Runs on: `http://localhost:9091`\n\n#### Flight Service\n```bash\ncd flight-service\n./mvnw spring-boot:run\n```\n- Runs on: `http://localhost:9092`\n\n#### API Gateway\n```bash\ncd api-gateway\n./mvnw spring-boot:run\n```\n- Runs on: `http://localhost:8080`\n\n#### Frontend\n```bash\ncd frontend\nnpm install\nnpm run dev\n```\n- Runs on: `http://localhost:5173`\n\n## 📡 API Documentation\n\n### User Service APIs\n\n**Base URL**: `http://localhost:9091`\n\n#### Authentication Endpoints\n\n| Method | Endpoint | Description | Request Body | Response |\n|--------|----------|-------------|--------------|----------|\n| POST | `/auth/create` | Register new user | `UserRequestDto` | `JwtResponse` |\n| POST | `/auth/login` | User login | `JwtRequest` | `JwtResponse` |\n| POST | `/auth/refresh-token` | Refresh access token | `RefreshTokenRequest` | `JwtResponse` |\n| GET | `/auth/logout` | Logout user | None | String message |\n| DELETE | `/auth/delete` | Delete user account | Query: `email` | String message |\n\n#### Request/Response Formats\n\n**UserRequestDto** (Registration):\n```json\n{\n  \"name\": \"John Doe\",\n  \"email\": \"john@example.com\",\n  \"password\": \"password123\",\n  \"role\": \"USER\"\n}\n```\n\n**JwtRequest** (Login):\n```json\n{\n  \"email\": \"john@example.com\",\n  \"password\": \"password123\"\n}\n```\n\n**JwtResponse**:\n```json\n{\n  \"token\": \"eyJhbGciOiJIUzUxMiJ9...\",\n  \"refreshToken\": \"refresh-token-here\"\n}\n```\n\n### Flight Service APIs\n\n**Base URL**: `http://localhost:9092`\n\n#### Flight Management Endpoints\n\n| Method | Endpoint | Description | Required Role | Request Body | Response |\n|--------|----------|-------------|---------------|--------------|----------|\n| GET | `/api/flights/search` | Search flights | USER, ADMIN | Query params | `List\u003cFlight\u003e` |\n| POST | `/api/flights/add` | Add new flight | ADMIN only | `Flight` | String message |\n| GET | `/api/flights` | Get all flights | USER, ADMIN | None | `List\u003cFlight\u003e` |\n\n#### Search Flights Query Parameters\n- `source`: Departure city (string)\n- `destination`: Arrival city (string)  \n- `date`: Departure date (YYYY-MM-DD)\n\n**Example**: `/api/flights/search?source=Mumbai\u0026destination=Delhi\u0026date=2024-01-15`\n\n#### Flight Entity Format\n```json\n{\n  \"id\": 1,\n  \"airline\": \"Air India\",\n  \"source\": \"Mumbai\",\n  \"destination\": \"Delhi\",\n  \"departureDate\": \"2024-01-15\",\n  \"departureTime\": \"09:30\",\n  \"availableSeats\": 150,\n  \"price\": 5500.0\n}\n```\n\n## 🔐 Security \u0026 Authentication\n\n### JWT Token Configuration\n- **Token Validity**: 5 hours\n- **Algorithm**: HS512\n- **Claims**: username (email), role\n\n### Role-Based Access Control\n\n#### User Roles\n- **USER**: Can search and view flights\n- **ADMIN**: Can perform all operations including adding flights\n\n#### Protected Endpoints\n- **Flight Search/View**: Requires USER or ADMIN role\n- **Add Flight**: Requires ADMIN role only\n\n### Authentication Flow\n\n1. **Register/Login** → Receive JWT access token + refresh token\n2. **Include JWT** in Authorization header: `Bearer \u003ctoken\u003e`\n3. **Token Validation** → Services validate JWT and extract user role\n4. **Access Control** → Grant/deny access based on role permissions\n\n## 🗄️ Database Schema\n\n### User Entity\n```sql\nTable: userDb\n- id: BIGINT (Primary Key, Auto-generated)\n- name: VARCHAR\n- email: VARCHAR (Unique, Not Null)\n- password: VARCHAR (Encrypted)\n- role: VARCHAR (USER/ADMIN)\n```\n\n### Flight Entity\n```sql\nTable: flight\n- id: BIGINT (Primary Key, Auto-generated)\n- airline: VARCHAR\n- source: VARCHAR\n- destination: VARCHAR\n- departure_date: DATE\n- departure_time: VARCHAR\n- available_seats: INTEGER\n- price: DOUBLE\n```\n\n## 🌐 Service Ports\n\n| Service | Port | Description |\n|---------|------|-------------|\n| Discovery Server | 8761 | Eureka Service Registry |\n| API Gateway | 8080 | Request routing |\n| User Service | 9091 | Authentication \u0026 user management |\n| Flight Service | 9092 | Flight operations |\n| Frontend | 5173 | React application |\n\n## 🚦 API Gateway Routes\n\nThe API Gateway routes requests to appropriate microservices:\n\n- `/api/users/**` → User Service (Port 9091)\n- `/api/flights/**` → Flight Service (Port 9092)\n\n## 🔧 Configuration\n\n### Application Properties\n\nEach service has its own `application.yml` with service-specific configurations:\n\n```yaml\n# Common database configuration\nspring:\n  datasource:\n    url: jdbc:postgresql://localhost:5432/flight_app\n    username: postgres\n    password: 123456\n    driver-class-name: org.postgresql.Driver\n  jpa:\n    hibernate:\n      ddl-auto: update\n    show-sql: true\n```\n\n## 🧪 Testing the System\n\n### 1. Create Admin User\n```bash\ncurl -X POST http://localhost:9091/auth/create \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"name\": \"Admin User\",\n    \"email\": \"admin@example.com\",\n    \"password\": \"admin123\",\n    \"role\": \"ADMIN\"\n  }'\n```\n\n### 2. Login as Admin\n```bash\ncurl -X POST http://localhost:9091/auth/login \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"email\": \"admin@example.com\",\n    \"password\": \"admin123\"\n  }'\n```\n\n### 3. Add Flight (ADMIN only)\n```bash\ncurl -X POST http://localhost:9092/api/flights/add \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Authorization: Bearer YOUR_JWT_TOKEN\" \\\n  -d '{\n    \"airline\": \"Air India\",\n    \"source\": \"Mumbai\",\n    \"destination\": \"Delhi\",\n    \"departureDate\": \"2024-01-15\",\n    \"departureTime\": \"09:30\",\n    \"availableSeats\": 150,\n    \"price\": 5500.0\n  }'\n```\n\n### 4. Search Flights\n```bash\ncurl \"http://localhost:9092/api/flights/search?source=Mumbai\u0026destination=Delhi\u0026date=2024-01-15\" \\\n  -H \"Authorization: Bearer YOUR_JWT_TOKEN\"\n```\n\n## 🚀 Deployment\n\nThe system is designed for containerization and cloud deployment:\n\n1. **Docker**: Each service can be containerized\n2. **Kubernetes**: Supports orchestration with service discovery\n3. **Cloud Platforms**: Compatible with AWS, Azure, GCP\n\n## 🤝 Contributing\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## 📝 License\n\nThis project is licensed under the MIT License.\n\n## 📞 Support\n\nFor support and questions, please open an issue in the repository.\n\n---\n\n**Happy Coding! ✈️**\n\nLet me know if you'd like to:\n\nPrevent duplicate cancellations\n\nAdd audit logs for cancellations\n\nOr make the Flight update endpoint private for Booking Service only?\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthejas01%2Fairline-booking-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthejas01%2Fairline-booking-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthejas01%2Fairline-booking-system/lists"}