How dpacheco2001/agentsbmemlayer works
Project Type and Purpose
• This is a full-stack research application demonstrating an AI agent with persistent, graph-based memory.
• The backend (Python + Flask/WebSockets) manages conversations, memory storage (Neo4j), and LLM calls.
• The frontend (React + Vite + Tailwind + Shadcn/UI) visualizes the memory graph in 3D and provides a chat interface.
File Structure Analysis
• Top level:
• app/frontend → React UI code (TSX, components, pages, UI primitives, hooks, services)
• app/main.py & app/main_ws.py → Python entry points (REST + WebSocket servers)
• app/myagent → Core “agent” logic: audio streaming, graph manipulation, state management, prompt tools.
• requirements.txt → Python dependencies (Flask, websockets, Neo4j driver, LangChain/LangGraph).
• import_relationships.py → Data-bootstrap script for Neo4j.
• Supporting folders: downloads (audio files), local_images, output_file.json.
Architectural Insights from README
• Communication: WebSocket between frontend and backend for real-time memory exploration.
• Persistence: Neo4j graph database for nodes/edges representing memories.
• Extensibility: Multi-model support via LangChain/LangGraph adapters.
• UI: React Force Graph for 3D graph, custom “neural” theme with Tailwind + Shadcn/UI.
Main Components
a. Frontend Layer
• Browser (React App)
• UI Sub-components: ChatInterface, BrainVisualization, GraphVisualization, NodeEditor/RelationshipEditor
• WebSocketService (frontend/src/services/websocketService.js)
b. Backend Layer
• WebSocket Server (main_ws.py) for real-time messages
• REST API Server (main.py) for auxiliary endpoints
• Agent Core (app/myagent):
• audio_streaming.py
• graph.py (build/update memory graph)
• utils/ (configuration, models, nodes_edges, prompts, state, tools, image_proxy)
c. Persistence Layer
• Neo4j Graph Database
d. External Services Layer
• LLM Providers (OpenAI, Anthropic, Google, DeepSeek, Ollama, etc.)
• Optional LangSmith tracing endpoint
e. Static/Data Assets
• Local image store (local_images)
• Downloaded audio (downloads)
Relationships & Data Flow
• User types in ChatInterface → Frontend WebSocketService sends message → Backend WebSocket Server.
• Backend routes to Agent Core →
• Query/Update Neo4j (memory retrieval/storage)
• Invoke LLM(s) via LangChain/LangGraph → generate response and memory updates.
• Agent Core returns new graph data and chat response via WebSocket → Frontend updates UI: GraphVisualization + ChatInterface.
• import_relationships.py populates Neo4j in advance; main.py exposes any RESTful diagnostics or config endpoints.
Architectural Patterns & Principles
• Layered Architecture: UI → API/Communication → Core Domain → Persistence → External Integrations
• Component-Based Frontend with reusable UI primitives (Shadcn/UI + Tailwind)
• Micro-service-style separation of realtime (WebSocket) vs. request/response (REST).
• Domain-driven design inside “myagent” package (clear separation of graph logic, prompts, state).