How xiaoxiaohexin/study-room works
Study Room is a local-first learning assistant, with a customized llama.cpp WebUI and a FastAPI backend. The main workflow is a learner asking a question, the backend coordinating an agent response using session history, learning intent, memory, and optional RAG context, then returning the result to the interface. Other documented capabilities include document ingestion, quizzes and spaced repetition, knowledge notes, and memory management. Some route and tool implementations were not sampled, so those links are omitted or marked unverified.
Main entry points: loop.py ReAct agent · retriever.py RAG retrieval · main.py FastAPI routes · builder.py Context builder
Components 21
User interface
- Study WebUI
llama-webui/tools/ui/src/lib/components/app/chat/ChatScreen/ChatScreen.svelte
Agent runtime
- FastAPI routes
app/main.py - Chat and compat routes
app/api/routes/chat.py - ReAct agent
app/agent/loop.py - Context builder
app/context/builder.py - LLM client
app/llm/base.py - Session state
app/session/state_manager.py - MCP tools
app/tools/protocols/mcp_client.py
Learning and memory
- Intent router
app/learning/router.py - Memory manager
app/memory/manager.py - Learning tools
app/tools/builtin/learning_tools.py - Learning store
app/learning/store.py - Four-layer memory
app/memory/working.py
Knowledge and storage
- RAG routes
app/api/routes/rag.py - Document ingestion
app/rag/pipeline.py - RAG retrieval
app/rag/retriever.py - Embedding provider
app/llm/embedding.py - Vector store
app/storage/vector.py - SQLite storage
app/storage/sqlite.py - Query expansion
app/query/expansion.py
Other components
- Learner
Connections 25
- Learner → Study WebUI: asks question
README.md - Study WebUI → FastAPI routes: sends requests
README.md - FastAPI routes → Chat and compat routes: registers routes
app/main.py - FastAPI routes → RAG routes: registers routes
app/main.py - Chat and compat routes → ReAct agent: dispatches chat
- ReAct agent → Intent router: routes intent
app/agent/loop.py - ReAct agent → Context builder: builds context
app/agent/loop.py - ReAct agent → LLM client: requests completion
app/agent/loop.py - ReAct agent → Session state: loads history
app/agent/loop.py - ReAct agent → Memory manager: retrieves memories
app/agent/loop.py - ReAct agent → Query expansion: expands queries
app/agent/loop.py - Intent router → Learning store: checks pending question
app/learning/router.py - Context builder → RAG retrieval: uses retrieved docs
app/context/builder.py - Context builder → Four-layer memory: uses memory items
app/context/builder.py - Session state → SQLite storage: reads and writes
app/session/state_manager.py - RAG retrieval → Embedding provider: embeds queries
app/rag/retriever.py - RAG retrieval → Vector store: searches vectors
app/rag/retriever.py - Document ingestion → Embedding provider: embeds chunks
app/rag/pipeline.py - Document ingestion → Vector store: stores chunks
app/rag/pipeline.py - RAG routes → Document ingestion: imports documents
app/api/routes/rag.py - RAG routes → RAG retrieval: runs searches
app/api/routes/rag.py - ReAct agent → Learning tools: dispatches tools
- Learning tools → Learning store: updates learning state
- Memory manager → Four-layer memory: retrieves and stores
- ReAct agent → MCP tools: uses optional tools