This project is a Movie Listing API built with FastAPI. The API allows users to list movies, view listed movies, rate them, and add comments. The application is secured using JWT (JSON Web Tokens), ensuring that only the user who listed a movie can edit or delete it. The application is also deployed on a cloud platform(Render), making it accessible publicly.
- Users can register by providing a username and password.
- Registered users can log in to receive a JWT token.
- JWT Token Generation: After logging in, users receive a JWT token for authentication.
- View a Movie: Anyone can view details of a listed movie.
- Authenticated users can add new movies.
- Anyone can view the list of all movies.
- Only the user who listed the movie can edit its details.
- Only the user who listed the movie can delete it.
- Authenticated users can rate movies.
- Anyone can view ratings for a movie.
- Authenticated users can add comments to movies.
- Anyone can view comments for a movie.
- Authenticated users can reply to existing comments, creating nested comments.
- Python with FastAPI
- JWT for securing endpoints
- SQLAlchemy ORM with support for SQL databases
- Unit tests for API endpoints using pytest
- OpenAPI/Swagger for API documentation
- Integrated logging for important application details using PaperTrail logging
- Deployed on Render
- Python 3.7+
- An SQL database (PostgreSQL, MySQL, SQLite, etc.)
- Git (for version control)
- Clone the Repository:
git clone https://github.com/yourusername/movie_listing_api.gitcd movie_listing_api- Create and Activate a Virtual Environment:
python -m venv environment_name
source environment_name/bin/activate - Install Dependencies:
pip install -r requirements.txt- Set Up Database:
alembic upgrade head- Run the Application:
uvicorn app.main:app --reload- Access the API Documentation:
- Visit
http://127.0.0.1:8000/docsto explore the API with Swagger UI.
To run unit tests, use the following command:
pytest- JWT tokens are used to secure endpoints.
- Only authenticated users can perform operations like adding, editing, or deleting movies and comments.
- Ensure you change the SECRET_KEY in production to a strong, unique value.