Loading repository data…
Loading repository data…
Anshu2607-iiitr / repository
A full-stack IRCTC-inspired railway reservation system built with Java, Spring Boot, Spring Security, JPA, H2 Database, and HTML/CSS/JavaScript.
A Java Spring Boot + vanilla HTML/CSS/JS train booking system, built as a portfolio/learning project. Not affiliated with or endorsed by Indian Railways / IRCTC — it just borrows the familiar workflow (search → book → PNR) as a realistic project to build.
src/main/resources/static), calling the REST API with fetchROLE_USER / ROLE_ADMINIRCTC_/
├── settings.gradle
├── build.gradle (root — empty, config lives in app/)
├── gradlew / gradlew.bat
└── app/
├── build.gradle (Spring Boot dependencies)
└── src/main/
├── java/com/irctc/
│ ├── IrctcApplication.java
│ ├── model/ (User, Train, TrainAvailability, Booking, enums)
│ ├── repository/ (Spring Data JPA repositories)
│ ├── service/ (UserService, TrainService, BookingService, PnrGenerator)
│ ├── controller/ (AuthController, TrainController, BookingController, AdminController)
│ ├── security/ (SecurityConfig, UserDetailsService, JSON auth handlers)
│ ├── config/ (DataSeeder — creates a demo admin + sample trains on startup)
│ ├── dto/ (request/response objects)
│ └── exception/ (GlobalExceptionHandler → clean JSON error responses)
└── resources/
├── application.properties
└── static/
├── index.html (search trains)
├── css/style.css
├── js/{api.js, search.js, admin.js}
└── pages/{login, signup, my-bookings, pnr-status, admin, booking-confirmation}.html
gradle/wrapper/gradle-wrapper.jar is missing
(only the .properties file is included here), generate it once with a local Gradle install:
gradle wrapper --gradle-version 8.10
./gradlew bootRun # macOS/Linux
gradlew.bat bootRun # Windows
On first startup, DataSeeder creates:
admin@irctc.com / admin123You can inspect the H2 database directly at http://localhost:8080/h2-console
(JDBC URL: jdbc:h2:mem:irctcdb, user sa, no password).
fetch with session cookies. A production version should either issue a CSRF
token to the frontend, or move to token-based (JWT) auth.application.properties for MySQL/Postgres to persist data.| Method | Path | Auth | Description |
|---|---|---|---|
| POST | /api/auth/signup | Public | Create a user account |
| POST | /api/auth/login | Public | Log in (form-encoded email/password) |
| POST | /api/auth/logout | Logged in | Log out |
| GET | /api/auth/me | Logged in | Current user info |
| GET | /api/trains/search | Public | ?source=&destination=&date=YYYY-MM-DD |
| POST | /api/bookings | Logged in | Book seats |
| POST | /api/bookings/{pnr}/cancel | Owner/Admin | Cancel a booking |
| GET | /api/bookings/pnr/{pnr} | Public | Look up booking by PNR |
| GET | /api/bookings/my | Logged in | Your bookings |
| POST | /api/admin/trains | Admin | Add a train |
| GET | /api/admin/trains | Admin | List all trains |
| GET | /api/admin/bookings | Admin | List all bookings |
| POST | /api/admin/bookings/{pnr}/cancel | Admin | Cancel any booking |