A recommendation system that helps tenants find compatible roommates for co-renting apartments using Neo4j graph database and a weighted compatibility scoring algorithm.
The system calculates compatibility between two tenants using a weighted scoring system:
| Factor | Weight | Logic |
|---|---|---|
| Cleanliness Match | 20 pts | Awarded if cleanliness scores are within 2 points of each other |
| Schedule Match | 20 pts | Awarded if both are night owls OR both are early birds |
| Work Style Match | 15 pts | Awarded if both work from home OR both go to office |
| Shared Interests | 5 pts each | Each common interest adds 5 points |
| Pet Status Match | 10 pts | Awarded if both have pets OR both don't have pets |
Minimum Score: 30 points required for a recommendation
Before compatibility scoring, tenants must pass these filters:
- Combined budget ≥ apartment rent
- Matching smoking preference (both smokers OR both non-smokers)
- Pet compatibility (if either has pets, apartment must allow pets)
- Both interested in the same apartment
Nodes:
Tenant: id, name, age, occupation, budget, smoker, hasPets, petType, cleanliness (1-10), nightOwl, workFromHome, interests[], phone, emailApartment: id, address, city, bedrooms, bathrooms, rent, deposit, sqft, parking, furnished, petsAllowed, amenities[]Landlord: id, name, phone, email, rating
Relationships:
OWNS: Landlord → Apartment (properties: since)INTERESTED_IN: Tenant → Apartment (properties: moveInDate, urgency)
1. Find Roommates for Tenant
Input: tenant_id, apartment_id
Process:
1. Query all tenants interested in same apartment
2. Filter by budget, smoking, pet policies
3. Calculate compatibility scores
4. Filter by minimum score (30)
5. Sort by score DESC, then budget surplus DESC
Output: Ranked list of compatible roommates
2. Find All Compatible Pairs
Input: apartment_id
Process:
1. Query all tenants interested in apartment
2. Generate all possible pairs (t1, t2) where t1.id < t2.id
3. Apply filters and compatibility scoring
4. Filter by minimum score (25)
5. Sort by score DESC
Output: Ranked list of tenant pairs
3. Calculate Financial Feasibility
Combined Budget = tenant1.budget + tenant2.budget
Budget Surplus = Combined Budget - apartment.rent
Each Tenant Share = apartment.rent / 2
src/
├── db_connection.py # Neo4j queries and connection
├── recommendation_engine.py # Compatibility scoring logic
└── main.py # Interactive CLI