hoangsonww/EstateWise-Chapel-Hill-Chatbot

Feature: Integrate Neo4j for Relationship-Aware Property Recommendations

开放

#74 创建于 2025年9月16日

 (0 条评论) (0 个反应) (1 位负责人)TypeScript (21 个派生)auto 404
backendchoreci/cddocumentationenhancementfrontendgood first issuehelp wanted

仓库指标

星标
 (38 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

🚀 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

  1. Neighborhood Graph

    • (Property)-[:IN]->(Neighborhood)-[:HAS]->(School)
    • Query: “Show me houses near UNC with A-rated schools and parks.”
  2. Property Similarity Graph

    • (House A)-[:SIMILAR {priceDiff:20k, bedDiff:1}]->(House B)
    • Explainable recommendations, not just opaque vector matches.
  3. User–Property Interaction Graph

    • (User)-[:LIKED]->(Property)
    • Collaborative filtering: “Users who liked this home also liked these.”
  4. Proximity / Commute Queries

    • With Neo4j spatial: “Find 3BR homes within 15 min of downtown.”
  5. Hybrid Search

    • Pinecone → fast semantic candidate retrieval.
    • Neo4j → relationship-aware filtering/ranking.

🛠 Implementation Plan

  • Backend

    1. Install driver: npm install neo4j-driver.

    2. Add env vars:

      NEO4J_URI=neo4j+s://<db-uri>
      NEO4J_USER=<user>
      NEO4J_PASSWORD=<password>
      
    3. Create services/neo4jService.ts to init driver + expose query helpers.

    4. Define graph schema + migration script:

      • Nodes: Property, User, Neighborhood, School, etc.
      • Edges: :IN, :SIMILAR, :LIKED, :HAS.
  • 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.md and TECH_DOCS.md to reflect new graph layer.

✅ 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.

贡献者指南