Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/saadarazzaq/product-reviews-api

Dockerized Amazon Product Reviews CRUD API with MongoDB ⚡️🛢
https://github.com/saadarazzaq/product-reviews-api

beanie-odm crud docker fastapi mongo-jamie mongodb

Last synced: 1 day ago
JSON representation

Dockerized Amazon Product Reviews CRUD API with MongoDB ⚡️🛢

Awesome Lists containing this project

README

        

# Product-Reviews 📝

This project demonstrates a FastAPI application using Beanie ODM (Object Document Mapper) for MongoDB. The project is containerized using Docker and Docker Compose for easy setup and deployment.

## Project Demonstration 📹

[![Product Reviews API](https://github.com/SaadARazzaq/Product-Reviews-API/assets/123338307/7960274c-5ac1-4726-96d2-367c99bf0896)](https://www.loom.com/share/bd94945efe2242eb8bbeda4b5ff4ec7a?sid=25e23587-d6e6-4b2e-b681-113c20004a93)

## Project Structure 🧱

Screenshot 2024-06-30 at 4 02 42 AM
Screenshot 2024-06-30 at 3 57 41 AM

- **app/server/models/product_review.py**: Defines the `ProductReview` and `UpdateProductReview` models using `Beanie` and `Pydantic`.
- **app/server/routes/product_review.py**: Contains the `API routes` for handling product reviews.
- **app/server/app.py**: The main `FastAPI` application setup, including `route inclusion` and `database initialization`.
- **app/server/database.py**: Contains the `database initialization logic`.
- **main.py**: The entry point for running the `Uvicorn server`.
- **Dockerfile**: The `Dockerfile` for building the FastAPI application image.
- **docker-compose.yml**: `Docker Compose file` for setting up the `FastAPI` and `MongoDB services`.
- **requirements.txt**: Python dependencies required for the project.

## Getting Started 🏃

### Prerequisites 📋

- `Docker Desktop` installed and up and running on your machine.

### Installation 🛠️

1. Clone the repository:

```sh
git clone https://github.com/SaadARazzaq/Product-Reviews-API
cd fastapi-beanie
```

2. Build and start the Docker containers:

```sh
docker-compose up --build
```

3. The FastAPI application will be available at `http://localhost:8000`.

### API Endpoints ⚡

Screenshot 2024-06-30 at 4 08 40 AM

### Example Product Review Model Schema 🧩

```json
{
"name": "Saad Abdur Razzaq",
"title": "MacBook Air M2",
"rating": 5.0,
"review": "Best Laptop in the world",
"date": "2023-06-30T12:34:56.789Z"
}
```

### Example Update Product Review Model Schema 🧩

```json
{
"name": "Taha Abdur Razzaq",
"title": "HP Victus 16",
"rating": 5.0,
"review": "Worst Laptop in the world",
"date": "2023-06-30T12:34:56.789Z"
}
```

### Notes 📒

- Ensure MongoDB is running and accessible for the FastAPI application to function correctly.
- The mongo_url in app/server/database.py is set to connect to a MongoDB instance at host.docker.internal.

---

```bash
This project was made with 💖 by Saad Abdur Razzaq
```