Skip to content

folg-code/django-event-ticketing-api

Repository files navigation

TheatreAPI

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.


📦 Technologies

  • Python 3.11+
  • Django 5.x
  • Django REST Framework
  • drf-spectacular (Swagger / OpenAPI)
  • PostgreSQL 17
  • Docker (optional)
  • JWT authentication (djangorestframework-simplejwt)

🚀 Local Installation (Docker)

Since the project includes Dockerfile and docker-compose, you can run everything with Docker:

  1. Build and start containers
docker-compose up --build
  1. Apply database migrations
docker-compose exec web python manage.py migrate
  1. Create a superuser
docker-compose exec web python manage.py createsuperuser
  1. Access the application

🐳 Docker Compose Services

- 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.

📊 Diagram

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"
Loading

🔐 Authentication

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

🎭 API Endpoints

Play

  • 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)

Actor

  • GET /api/theatre/actor/
  • GET /api/theatre/actor/{id}/
  • POST/PUT/PATCH/DELETE – admin only

Genre

  • GET /api/theatre/genre/
  • GET /api/theatre/genre/{id}/
  • POST/PUT/PATCH/DELETE – admin only

Theatre Hall

  • GET /api/theatre/theatrehall/
  • GET /api/theatre/theatrehall/{id}/
  • POST/PUT/PATCH/DELETE – admin only

Performance

  • GET /api/theatre/performance/
  • GET /api/theatre/performance/{id}/
  • POST/PUT/PATCH/DELETE – admin only

Order

  • GET /api/theatre/order/ – list user orders
  • POST /api/theatre/order/ – create an order with tickets

📝 API Documentation

- Swagger UI: http://127.0.0.1:8000/api/doc/swagger/
- Redoc: http://127.0.0.1:8000/api/doc/redoc/

About

Project for managing theatre with django DB API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors