
This commit implements a simple movie database backend inspired by IMDb. It includes: - API endpoints for movies, actors, directors and genres - SQLAlchemy models with relationships - Alembic migrations - Pydantic schemas for request/response validation - Search and filtering functionality - Health check endpoint - Complete documentation
112 lines
3.1 KiB
Markdown
112 lines
3.1 KiB
Markdown
# Movie Database API
|
|
|
|
A simple backend for a movie website inspired by IMDb, built with FastAPI and SQLite.
|
|
|
|
## Features
|
|
|
|
- **Movies**: Create, read, update, and delete movie information
|
|
- **Actors**: Manage actor profiles and their roles in movies
|
|
- **Directors**: Manage director profiles and their filmography
|
|
- **Genres**: Categorize movies by genre
|
|
- **Search**: Search for movies by title or overview
|
|
- **Filtering**: Filter movies by various criteria (title, director, actor, genre, rating, year)
|
|
|
|
## Technical Stack
|
|
|
|
- **Framework**: FastAPI
|
|
- **Database**: SQLite with SQLAlchemy ORM
|
|
- **Migrations**: Alembic
|
|
- **Validation**: Pydantic
|
|
- **Linting**: Ruff
|
|
|
|
## Getting Started
|
|
|
|
### Prerequisites
|
|
|
|
- Python 3.8 or higher
|
|
|
|
### Installation
|
|
|
|
1. Clone the repository
|
|
|
|
```bash
|
|
git clone <repository-url>
|
|
cd moviedbbackendservice-kduc3s
|
|
```
|
|
|
|
2. Install dependencies
|
|
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
3. Run database migrations
|
|
|
|
```bash
|
|
alembic upgrade head
|
|
```
|
|
|
|
4. Start the server
|
|
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
The API will be available at http://localhost:8000
|
|
|
|
## API Documentation
|
|
|
|
Once the server is running, you can access the interactive API documentation:
|
|
|
|
- Swagger UI: http://localhost:8000/docs
|
|
- ReDoc: http://localhost:8000/redoc
|
|
|
|
## Database Schema
|
|
|
|
The application uses the following database schema:
|
|
|
|
- **Movie**: Stores movie information (title, release date, overview, poster, runtime, rating)
|
|
- **Actor**: Stores actor information (name, birth date, bio, photo)
|
|
- **Director**: Stores director information (name, birth date, bio, photo)
|
|
- **Genre**: Stores genre categories (name)
|
|
- **MovieActor**: Junction table for the many-to-many relationship between movies and actors
|
|
- **MovieGenre**: Junction table for the many-to-many relationship between movies and genres
|
|
|
|
## API Endpoints
|
|
|
|
### Health Check
|
|
|
|
- `GET /health`: Check the health status of the API
|
|
|
|
### Movies
|
|
|
|
- `GET /api/movies`: List all movies with pagination and filtering
|
|
- `POST /api/movies`: Create a new movie
|
|
- `GET /api/movies/{movie_id}`: Get details of a specific movie
|
|
- `PUT /api/movies/{movie_id}`: Update a movie
|
|
- `DELETE /api/movies/{movie_id}`: Delete a movie
|
|
- `GET /api/movies/search/{query}`: Search for movies by title or overview
|
|
|
|
### Actors
|
|
|
|
- `GET /api/actors`: List all actors with pagination and filtering
|
|
- `POST /api/actors`: Create a new actor
|
|
- `GET /api/actors/{actor_id}`: Get details of a specific actor
|
|
- `PUT /api/actors/{actor_id}`: Update an actor
|
|
- `DELETE /api/actors/{actor_id}`: Delete an actor
|
|
|
|
### Directors
|
|
|
|
- `GET /api/directors`: List all directors with pagination and filtering
|
|
- `POST /api/directors`: Create a new director
|
|
- `GET /api/directors/{director_id}`: Get details of a specific director
|
|
- `PUT /api/directors/{director_id}`: Update a director
|
|
- `DELETE /api/directors/{director_id}`: Delete a director
|
|
|
|
### Genres
|
|
|
|
- `GET /api/genres`: List all genres with pagination and filtering
|
|
- `POST /api/genres`: Create a new genre
|
|
- `GET /api/genres/{genre_id}`: Get details of a specific genre
|
|
- `PUT /api/genres/{genre_id}`: Update a genre
|
|
- `DELETE /api/genres/{genre_id}`: Delete a genre |