GraphMind is a user-centric financial memory assistant.
It stores chat memories in a Neo4j knowledge graph, persists chat/session history in PostgreSQL, and generates grounded answers with citations using an LLM.
- Multi-user auth with JWT + bcrypt
- Strict user isolation for graph and chat history
- Graph ingestion pipeline for chat messages and uploaded documents
- Graph-only retrieval (no vector DB yet) with:
- mode-based query planning
- adaptive depth and adaptive
top_k - timeline filtering
- real shortest-path hop distance in query
- weighted ranking (
graph_distance,recency,confidence,reinforcement)
- Deferred reinforcement of cited nodes
- Optional background hard-decay worker for persisted confidence
- Mindmap endpoint + frontend graph visualization
- Frontend: React + TypeScript + Vite
- Backend: FastAPI
- Datastores:
- PostgreSQL: users, sessions, messages, metadata
- Neo4j: memory graph (facts, entities, relations)
- LLM: Google Gemini (fallback behavior when unavailable)
- Optional storage: AWS S3 for document uploads (best-effort)
- Ensure/create user node in Neo4j
- Store raw message node
- Deduplicate facts by
(user_id, fact_text):- existing fact -> reinforce
- new fact -> create and link from message
- Merge entity nodes with
id + user_id - Create canonical links (for example
User -> MADE_TRANSACTION -> Transaction -> AFFECTS_ASSET -> Asset) - Link evidence facts to structured nodes (
CONFIRMS,RELATES_TO) - Run contradiction detection heuristic (skipped for document ingestion routes)
- Classify query into one of:
DIRECT_LOOKUPAGGREGATIONRELATIONAL_REASONING
- Build adaptive retrieval plan (
depth,top_k) from mode + query length - Execute mode-specific Cypher with user scoping and optional timeline filter
- Compute hop distance in the same query using
shortestPath - Rank by weighted score:
score = 0.4*graph_distance + 0.3*recency + 0.2*confidence + 0.1*reinforcement
- Return ranked nodes + citations, then reinforce cited nodes after answer generation
GET /health
POST /auth/signupPOST /auth/loginGET /auth/me
POST /chatGET /sessionsGET /sessions/{session_id}/messagesPOST /sessions/{session_id}/archiveDELETE /sessions/{session_id}
GET /memory/mindmap
POST /documents/uploadPOST /documents/ingestPOST /documents/upload-and-ingest
OpenAPI docs are available at:
http://localhost:8001/docs
/chat returns retrieval and generation timings separately:
graph_query_msvector_search_ms(currently0.0placeholder)context_assembly_msretrieval_ms(excludes LLM generation)llm_generation_ms
graphmind/
├── backend/
│ ├── api/
│ │ ├── main.py
│ │ ├── models.py
│ │ ├── models_auth.py
│ │ ├── models_mindmap.py
│ │ └── routes/
│ │ ├── auth.py
│ │ ├── chat.py
│ │ ├── documents.py
│ │ ├── health.py
│ │ └── memory.py
│ ├── config/
│ │ └── settings.py
│ ├── database/
│ │ ├── init.sql
│ │ └── postgres.py
│ ├── services/
│ │ ├── auth/
│ │ ├── database/
│ │ ├── extraction/
│ │ ├── graph/
│ │ │ ├── ingestion.py
│ │ │ ├── memory_decay.py
│ │ │ ├── mindmap_service.py
│ │ │ ├── query_understanding.py
│ │ │ ├── retrieval.py
│ │ │ ├── retrieval_old.py
│ │ │ └── schema.cypher
│ │ ├── llm/
│ │ ├── orchestrator/
│ │ └── storage/
│ ├── requirements.txt
│ └── .env.example
├── frontend/
│ ├── src/
│ │ ├── components/
│ │ ├── contexts/
│ │ ├── lib/
│ │ └── pages/
│ └── package.json
├── docker-compose.yml
└── README.md
- Python 3.10+
- Node.js 18+
- Docker + Docker Compose
cd /home/tanmay08/graphmind
docker compose up -dcd /home/tanmay08/graphmind/backend
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
cp .env.example .envSet required values in .env:
GEMINI_API_KEYJWT_SECRET_KEYNEO4J_URI,NEO4J_USER,NEO4J_PASSWORD- PostgreSQL values if different from Docker defaults
cd /home/tanmay08/graphmind/frontend
npm installBackend:
cd /home/tanmay08/graphmind/backend
source venv/bin/activate
uvicorn api.main:app --reload --host 0.0.0.0 --port 8001Frontend:
cd /home/tanmay08/graphmind/frontend
npm run dev- Frontend:
http://localhost:5173 - API docs:
http://localhost:8001/docs
The backend supports optional confidence hard-decay worker through env flags:
MEMORY_HARD_DECAY_ENABLEDMEMORY_HARD_DECAY_INTERVAL_SECONDSMEMORY_HARD_DECAY_BATCH_SIZEMEMORY_DECAY_HALF_LIFE_DAYSMEMORY_DECAY_FLOOR
If hard-decay is disabled (default), retrieval still uses recency + confidence + reinforcement from stored graph properties.
- Retrieval is graph-only (vector retrieval is planned but not active)
- Query understanding is deterministic keyword based
- Contradiction detection is heuristic
- Document extraction chunk-level vector indexing is not yet implemented