In this assignment, you will implement a matchmaking algorithm for a dating application. Your task is to create a scoring system that determines compatibility between users based on their profiles, including hobbies, interests, and other relevant data.
- Python 3.8+
- FastAPI
- Additional libraries of your choice (please document them)
matchmaking/
│
├── app/
│ ├── __init__.py
│ ├── main.py
│ ├── models.py
│ └── matching/
│ ├── __init__.py
│ └── algorithm.py
│
├── mock_data/
│ └── users.json
│
├── requirements.txt
└── README.md
Each user profile contains the following information:
{
"id": str,
"name": str,
"age": int,
"gender": str,
"interested_in": str,
"location": str,
"hobbies": List[str],
"interests": List[str],
"occupation": str,
"education_level": str,
"personality_traits": List[str]
}
- Implement the matching algorithm in
app/matching/algorithm.py
- The algorithm should:
- Calculate compatibility scores between users
- Consider factors like common interests, hobbies, education level, etc.
- Return ranked pairs of users with their compatibility scores
- Expose the functionality through FastAPI endpoints
Implement the following endpoints:
POST /api/v1/match
: Generate matches for a given userGET /api/v1/compatibility/{user_id1}/{user_id2}
: Get compatibility score for two users
Submit your solution as a ZIP file containing:
- All source code
- Requirements file
- Documentation (PDF format) explaining:
- Your algorithm's approach
- Scoring methodology
- Trade-offs and decisions made
- Potential improvements
- Setup and running instructions
- Virtual Environment should not be included in the ZIP file
Your documentation should include:
-
Algorithm Overview
- Explanation of your matching logic
- Factors considered and their weights
- Mathematical formulas (if any)
-
Technical Implementation
- Code structure
- Libraries used and why
- Performance considerations
-
Future Improvements
- What would you do differently with more time?
- Scalability considerations
- Additional features
Your submission will be evaluated based on:
- Code quality and organization
- Algorithm effectiveness and creativity
- Documentation clarity
- Performance and scalability considerations
- Error handling and edge cases
- Clone this template
- Install dependencies:
pip install -r requirements.txt
- Start server:
uvicorn app.main:app --reload
Sample user data is provided in mock_data/users.json
. Use this data to test your implementation.
http://localhost:8000
- Request:
- Method: GET
- URL:
/
- No headers required
- Expected Response:
{
"message": "Welcome to the Dating App Matchmaking API"
}
- Request:
- Method: POST
- URL:
/api/v1/match/user1
- No body required
- Expected Response:
[
{
"user_id": "user4",
"name": "Emily Parker",
"compatibility_score": 0.85,
"common_interests": ["travel", "technology"],
"common_hobbies": ["hiking", "photography"]
},
{
"user_id": "user2",
"name": "Sarah Chen",
"compatibility_score": 0.72,
"common_interests": ["travel"],
"common_hobbies": ["cooking"]
}
]
- Request:
- Method: GET
- URL:
/api/v1/compatibility/user1/user2
- No body required
- Expected Response:
{
"user1_id": "user1",
"user2_id": "user2",
"compatibility_score": 0.72
}
-
Valid Match Generation
- Use existing user IDs (user1, user2, user3, user4, user5)
- Verify that matches are sorted by compatibility score
- Check that gender preferences are respected
- Verify common interests and hobbies are correct
-
Invalid User IDs
- Test with non-existent user ID:
/api/v1/match/user999
- Expected: 404 Not Found response
{ "detail": "User not found" }
- Test with non-existent user ID: