Skip to content

Conversation

@utkarshupdy
Copy link

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

Ensure the following Python packages are installed:

FastAPI
SQLAlchemy
geopy
pydantic

### Instructions to Run
Install dependencies: pip install -r requirements.txt
Start the FastAPI server: uvicorn main:app --reload
Use 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant