https://github.com/kejiahp/fastapi-ecom-recommendation-system
Advanced recommendation system for e-commerce applications.
https://github.com/kejiahp/fastapi-ecom-recommendation-system
docker fastapi jinja2 mongodb motor pydantic python scikit-learn scikit-surprise
Last synced: 3 months ago
JSON representation
Advanced recommendation system for e-commerce applications.
- Host: GitHub
- URL: https://github.com/kejiahp/fastapi-ecom-recommendation-system
- Owner: kejiahp
- Created: 2025-02-07T21:15:35.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-30T11:41:09.000Z (12 months ago)
- Last Synced: 2025-12-26T10:40:36.737Z (6 months ago)
- Topics: docker, fastapi, jinja2, mongodb, motor, pydantic, python, scikit-learn, scikit-surprise
- Language: Python
- Homepage: https://fastapi-ecom-recommendation-syst-production.up.railway.app
- Size: 102 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ADVANCED RECOMMENDATION SYSTEM FOR E-COMMERCE APPS
*This was a Bsc dissertation project.*
#### Introduction
The backend is built using FastAPI, a high-performance web framework for Python. It is
responsible for handling all business logic, authentication, recommendation generation,
and database interactions. The backend server is developed using a modular monolithic
architecture, where all core functionalities, including API routing, authentication,
recommendation logic, and database access, are contained within a single unified
codebase but loosely coupled. This approach simplifies development and deployment in
the early stages of the project, offering ease of integration and centralized control.
As the system grows, this monolithic structure provides a solid foundation that can later be
modularized or refactored into microservices if scalability and separation of concerns
become priorities.
- **API Layer**: Exposes endpoints for interacting with the system, including endpoints
for user authentication, recommendations, and data management.
- **Business Logic Layer**: Contains the recommendation algorithms, including
collaborative filtering using scikit-surprise (KNN) and content-based filtering using
scikit-learn (TF-IDF). Logic for interaction with products, cart manipulation, order
checkout and product rating are also included here.
- **Data Layer**: MongoDB is used to store all persistent data, including user profiles,
ratings, product data, and recommendations. FastAPI interacts with the database
using Motor for asynchronous database queries.
- **Authentication Layer**: Uses JWT (JSON Web Tokens) for secure user authentication.
The tokens are passed in API requests to authenticate and authorize user actions.
#### Dependencies
- Python Version: >= `3.10` <= `3.12` (`scikit-surprise` at the moment does not work well with Python version `3.13`)
- fastapi==0.115.12
- Jinja2==3.1.6
- motor==3.7.0 and pymongo==4.11.3
- pydantic==2.11.2
- pydantic-settings==2.8.1
- pydantic_core==2.33.1
- PyJWT==2.10.1
- bcrypt==4.3.0
- emails==0.6
- *And others listed in the `requirements.txt` file*
#### Modular Monolith Architecture

#### NoSQL Data Model Diagram

#### Running locally (macOS)?
- `docker-compose up -d` to start docker services in the background detached from the terminal.
- create a virtual environment: `python3 -m venv `
- enter your virtual environment: `source /bin/activate`
- install packages listed in the requirements.txt file: `pip install -r requirements.txt`
- start server: `uvicorn app.main:application --host 0.0.0.0 --port 8000`, for reloads on code change the `--reload` flag can be added.
The server will now be running on port `8000`.