Django REST Framework API service for managing train station operations, including trains, routes, journeys, crew members, and ticket booking system.
- JWT Authentication for secure user access
- Admin Panel for managing train station operations
- CRUD Operations for stations, trains, routes, journeys, crews, and orders
- Advanced Filtering for trains (by train type) and routes (by source station)
- Ticket Booking System with seat validation and availability tracking
- Image Upload for train models
- API Documentation with Swagger and ReDoc
- Permissions System (Admin-only for modifications, authenticated users for read access)
- Clone the repository
git clone https://github.com/your-username/train-station-api.git
cd train-station-api- Create and activate virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies
pip install -r requirements.txt- Set up environment variables
Create a .env file in the project root (see .env.example):
# PostgreSQL settings
POSTGRES_USER=your_db_user
POSTGRES_PASSWORD=your_db_password
POSTGRES_DB=your_db_name
POSTGRES_HOST=db
POSTGRES_PORT=5432
PGDATA=/var/lib/postgresql/data
# Django settings
SECRET_KEY=your_django_secret_key
DEBUG=True- Apply migrations
python manage.py migrate- Run the development server
python manage.py runserverThe API will be available at http://127.0.0.1:8000/
- Build and run containers
docker-compose up --buildThe API will be available at http://127.0.0.1:8000/
You can use the following superuser account:
Email: admin@admin.com
Password: superuser
- Register a new user:
POST /api/user/register/
{
"email": "user@example.com",
"password": "securepassword123"
}- Get access token:
POST /api/user/token/
{
"email": "user@example.com",
"password": "securepassword123"
}- Use the token in requests:
Authorization: Bearer your-jwt-access-token-here
- Swagger UI:
http://127.0.0.1:8000/api/doc/swagger/ - ReDoc:
http://127.0.0.1:8000/api/doc/redoc/