API for searching and managing movies and blog posts.
The project is hosted on the following infrastructure:
- Backend: Flask application hosted on Heroku
- Image Storage: Amazon S3 for blog post image storage
- Database: MongoDB Atlas for data persistence
movie-search-blog-backend/
βββ app.py # Main application
βββ config.py # Configurations (MongoDB, AWS, etc)
βββ requirements.txt # Project dependencies
βββ favorites/ # Favorite movies module
β βββ init.py
β βββ controller.py # Business logic
β βββ models.py # Swagger models
β βββ routes.py # API routes
βββ blogposts/ # Blog posts module
βββ init.py
βββ controller.py # Business logic
βββ models.py # Swagger models
βββ routes.py # API routes
Swagger documentation is available at http://localhost:5000/docs
- Development: http://localhost:5000
- Production: https://your-app.herokuapp.com
- POST /api/favorites/search - Search favorite movies
- GET /api/favorites/tconst - Get a favorite movie
- POST /api/favorites/tconst - Add a movie to favorites
- PUT /api/favorites/tconst - Update a favorite movie
- DELETE /api/favorites/tconst - Remove a movie from favorites
- POST /api/blogposts/search - Search blog posts
- GET /api/blogposts/tconst - Get a specific post
- GET /api/blogposts/images/tconst - Get images of a post
python -m venv venv
source venv/bin/activate
venv\Scripts\activate
pip install -r requirements.txt
Create a .env
file in the root of the project and define the following variables:
-
MongoDB:
MONGODB_CONNECTION_STRING
: MongoDB connection string.MONGODB_DATABASE
: MongoDB database name.
-
AWS S3:
AWS_ACCESS_KEY_ID
: AWS access key ID.AWS_SECRET_ACCESS_KEY
: AWS secret access key.BUCKET_NAME
: S3 bucket name.
Example .env
file:
MONGODB_CONNECTION_STRING="mongodb+srv://<username>:<password>@cluster0.mongodb.net/"
MONGODB_DATABASE="movie-search"
AWS_ACCESS_KEY_ID="your-access-key-id"
AWS_SECRET_ACCESS_KEY="your-secret-access-key"
BUCKET_NAME="your-bucket-name"
python app.py
Each module (favorites and blogposts) follows the same structure:
- models.py: Defines Swagger models for API documentation
- routes.py: Defines API routes and endpoints
- controller.py: Contains business logic and database interaction
- Flask: Web framework
- Flask-RESTX: Extension for RESTful APIs and Swagger documentation
- PyMongo: MongoDB driver
- Boto3: AWS SDK for Python
- Python-dotenv: Environment variable management