Feature: Integrate Neo4j for Relationship-Aware Property Recommendations
#74 opened on 2025/09/16
Repository metrics
- Stars
- (38 個のスター)
- PR merge metrics
- (PR metrics pending)
説明
🚀 Feature Request
Add Neo4j as a graph database layer to complement MongoDB (document store) and Pinecone (vector search). This will enable EstateWise to handle relationship-heavy queries, improve explainability of recommendations, and unlock new AI/graph hybrid capabilities.
🔑 Motivation / Why
Current stack:
- MongoDB → user data, raw listings.
- Pinecone → semantic similarity (embeddings).
- Redis → caching.
What’s missing:
- A way to model explicit relationships (neighborhoods, schools, user preferences, property-to-property similarities).
- Ability to answer graph traversal queries that are hard/inefficient in MongoDB.
- Better explainability for recommendations: “This house was recommended because it’s in the same school district and similar in size/price to your liked properties.”
🎯 Use Cases
-
Neighborhood Graph
(Property)-[:IN]->(Neighborhood)-[:HAS]->(School)- Query: “Show me houses near UNC with A-rated schools and parks.”
-
Property Similarity Graph
(House A)-[:SIMILAR {priceDiff:20k, bedDiff:1}]->(House B)- Explainable recommendations, not just opaque vector matches.
-
User–Property Interaction Graph
(User)-[:LIKED]->(Property)- Collaborative filtering: “Users who liked this home also liked these.”
-
Proximity / Commute Queries
- With Neo4j spatial: “Find 3BR homes within 15 min of downtown.”
-
Hybrid Search
- Pinecone → fast semantic candidate retrieval.
- Neo4j → relationship-aware filtering/ranking.
🛠 Implementation Plan
-
Backend
-
Install driver:
npm install neo4j-driver. -
Add env vars:
NEO4J_URI=neo4j+s://<db-uri> NEO4J_USER=<user> NEO4J_PASSWORD=<password> -
Create
services/neo4jService.tsto init driver + expose query helpers. -
Define graph schema + migration script:
- Nodes:
Property,User,Neighborhood,School, etc. - Edges:
:IN,:SIMILAR,:LIKED,:HAS.
- Nodes:
-
-
Data Ingestion
- During property upsert (currently to Pinecone + Mongo), also push to Neo4j.
- Script example:
npm run upsert:neo4j.
-
API Layer
-
New endpoints for relationship queries (e.g.
/api/properties/graph-similar,/api/properties/by-neighborhood). -
Extend chat agent so Decision AI can choose between:
- Pinecone (semantic).
- Neo4j (graph queries).
- Hybrid (both, merged).
-
-
Docs
- Update
ARCHITECTURE.mdandTECH_DOCS.mdto reflect new graph layer.
- Update
✅ Acceptance Criteria
- Neo4j service connected + working in dev.
- Properties + relationships ingested into graph.
- API endpoints available for graph-based queries.
- Chat agent can leverage Neo4j when user queries involve relationships.
- Updated diagrams/docs with Neo4j included in architecture.
📌 Notes
- Could use Neo4j AuraDB Free Tier (cloud) for dev.
- Initial focus: Neighborhood + User–Property graphs.
- Future: Pathfinding, commute queries, explainable recs.