Duration: 3 hours
Objective: Assess the candidate's ability to design and implement a scalable real-time recommendation system for an e-commerce platform using Python, FastAPI, Celery, PostgreSQL, and machine learning techniques.
- FastAPI Application:
- Set up a FastAPI application with a well-structured project layout.
- Configure necessary libraries such as FastAPI-SQLAlchemy for ORM and FastAPI-Cors for handling CORS issues.
- Database Configuration:
- Connect to PostgreSQL and create tables for
users
,products
,orders
, anduser_product_interactions
(to track user interactions with products). - Define relationships between tables.
- Capture User Interactions:
- Implement an API endpoint that logs user interactions with products (e.g., views, clicks, purchases).
- Store these interactions in the
user_product_interactions
table.
- Data Processing:
- Create a background task using Celery that processes the interaction data periodically to update user profiles for recommendations.
- Collaborative Filtering Algorithm:
- Implement a simple collaborative filtering algorithm to generate product recommendations based on user interactions.
- Use techniques such as cosine similarity or matrix factorization (e.g., SVD) to compute recommendations.
- Real-Time Recommendations Endpoint:
- Create an API endpoint that returns real-time product recommendations for a given user based on their interaction history.
- Ensure that the recommendations are updated dynamically as new interactions are logged.
- Integration with Machine Learning Model:
- Integrate a pre-trained machine learning model (e.g., using scikit-learn or TensorFlow) that predicts user preferences based on historical data.
- Allow the model to be retrained periodically using new interaction data.
- Unit Testing and API Documentation:
- Write unit tests for the recommendation logic and API endpoints using pytest.
- Document the API endpoints using Swagger or Postman.
- Serialization Methods:
- Implement serialization of user interactions and recommendations using both
pickle
andJSON
. - Demonstrate converting data from
pickle
format toJSON
for API responses.
- Code Quality: Clarity, organization, adherence to Python best practices.
- Functionality: Completeness of features implemented within the time limit.
- Algorithm Understanding: Ability to explain and implement collaborative filtering concepts effectively.
- Real-Time Processing: Efficiency in handling real-time data updates for recommendations.
- Testing Rigor: Completeness and effectiveness of tests written.
- Creativity: Innovative approaches taken in implementing features or algorithms.
- For guidance on building FastAPI applications:
- To understand how to set up Celery:
- For collaborative filtering algorithms:
- For machine learning with scikit-learn: