Added to the repository main branch
Recommender Companion is a web application designed to provide personalized book and movie recommendations based on user preferences. Utilizing Microsoft OAuth for authentication, Docker for consistent environment setup, and Flyway for database migrations, the application ensures a robust and secure user experience.
- Docker Desktop
- Python 3.8 or higher
- Node.js
- Angular CLI
- Development / Testing:
pip install -r requirements.txt
pip install pytest
pip install PyJWT
- Runtime Deployment:
pip install -r requirements.txt
This will install all required packages such as Flask, SQLAlchemy, and others crucial for the application's backend.
- Clone the repository.
- Obtain Microsoft Azure credentials:
- Tenant ID
- Client ID
- Client Secret
- Open AI API Key
- Use the provided startup script to launch the application:
For additional help:
# Windows python start.py <tenant_id> <client_id> <client_secret> <openai_api_key> # Linux/MacOS python3 start.py <tenant_id> <client_id> <client_secret> <openai_api_key>
The application will be available atpython start.py --help
http://localhost:5000
.
- Navigate to the frontend directory.
- Install dependencies:
npm install
- Launch the frontend application:
The frontend will be accessible at
npm start
http://localhost:4200/
. Ensure the backend is operational before accessing the frontend.
Configure the project using the following environment variables in the .env
file:
MICROSOFT_TENANT_ID
MICROSOFT_CLIENT_ID
MICROSOFT_CLIENT_SECRET
DATABASE_URL
Source Repositories:
- Movies: https://www.kaggle.com/datasets/alanvourch/tmdb-movies-daily-updates
- Books: https://www.kaggle.com/datasets/arashnic/book-recommendation-dataset The database is structured with five main tables:
- Movies Table: Stores data from the TMDB repository.
- Books Table: Contains book data from the GoodReads repository.
- User Table: Manages information about active users.
- User Watched Movies Table: Records movies watched by users.
- User Read Books Table: Logs books read by users.
Flyway manages database migrations, which are automatically applied upon service startup.
The ApiService
and AdminService
in the Angular frontend handle all interactions with the backend. These services facilitate operations such as fetching listings, submitting reviews, and updating user profiles. Administrative functions include adding new movies or books and retrieving recent additions.
- getListings: Fetches movies or books based on search criteria.
- submitReview: Allows users to post reviews.
- addMovie/book: Admin functionality to add new content.
- deleteItem: Removes a specified item by ID.
- updateItem: Updates the details of an item.
- generateRecommendations: Offers personalized recommendations.
The application utilizes the OpenAI API using GPT 3.5 Turbo Model to generate personalized book and movie recommendations. Interaction with the GPT API is handled securely to ensure that user data is used effectively to enhance recommendation accuracy.
- The Microsoft credentials are securely stored and not hard-coded.
- We use HTTPS to protect data in transit.
Manage Docker containers using the following commands:
# Start all services
python start.py <tenant_id> <client_id> <client_secret> <gpt_api_keys>
# Stop all services and remove volumes
docker-compose down -v
# View logs for troubleshooting
docker-compose logs
# Access the MySQL shell
docker-compose exec db mysql -uuser -ppassword rc_db
- Run all tests:
pytest tests/test.py -v
- Run specific test:
pytest tests/test.py -v -k "test_health_check"
- Run with coverage:
pip install pytest-cov
pytest --cov=app tests/test.py
- Checkout to the frontend directory
cd frontend
-
Perform
npm install
if not done already. -
Run
npm run test:coverage
Tests cover API endpoints, authentication, database operations, and recommendation engine functionality.