How aritra741/memoryatlas works
Purpose and Entry Points
MemoryAtlas is a local-first journaling system that detects sustained negative emotional trajectories and retrieves evidence of prior recovery. The React client starts at frontend/src/main.jsx and frontend/src/App.jsx; the FastAPI service starts at backend/main.py. Primary ingress is entry ingestion, with REST routers and a user WebSocket under backend/routers/entries.py, backend/routers/search.py, and backend/routers/websocket.py.
Frontend Experience and State
The frontend renders an emotional 3D “ocean” rather than a conventional dashboard. frontend/src/components/OceanView.jsx maps entry coordinates and emotional state into the scene; frontend/src/components/InterventionCinematic.jsx and frontend/src/components/InterventionOverlays.jsx present the staged recovery journey. API/WebSocket integration is centralized in frontend/src/services/api.js; client-side memory and intervention timing state live in frontend/src/store/memoryStore.js and frontend/src/store/interventionTimings.js.
Entry Ingestion and Feature Extraction
POST /api/entries accepts text and optional audio through backend/routers/entries.py. The pipeline generates semantic embeddings, emotion distributions/Russell valence-arousal features, and linguistic features via backend/ml/embeddings.py, backend/ml/emotion.py, and backend/ml/linguistic.py. Audio processing adds transcription/prosodic signals and text-audio dissonance through backend/ml/voice_emotion.py. The resulting entry is a multimodal point, with suppression/dissonance flags retained as searchable payload.
Vector Storage Boundary
Qdrant is the durable retrieval engine, accessed through backend/db/qdrant_client.py and higher-level persistence/search operations in backend/db/storage.py. Each entry shares one point ID across six named vectors; trajectory points have four named vectors. This co-location enables filtered searches and dissonance queries without cross-collection joins. Qdrant runs locally via docker-compose.yml; collection lifecycle support is in backend/reset_collections.py.
Trajectory Construction and Matching
After upsert, a recent 14-day entry window is converted into sequence and aggregate representations by backend/ml/trajectory_build.py, backend/ml/trajectory_encoder.py, and backend/ml/trajectory_features.py. Historical trajectory retrieval performs weighted multi-vector fusion in backend/ml/trajectory_context.py; confidence evaluation is isolated in backend/ml/match_confidence.py. This is the core boundary between per-entry understanding and longitudinal spiral detection.
Intervention and Recovery Retrieval
backend/ml/observation_engine.py implements the graduated intervention gates: ambient negative-state signaling, sustained-pattern observation, and evidence-backed cinematic intervention. Once a trajectory match passes confidence and safety gates, Qdrant Recommend uses the current spiral as negative examples and a post-historical-spiral datetime window to identify contrasting recovery entries. backend/ml/recovery_scoring.py ranks those candidates before they are returned in the ingest response.
Projection, Realtime Updates, and Infrastructure
backend/ml/umap_projector.py projects combined embedding features into 3D coordinates; periodic refits publish updated coordinates through the WebSocket router. The frontend uses these coordinates to position journal orbs and derives camera behavior from rolling emotional state. Deployment consists of a FastAPI container (backend/Dockerfile), static React/Nginx container (frontend/Dockerfile, frontend/nginx.conf), and local Qdrant. External dependency is TwelveLabs Marengo for audio embeddings; text, emotion, NLP, Whisper, UMAP, and trajectory models run locally.
Main entry points: main.py FastAPI application · App.jsx App shell · api.js API & WebSocket client · storage.py Storage operations
Components 19
React Client
Local emotional ocean experience.
- React entry
frontend/src/main.jsx - App shell
frontend/src/App.jsx - Emotional ocean · Positions journal orbs from projected coordinates and emotional state.
frontend/src/components/OceanView.jsx - Intervention journey
frontend/src/components/InterventionCinematic.jsx - API & WebSocket client
frontend/src/services/api.js - Memory state · Stores memories and intervention timing state.
frontend/src/store/memoryStore.js
FastAPI Service
Ingress, search, and realtime delivery.
- FastAPI application
backend/main.py - Entry ingestion · Accepts text and optional audio at POST /api/entries.
backend/routers/entries.py - Memory search
backend/routers/search.py - Realtime updates · Publishes coordinate refits to users.
backend/routers/websocket.py
Understanding & Intervention
Entry analysis through recovery retrieval.
- Multimodal features · Builds embeddings, emotion, linguistic, and audio dissonance signals.
backend/ml/embeddings.py - Trajectory construction · Builds 14-day sequence and aggregate representations.
backend/ml/trajectory_build.py - Historical matching · Fuses trajectory vectors and evaluates match confidence.
backend/ml/trajectory_context.py - Observation gates · Selects ambient, sustained-pattern, or cinematic intervention.
backend/ml/observation_engine.py - Recovery ranking · Ranks contrasting post-spiral recovery entries.
backend/ml/recovery_scoring.py - 3D projection · Refits and produces entry coordinates.
backend/ml/umap_projector.py
Vector Storage
Local durable retrieval boundary.
- Storage operations · Co-locates entry and trajectory named vectors by point ID.
backend/db/storage.py - Qdrant · Durable local engine for filtered, fused, and recommendation retrieval.
backend/db/qdrant_client.py
Deployment
Local containerized runtime.
- Local stack · Runs FastAPI, React/Nginx, and Qdrant locally.
docker-compose.yml
Connections 27
- React entry → App shell: mounts
- App shell → Emotional ocean: renders
- App shell → Intervention journey: renders
- App shell → API & WebSocket client: uses
- API & WebSocket client → FastAPI application: REST / WebSocket
- FastAPI application → Entry ingestion: routes
- FastAPI application → Memory search: routes
- FastAPI application → Realtime updates: routes
- Entry ingestion → Multimodal features: extracts
- Multimodal features → Storage operations: upserts entry payload and vectors
- Storage operations → Qdrant: persists and queries
- Storage operations → Trajectory construction: loads recent 14-day window
- Trajectory construction → Storage operations: upserts trajectory vectors
- Trajectory construction → Historical matching: current spiral
- Historical matching → Qdrant: retrieves historical trajectories
- Historical matching → Observation gates: matched confidence
- Observation gates → Recovery ranking: approved intervention
- Recovery ranking → Qdrant: recommends recovery evidence
- Observation gates → Entry ingestion: ingest response
- Multimodal features → 3D projection: combined features
- 3D projection → Realtime updates: coordinate updates
- Realtime updates → API & WebSocket client: pushes updates
- API & WebSocket client → Memory state: updates
- Memory state → Emotional ocean: coordinates and state
- Memory state → Intervention journey: intervention state
- Local stack → FastAPI application: runs
- Local stack → Qdrant: runs