
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
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
- Clone the repository
git clone <repository-url>
cd moviedbbackendservice-kduc3s
- Install dependencies
pip install -r requirements.txt
- Run database migrations
alembic upgrade head
- Start the server
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 filteringPOST /api/movies
: Create a new movieGET /api/movies/{movie_id}
: Get details of a specific moviePUT /api/movies/{movie_id}
: Update a movieDELETE /api/movies/{movie_id}
: Delete a movieGET /api/movies/search/{query}
: Search for movies by title or overview
Actors
GET /api/actors
: List all actors with pagination and filteringPOST /api/actors
: Create a new actorGET /api/actors/{actor_id}
: Get details of a specific actorPUT /api/actors/{actor_id}
: Update an actorDELETE /api/actors/{actor_id}
: Delete an actor
Directors
GET /api/directors
: List all directors with pagination and filteringPOST /api/directors
: Create a new directorGET /api/directors/{director_id}
: Get details of a specific directorPUT /api/directors/{director_id}
: Update a directorDELETE /api/directors/{director_id}
: Delete a director
Genres
GET /api/genres
: List all genres with pagination and filteringPOST /api/genres
: Create a new genreGET /api/genres/{genre_id}
: Get details of a specific genrePUT /api/genres/{genre_id}
: Update a genreDELETE /api/genres/{genre_id}
: Delete a genre
Description
Languages
Python
98.5%
Mako
1.5%