TheatreAPI is a RESTful API for managing a theater system. It provides endpoints for managing users, plays, actors, genres, theatre halls, performances, and ticket orders. Built with Django REST Framework and JWT authentication.
- Python 3.11+
- Django 5.x
- Django REST Framework
- drf-spectacular (Swagger / OpenAPI)
- PostgreSQL 17
- Docker (optional)
- JWT authentication (djangorestframework-simplejwt)
Since the project includes Dockerfile and docker-compose, you can run everything with Docker:
- Build and start containers
docker-compose up --build- Apply database migrations
docker-compose exec web python manage.py migrate- Create a superuser
docker-compose exec web python manage.py createsuperuser- Access the application
- Django server: http://127.0.0.1:8000
- Swagger UI: http://127.0.0.1:8000/api/doc/swagger/
- Redoc: http://127.0.0.1:8000/api/doc/redoc/
- web: Django application
- db: PostgreSQL databas
The docker-compose.yml automatically links the web and db services, so Django connects to the database using the service name db.
erDiagram
USER {
int id PK
string email
string password
bool is_staff
bool is_superuser
datetime date_joined
}
PLAY {
int id PK
string title
text description
}
ACTOR {
int id PK
string first_name
string last_name
}
GENRE {
int id PK
string name
}
THEATREHALL {
int id PK
string name
int rows
int seat_in_row
}
PERFORMANCE {
int id PK
datetime show_time
int play_id FK
int theatre_hall_id FK
}
ORDER {
int id PK
datetime created_at
int user_id FK
}
TICKET {
int id PK
int row
int seat_in_row
int performance_id FK
int order_id FK
}
PLAY ||--o{ ACTOR : "many-to-many"
PLAY ||--o{ GENRE : "many-to-many"
PERFORMANCE }o--|| PLAY : "belongs to"
PERFORMANCE }o--|| THEATREHALL : "in"
ORDER }o--|| USER : "belongs to"
TICKET }o--|| PERFORMANCE : "for"
TICKET }o--|| ORDER : "belongs to"
| Endpoint | Method | Description |
|---|---|---|
/api/user/register/ |
POST | Register a new user |
/api/user/token/ |
POST | Get access and refresh tokens |
/api/user/token/refresh/ |
POST | Refresh access token |
/api/user/me/ |
GET, PUT, PATCH | Retrieve or update authenticated user's profile |
- GET /api/theatre/play/ – list all plays
- GET /api/theatre/play/{id}/ – play details
- POST /api/theatre/play/ – create a play (admin)
- PUT/PATCH/DELETE /api/theatre/play/{id}/ – update/delete (admin)
- GET /api/theatre/actor/
- GET /api/theatre/actor/{id}/
- POST/PUT/PATCH/DELETE – admin only
- GET /api/theatre/genre/
- GET /api/theatre/genre/{id}/
- POST/PUT/PATCH/DELETE – admin only
- GET /api/theatre/theatrehall/
- GET /api/theatre/theatrehall/{id}/
- POST/PUT/PATCH/DELETE – admin only
- GET /api/theatre/performance/
- GET /api/theatre/performance/{id}/
- POST/PUT/PATCH/DELETE – admin only
- GET /api/theatre/order/ – list user orders
- POST /api/theatre/order/ – create an order with tickets
- Swagger UI: http://127.0.0.1:8000/api/doc/swagger/
- Redoc: http://127.0.0.1:8000/api/doc/redoc/