A modern RESTful API for managing theater resources including performances, reservations, and user accounts.
The Theater API provides a complete backend solution for theater management systems. It allows for managing theater performances, handling ticket reservations, and user authentication/authorization. Built with Django and Django REST Framework, it follows best practices for security, documentation, and API design.
- User Management: Registration, authentication, and profile management
- Performance Management: Create, read, update, and delete theater performances
- Reservation System: Book tickets and manage reservations
- Admin Dashboard: Administrative interface for theater management
- API Documentation: Comprehensive documentation with drf-spectacular
- Permissions: Role-based access control for different user types
- Framework: Django, Django REST Framework
- Database: PostgreSQL
- Documentation: drf-spectacular (OpenAPI 3.0)
- Authentication: JWT (JSON Web Tokens)
- Testing: Django Test Framework
- Python 3.8+
- PostgreSQL
- pip
-
Clone the repository:
git clone https://github.com/IvankaKuzin/theater-api.git cd theater-api -
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Configure environment variables:
- Create a
.envfile based on.env.sample - Set your database credentials and other configuration options
- Create a
If you chose local settings file:
-
Apply migrations:
python manage.py migrate
-
Create a superuser:
python manage.py createsuperuser
-
Run the development server:
python manage.py runserver
If you chose docker settings file:
-
Build and start the Docker containers:
docker-compose build docker-compose up -d
-
Apply migrations:
docker-compose exec web python manage.py migrate -
Create a superuser:
docker-compose exec web python manage.py createsuperuser -
Access the API at http://localhost:8000/api/
Make the following changes to your .env file:
# Database settings
POSTGRES_PASSWORD=your_database_password
POSTGRES_USER=your_database_user
POSTGRES_DB=theater_db
POSTGRES_HOST=db
POSTGRES_PORT=5432
PGDATA=/var/lib/postgresql/data
# Django settings
DJANGO_SECRET_KEY=your_secure_secret_key
DJANGO_SETTINGS_MODULE=path_to_settings_file # Use theatre_service.settings.docker for Docker, theatre_service.settings.local for local development
Once the server is running, you can access the API documentation at:
- Swagger UI:
http://localhost:8000/api/schema/swagger-ui/ - ReDoc:
http://localhost:8000/api/schema/redoc/
POST /api/user/register/- Register a new userPOST /api/user/token/- Obtain authentication tokensGET/PUT/PATCH /api/user/me/- Retrieve or update authenticated user profile
GET /api/theater/performances/- List all performancesPOST /api/theater/performances/- Create a new performance (admin only)GET /api/theater/performances/{id}/- Retrieve performance detailsPUT/PATCH /api/theater/performances/{id}/- Update a performance (admin only)DELETE /api/theater/performances/{id}/- Delete a performance (admin only)
GET /api/theater/genres/- List all genresPOST /api/theater/genres/- Create a new genre (admin only)GET /api/theater/genres/{id}/- Retrieve genre detailsPUT/PATCH /api/theater/genres/{id}/- Update a genre (admin only)DELETE /api/theater/genres/{id}/- Delete a genre (admin only)
GET /api/theater/actors/- List all actorsPOST /api/theater/actors/- Add a new actor (admin only)GET /api/theater/actors/{id}/- Retrieve actor detailsPUT/PATCH /api/theater/actors/{id}/- Update actor information (admin only)DELETE /api/theater/actors/{id}/- Remove an actor (admin only)
GET /api/theater/plays/- List all playsPOST /api/theater/plays/- Create a new play (admin only)GET /api/theater/plays/{id}/- Retrieve play detailsPUT/PATCH /api/theater/plays/{id}/- Update a play (admin only)DELETE /api/theater/plays/{id}/- Delete a play (admin only)
GET /api/theater/theatre-halls/- List all theatre hallsPOST /api/theater/theatre-halls/- Create a new theatre hall (admin only)GET /api/theater/theatre-halls/{id}/- Retrieve theatre hall detailsPUT/PATCH /api/theater/theatre-halls/{id}/- Update a theatre hall (admin only)DELETE /api/theater/theatre-halls/{id}/- Delete a theatre hall (admin only)
GET /api/theater/reservations/- List user's reservationsPOST /api/theater/reservations/- Create a new reservationGET /api/theater/reservations/{id}/- Retrieve reservation detailsDELETE /api/theater/reservations/{id}/- Cancel a reservation
Run the test suite:
python manage.py test- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Project Link: https://github.com/IvankaKuzin/theater-api