Feature Completion and Enhancements for Marriage Matchmaking App #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This pull request completes the required functionality for the Marriage Matchmaking App by implementing the following features and improvements:
Add User Update Endpoint: A PUT /users/{user_id} endpoint has been implemented to allow partial updates of user profiles.
Add User Deletion Endpoint: A DELETE /users/{user_id} endpoint has been implemented to allow deletion of user profiles by ID.
Find Matches for a User: A GET /users/{user_id}/matches endpoint has been added to find potential matches for a user based on:
1-Shared interests
2-Age proximity (±3 years)
3-Geographical proximity (city proximity scoring)
4-Email Validation: Validation has been added to ensure that email addresses conform to a standard format using a regular
expression.
5-Pagination Support: The GET /users endpoint now supports pagination with skip and limit query parameters.
Changes in the Codebase
**main.py:**1- CRUD endpoints for user creation, retrieval, update, and deletion.
2- Matching algorithm based on interests, city proximity, and age difference.
3- Email validation during user creation.
**schemas.py:**1- Pydantic models for user input/output validation and data serialization.
2- Added support for scoring in the UserWithScore model for matchmaking results.
**models.py:**1-Refined SQLAlchemy model for User to align with Pydantic schemas.
**database.py:**1-Configured SQLite database setup using SQLAlchemy.
**requirements.txt:**1-Added dependencies for FastAPI, SQLAlchemy, and geopy.
Key Features Implemented
Update User by ID:
1-Allows updating user details partially (only provided fields).
2-Validates input data to ensure correctness.
Delete User by ID:
1- Deletes a user profile from the database.
Matchmaking Algorithm:
1-Calculates a match score using:
2-Interest similarity: Based on the overlap of interests between two users.
3-City proximity: Using geographic coordinates and distance scoring.
4-Age proximity: Users within ±3 years are prioritized.
5-Results are sorted in descending order of match score.
Email Validation:
1-Ensures that email addresses are valid during user creation via regix.
Assumptions and Notes
1-Age Proximity: Matches are restricted to users within ±3 years of the given user's age.
2-Geographical Scoring: Uses geopy to calculate distances between coordinates; a proximity score is calculated based on 3-closeness.
3-Interest Overlap: Interests are treated as a list of strings; overlapping interests increase the match score.
4-Database: SQLite is used for simplicity. Suitable for small-scale applications.
### Testing
Unit Testing:
1-Tested all endpoints for expected behavior.
2-Verified error handling for invalid inputs (e.g., invalid email or nonexistent user ID).
Manual Testing:
1-Verified matchmaking results for various users with differing attributes.
2-Confirmed email validation and CRUD operations.
Dependencies
### Instructions to Run
Install dependencies:
pip install -r requirements.txtStart the FastAPI server:
uvicorn main:app --reloadUse the provided endpoints for CRUD operations and matchmaking.
Future Work
1-Enhance matching logic to incorporate user preferences or weights for scoring criteria.
2-Add support for advanced filtering in the matchmaking endpoint.
3-Integrate testing frameworks for automated testing.