brainpalace-rag 26.5.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. brainpalace_rag-26.5.1/PKG-INFO +399 -0
  2. brainpalace_rag-26.5.1/README.md +348 -0
  3. brainpalace_rag-26.5.1/brainpalace_server/__init__.py +3 -0
  4. brainpalace_rag-26.5.1/brainpalace_server/api/AGENTS.md +63 -0
  5. brainpalace_rag-26.5.1/brainpalace_server/api/CLAUDE.md +86 -0
  6. brainpalace_rag-26.5.1/brainpalace_server/api/__init__.py +5 -0
  7. brainpalace_rag-26.5.1/brainpalace_server/api/main.py +1143 -0
  8. brainpalace_rag-26.5.1/brainpalace_server/api/routers/__init__.py +19 -0
  9. brainpalace_rag-26.5.1/brainpalace_server/api/routers/cache.py +135 -0
  10. brainpalace_rag-26.5.1/brainpalace_server/api/routers/context.py +58 -0
  11. brainpalace_rag-26.5.1/brainpalace_server/api/routers/folders.py +156 -0
  12. brainpalace_rag-26.5.1/brainpalace_server/api/routers/git.py +43 -0
  13. brainpalace_rag-26.5.1/brainpalace_server/api/routers/health.py +437 -0
  14. brainpalace_rag-26.5.1/brainpalace_server/api/routers/index.py +530 -0
  15. brainpalace_rag-26.5.1/brainpalace_server/api/routers/jobs.py +111 -0
  16. brainpalace_rag-26.5.1/brainpalace_server/api/routers/memories.py +148 -0
  17. brainpalace_rag-26.5.1/brainpalace_server/api/routers/query.py +110 -0
  18. brainpalace_rag-26.5.1/brainpalace_server/api/routers/runtime.py +71 -0
  19. brainpalace_rag-26.5.1/brainpalace_server/api/routers/sessions.py +101 -0
  20. brainpalace_rag-26.5.1/brainpalace_server/config/__init__.py +5 -0
  21. brainpalace_rag-26.5.1/brainpalace_server/config/git_config.py +76 -0
  22. brainpalace_rag-26.5.1/brainpalace_server/config/provider_config.py +632 -0
  23. brainpalace_rag-26.5.1/brainpalace_server/config/session_config.py +77 -0
  24. brainpalace_rag-26.5.1/brainpalace_server/config/settings.py +200 -0
  25. brainpalace_rag-26.5.1/brainpalace_server/indexing/__init__.py +45 -0
  26. brainpalace_rag-26.5.1/brainpalace_server/indexing/bm25_index.py +203 -0
  27. brainpalace_rag-26.5.1/brainpalace_server/indexing/chunking.py +963 -0
  28. brainpalace_rag-26.5.1/brainpalace_server/indexing/document_loader.py +690 -0
  29. brainpalace_rag-26.5.1/brainpalace_server/indexing/embedding.py +304 -0
  30. brainpalace_rag-26.5.1/brainpalace_server/indexing/git_chunker.py +93 -0
  31. brainpalace_rag-26.5.1/brainpalace_server/indexing/git_loader.py +149 -0
  32. brainpalace_rag-26.5.1/brainpalace_server/indexing/gitignore_matcher.py +118 -0
  33. brainpalace_rag-26.5.1/brainpalace_server/indexing/graph_extractors.py +875 -0
  34. brainpalace_rag-26.5.1/brainpalace_server/indexing/graph_index.py +783 -0
  35. brainpalace_rag-26.5.1/brainpalace_server/indexing/session_chunker.py +173 -0
  36. brainpalace_rag-26.5.1/brainpalace_server/indexing/session_loader.py +219 -0
  37. brainpalace_rag-26.5.1/brainpalace_server/job_queue/__init__.py +11 -0
  38. brainpalace_rag-26.5.1/brainpalace_server/job_queue/job_service.py +364 -0
  39. brainpalace_rag-26.5.1/brainpalace_server/job_queue/job_store.py +442 -0
  40. brainpalace_rag-26.5.1/brainpalace_server/job_queue/job_worker.py +577 -0
  41. brainpalace_rag-26.5.1/brainpalace_server/locking.py +226 -0
  42. brainpalace_rag-26.5.1/brainpalace_server/lsp/__init__.py +6 -0
  43. brainpalace_rag-26.5.1/brainpalace_server/lsp/client.py +137 -0
  44. brainpalace_rag-26.5.1/brainpalace_server/lsp/cross_refs.py +109 -0
  45. brainpalace_rag-26.5.1/brainpalace_server/lsp/extractor.py +99 -0
  46. brainpalace_rag-26.5.1/brainpalace_server/lsp/servers.py +59 -0
  47. brainpalace_rag-26.5.1/brainpalace_server/models/__init__.py +111 -0
  48. brainpalace_rag-26.5.1/brainpalace_server/models/context.py +20 -0
  49. brainpalace_rag-26.5.1/brainpalace_server/models/folders.py +135 -0
  50. brainpalace_rag-26.5.1/brainpalace_server/models/graph.py +430 -0
  51. brainpalace_rag-26.5.1/brainpalace_server/models/health.py +206 -0
  52. brainpalace_rag-26.5.1/brainpalace_server/models/index.py +209 -0
  53. brainpalace_rag-26.5.1/brainpalace_server/models/job.py +339 -0
  54. brainpalace_rag-26.5.1/brainpalace_server/models/memory.py +98 -0
  55. brainpalace_rag-26.5.1/brainpalace_server/models/query.py +247 -0
  56. brainpalace_rag-26.5.1/brainpalace_server/models/session_extract.py +85 -0
  57. brainpalace_rag-26.5.1/brainpalace_server/project_root.py +86 -0
  58. brainpalace_rag-26.5.1/brainpalace_server/providers/__init__.py +64 -0
  59. brainpalace_rag-26.5.1/brainpalace_server/providers/base.py +258 -0
  60. brainpalace_rag-26.5.1/brainpalace_server/providers/embedding/__init__.py +23 -0
  61. brainpalace_rag-26.5.1/brainpalace_server/providers/embedding/cohere.py +163 -0
  62. brainpalace_rag-26.5.1/brainpalace_server/providers/embedding/ollama.py +232 -0
  63. brainpalace_rag-26.5.1/brainpalace_server/providers/embedding/openai.py +118 -0
  64. brainpalace_rag-26.5.1/brainpalace_server/providers/exceptions.py +93 -0
  65. brainpalace_rag-26.5.1/brainpalace_server/providers/factory.py +219 -0
  66. brainpalace_rag-26.5.1/brainpalace_server/providers/reranker/__init__.py +17 -0
  67. brainpalace_rag-26.5.1/brainpalace_server/providers/reranker/base.py +111 -0
  68. brainpalace_rag-26.5.1/brainpalace_server/providers/reranker/ollama.py +287 -0
  69. brainpalace_rag-26.5.1/brainpalace_server/providers/reranker/sentence_transformers.py +200 -0
  70. brainpalace_rag-26.5.1/brainpalace_server/providers/summarization/__init__.py +41 -0
  71. brainpalace_rag-26.5.1/brainpalace_server/providers/summarization/anthropic.py +87 -0
  72. brainpalace_rag-26.5.1/brainpalace_server/providers/summarization/gemini.py +74 -0
  73. brainpalace_rag-26.5.1/brainpalace_server/providers/summarization/grok.py +95 -0
  74. brainpalace_rag-26.5.1/brainpalace_server/providers/summarization/ollama.py +114 -0
  75. brainpalace_rag-26.5.1/brainpalace_server/providers/summarization/openai.py +87 -0
  76. brainpalace_rag-26.5.1/brainpalace_server/runtime.py +111 -0
  77. brainpalace_rag-26.5.1/brainpalace_server/services/__init__.py +46 -0
  78. brainpalace_rag-26.5.1/brainpalace_server/services/chunk_eviction_service.py +229 -0
  79. brainpalace_rag-26.5.1/brainpalace_server/services/content_injector.py +320 -0
  80. brainpalace_rag-26.5.1/brainpalace_server/services/embedding_cache.py +556 -0
  81. brainpalace_rag-26.5.1/brainpalace_server/services/file_type_presets.py +122 -0
  82. brainpalace_rag-26.5.1/brainpalace_server/services/file_watcher_service.py +369 -0
  83. brainpalace_rag-26.5.1/brainpalace_server/services/folder_manager.py +254 -0
  84. brainpalace_rag-26.5.1/brainpalace_server/services/git_history_index_service.py +142 -0
  85. brainpalace_rag-26.5.1/brainpalace_server/services/indexing_service.py +905 -0
  86. brainpalace_rag-26.5.1/brainpalace_server/services/manifest_tracker.py +239 -0
  87. brainpalace_rag-26.5.1/brainpalace_server/services/memory_service.py +293 -0
  88. brainpalace_rag-26.5.1/brainpalace_server/services/query_cache.py +177 -0
  89. brainpalace_rag-26.5.1/brainpalace_server/services/query_service.py +1097 -0
  90. brainpalace_rag-26.5.1/brainpalace_server/services/session_context_service.py +115 -0
  91. brainpalace_rag-26.5.1/brainpalace_server/services/session_extract_service.py +238 -0
  92. brainpalace_rag-26.5.1/brainpalace_server/services/session_index_service.py +141 -0
  93. brainpalace_rag-26.5.1/brainpalace_server/services/session_linker.py +145 -0
  94. brainpalace_rag-26.5.1/brainpalace_server/services/session_triplet_types.py +39 -0
  95. brainpalace_rag-26.5.1/brainpalace_server/services/session_watcher.py +107 -0
  96. brainpalace_rag-26.5.1/brainpalace_server/storage/__init__.py +46 -0
  97. brainpalace_rag-26.5.1/brainpalace_server/storage/chroma/__init__.py +5 -0
  98. brainpalace_rag-26.5.1/brainpalace_server/storage/chroma/backend.py +439 -0
  99. brainpalace_rag-26.5.1/brainpalace_server/storage/factory.py +139 -0
  100. brainpalace_rag-26.5.1/brainpalace_server/storage/graph_store.py +746 -0
  101. brainpalace_rag-26.5.1/brainpalace_server/storage/postgres/__init__.py +22 -0
  102. brainpalace_rag-26.5.1/brainpalace_server/storage/postgres/backend.py +666 -0
  103. brainpalace_rag-26.5.1/brainpalace_server/storage/postgres/config.py +154 -0
  104. brainpalace_rag-26.5.1/brainpalace_server/storage/postgres/connection.py +199 -0
  105. brainpalace_rag-26.5.1/brainpalace_server/storage/postgres/keyword_ops.py +222 -0
  106. brainpalace_rag-26.5.1/brainpalace_server/storage/postgres/schema.py +261 -0
  107. brainpalace_rag-26.5.1/brainpalace_server/storage/postgres/vector_ops.py +197 -0
  108. brainpalace_rag-26.5.1/brainpalace_server/storage/protocol.py +336 -0
  109. brainpalace_rag-26.5.1/brainpalace_server/storage/sqlite_graph_store.py +352 -0
  110. brainpalace_rag-26.5.1/brainpalace_server/storage/vector_store.py +593 -0
  111. brainpalace_rag-26.5.1/brainpalace_server/storage_paths.py +111 -0
  112. brainpalace_rag-26.5.1/pyproject.toml +118 -0
@@ -0,0 +1,399 @@
1
+ Metadata-Version: 2.1
2
+ Name: brainpalace-rag
3
+ Version: 26.5.1
4
+ Summary: BrainPalace RAG - Intelligent document indexing and semantic search server that gives AI agents long-term memory
5
+ Home-page: https://github.com/bxw91/brainpalace
6
+ License: MIT
7
+ Keywords: brainpalace,rag,semantic-search,ai-memory,llm-memory,documentation,indexing,llama-index,chromadb,ai-agent,claude-code,agent-memory
8
+ Author: bxw91
9
+ Requires-Python: >=3.10,<4.0
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Documentation
18
+ Classifier: Topic :: Text Processing :: Indexing
19
+ Provides-Extra: graphrag
20
+ Provides-Extra: postgres
21
+ Requires-Dist: anthropic (>=0.40.0,<0.41.0)
22
+ Requires-Dist: asyncpg (>=0.29.0,<0.30.0) ; extra == "postgres"
23
+ Requires-Dist: cachetools (>=5.3)
24
+ Requires-Dist: chromadb (>=0.5.0,<0.6.0)
25
+ Requires-Dist: click (>=8.1.0,<9.0.0)
26
+ Requires-Dist: cohere (>=5.0.0,<6.0.0)
27
+ Requires-Dist: fastapi (>=0.115.0,<0.116.0)
28
+ Requires-Dist: google-genai (>=1.0.0,<2.0.0)
29
+ Requires-Dist: langextract (>=1.0.0,<2.0.0) ; extra == "graphrag"
30
+ Requires-Dist: llama-index-core (>=0.14.0,<0.15.0)
31
+ Requires-Dist: llama-index-embeddings-openai (>=0.5.0,<0.6.0)
32
+ Requires-Dist: llama-index-llms-openai (>=0.6.12,<0.7.0)
33
+ Requires-Dist: llama-index-readers-file (>=0.5.0,<0.6.0)
34
+ Requires-Dist: llama-index-retrievers-bm25 (>=0.6.0,<0.7.0)
35
+ Requires-Dist: openai (>=1.57.0,<2.0.0)
36
+ Requires-Dist: pathspec (>=0.12.0,<0.13.0)
37
+ Requires-Dist: pydantic (>=2.10.0,<3.0.0)
38
+ Requires-Dist: pydantic-settings (>=2.6.0,<3.0.0)
39
+ Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
40
+ Requires-Dist: pyyaml (>=6.0.0,<7.0.0)
41
+ Requires-Dist: rank-bm25 (>=0.2.2,<0.3.0)
42
+ Requires-Dist: sentence-transformers (>=3.4.0,<4.0.0)
43
+ Requires-Dist: sqlalchemy[asyncio] (>=2.0.0,<3.0.0) ; extra == "postgres"
44
+ Requires-Dist: tiktoken (>=0.8.0,<0.9.0)
45
+ Requires-Dist: tree-sitter-language-pack (>=0.7.3,<0.8.0)
46
+ Requires-Dist: uvicorn[standard] (>=0.32.0,<0.33.0)
47
+ Project-URL: Documentation, https://github.com/bxw91/brainpalace#readme
48
+ Project-URL: Repository, https://github.com/bxw91/brainpalace
49
+ Description-Content-Type: text/markdown
50
+
51
+ # BrainPalace RAG Server
52
+
53
+ > **BrainPalace** (formerly doc-serve) is an intelligent document indexing and semantic search system designed to give AI agents long-term memory.
54
+
55
+ AI agents need persistent memory to be truly useful. BrainPalace provides the retrieval infrastructure that enables context-aware, knowledge-grounded AI interactions.
56
+
57
+ [![PyPI version](https://badge.fury.io/py/brainpalace-rag.svg)](https://pypi.org/project/brainpalace-rag/)
58
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
59
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
60
+
61
+ ## Installation
62
+
63
+ ```bash
64
+ pip install brainpalace-rag
65
+ ```
66
+
67
+ ## Quick Start
68
+
69
+ 1. Set environment variables:
70
+ ```bash
71
+ export OPENAI_API_KEY=your-key
72
+ export ANTHROPIC_API_KEY=your-key
73
+ ```
74
+
75
+ 2. Start the server:
76
+ ```bash
77
+ brainpalace-serve
78
+ ```
79
+
80
+ The server will start at `http://127.0.0.1:8000`.
81
+
82
+ > **Note**: The legacy command `doc-serve` is still available but deprecated. Please use `brainpalace-serve` for new installations.
83
+
84
+ ## Search Capabilities
85
+
86
+ BrainPalace provides multiple search strategies to match your retrieval needs:
87
+
88
+ | Search Type | Description | Best For |
89
+ |-------------|-------------|----------|
90
+ | **Semantic Search** | Natural language queries using OpenAI embeddings (`text-embedding-3-large`) | Conceptual questions, finding related content |
91
+ | **Keyword Search (BM25)** | Traditional keyword matching with TF-IDF ranking | Exact matches, technical terms, code identifiers |
92
+ | **Hybrid Search** | Combines vector + BM25 for best of both approaches | General-purpose queries, balanced recall/precision |
93
+ | **GraphRAG** | Knowledge graph-based retrieval for relationship-aware queries | Understanding connections, multi-hop reasoning |
94
+
95
+ ## Features
96
+
97
+ - **Document Indexing**: Load and index documents from folders (PDF, Markdown, TXT, DOCX, HTML)
98
+ - **AST-Aware Code Ingestion**: Smart parsing for Python, TypeScript, JavaScript, Java, Go, Rust, C, C++
99
+ - **Multi-Strategy Retrieval**: Semantic, keyword, hybrid, and graph-based search
100
+ - **OpenAI Embeddings**: Uses `text-embedding-3-large` for high-quality embeddings
101
+ - **Claude Summarization**: AI-powered code summaries for better context
102
+ - **Chroma Vector Store**: Persistent, thread-safe vector database
103
+ - **FastAPI**: Modern, high-performance REST API with OpenAPI documentation
104
+
105
+ ## Prerequisites
106
+
107
+ - Python 3.10+
108
+ - OpenAI API key (for embeddings)
109
+ - Anthropic API key (for summarization)
110
+
111
+ ## GraphRAG Configuration (Feature 113)
112
+
113
+ BrainPalace supports optional GraphRAG (Graph-based Retrieval-Augmented Generation) for enhanced relationship-aware queries.
114
+
115
+ ### Enabling GraphRAG
116
+
117
+ Set the environment variable to enable graph indexing:
118
+
119
+ ```bash
120
+ export ENABLE_GRAPH_INDEX=true
121
+ ```
122
+
123
+ ### Configuration Options
124
+
125
+ | Variable | Default | Description |
126
+ |----------|---------|-------------|
127
+ | `ENABLE_GRAPH_INDEX` | `false` | Enable/disable GraphRAG features |
128
+ | `GRAPH_STORE_TYPE` | `simple` | Graph backend: `simple` (JSON) or `kuzu` (embedded DB) |
129
+ | `GRAPH_MAX_TRIPLETS_PER_CHUNK` | `10` | Maximum entities to extract per document chunk |
130
+ | `GRAPH_USE_CODE_METADATA` | `true` | Extract relationships from code AST metadata |
131
+ | `GRAPH_USE_LLM_EXTRACTION` | `true` | Use LLM for entity extraction from documents |
132
+ | `GRAPH_TRAVERSAL_DEPTH` | `2` | Default traversal depth for graph queries |
133
+
134
+ ### Query Modes
135
+
136
+ With GraphRAG enabled, you have access to additional query modes:
137
+
138
+ - **`graph`**: Query using only the knowledge graph (entity relationships)
139
+ - **`multi`**: Combines vector search, BM25, and graph results using RRF fusion
140
+
141
+ ### Example: Graph Query
142
+
143
+ ```bash
144
+ # CLI
145
+ brainpalace query "authentication service" --mode graph
146
+
147
+ # API
148
+ curl -X POST http://localhost:8000/query \
149
+ -H "Content-Type: application/json" \
150
+ -d '{"query": "authentication service", "mode": "graph", "top_k": 10}'
151
+ ```
152
+
153
+ ### Example: Multi-Mode Query
154
+
155
+ ```bash
156
+ # CLI
157
+ brainpalace query "user login flow" --mode multi
158
+
159
+ # API
160
+ curl -X POST http://localhost:8000/query \
161
+ -H "Content-Type: application/json" \
162
+ -d '{"query": "user login flow", "mode": "multi", "top_k": 5}'
163
+ ```
164
+
165
+ ### Rebuilding the Graph Index
166
+
167
+ To rebuild only the graph index without re-indexing documents:
168
+
169
+ ```bash
170
+ curl -X POST "http://localhost:8000/index?rebuild_graph=true" \
171
+ -H "Content-Type: application/json" \
172
+ -d '{"folder_path": "."}'
173
+ ```
174
+
175
+ ### Optional Dependencies
176
+
177
+ For enhanced GraphRAG features, install optional dependency groups:
178
+
179
+ ```bash
180
+ # For Kuzu graph store (production workloads)
181
+ poetry install --with graphrag-kuzu
182
+
183
+ # For enhanced entity extraction
184
+ poetry install --with graphrag
185
+ ```
186
+
187
+ ## Two-Stage Reranking (Feature 123)
188
+
189
+ BrainPalace supports optional two-stage retrieval with reranking for improved search precision. When enabled, the system:
190
+
191
+ 1. **Stage 1**: Retrieves more candidates than requested (e.g., 50 candidates for top_k=5)
192
+ 2. **Stage 2**: Reranks candidates using a cross-encoder model for more accurate relevance scoring
193
+
194
+ ### Enabling Reranking
195
+
196
+ Set the following environment variables:
197
+
198
+ ```bash
199
+ # Enable two-stage reranking (default: false)
200
+ ENABLE_RERANKING=true
201
+
202
+ # Choose provider (default: sentence-transformers)
203
+ RERANKER_PROVIDER=sentence-transformers # or "ollama"
204
+
205
+ # Choose model (default: cross-encoder/ms-marco-MiniLM-L-6-v2)
206
+ RERANKER_MODEL=cross-encoder/ms-marco-MiniLM-L-6-v2
207
+
208
+ # Stage 1 retrieval multiplier (default: 10)
209
+ RERANKER_TOP_K_MULTIPLIER=10
210
+
211
+ # Maximum candidates for Stage 1 (default: 100)
212
+ RERANKER_MAX_CANDIDATES=100
213
+
214
+ # Batch size for reranking inference (default: 32)
215
+ RERANKER_BATCH_SIZE=32
216
+ ```
217
+
218
+ ### Provider Options
219
+
220
+ | Provider | Model | Latency | Description |
221
+ |----------|-------|---------|-------------|
222
+ | sentence-transformers | cross-encoder/ms-marco-MiniLM-L-6-v2 | ~50ms | Recommended. Fast, accurate cross-encoder. |
223
+ | sentence-transformers | cross-encoder/ms-marco-MiniLM-L-12-v2 | ~100ms | Slower but more accurate. |
224
+ | ollama | llama3.2:1b | ~500ms | Fully local, no HuggingFace download. |
225
+
226
+ ### YAML Configuration
227
+
228
+ You can also configure reranking in `config.yaml`:
229
+
230
+ ```yaml
231
+ reranker:
232
+ provider: sentence-transformers
233
+ model: cross-encoder/ms-marco-MiniLM-L-6-v2
234
+ params:
235
+ batch_size: 32
236
+ ```
237
+
238
+ ### Graceful Degradation
239
+
240
+ If the reranker fails (model unavailable, timeout, etc.), the system automatically falls back to Stage 1 results. This ensures queries never fail due to reranking issues.
241
+
242
+ ### Response Fields
243
+
244
+ When reranking is enabled, query results include additional fields:
245
+
246
+ - `rerank_score`: The cross-encoder relevance score
247
+ - `original_rank`: The position before reranking (1-indexed)
248
+
249
+ Example response:
250
+ ```json
251
+ {
252
+ "results": [
253
+ {
254
+ "text": "Document content...",
255
+ "source": "docs/guide.md",
256
+ "score": 0.95,
257
+ "rerank_score": 0.95,
258
+ "original_rank": 5,
259
+ "chunk_id": "chunk_abc123"
260
+ }
261
+ ]
262
+ }
263
+ ```
264
+
265
+ ## Development Installation
266
+
267
+ ```bash
268
+ cd brainpalace-server
269
+ poetry install
270
+ ```
271
+
272
+ ### Configuration
273
+
274
+ Copy the environment template and configure:
275
+
276
+ ```bash
277
+ cp ../.env.example .env
278
+ # Edit .env with your API keys
279
+ ```
280
+
281
+ Required environment variables:
282
+ - `OPENAI_API_KEY`: Your OpenAI API key for embeddings
283
+ - `ANTHROPIC_API_KEY`: Your Anthropic API key for summarization
284
+
285
+ ### Running the Server
286
+
287
+ ```bash
288
+ # Development mode
289
+ poetry run uvicorn brainpalace_server.api.main:app --reload
290
+
291
+ # Or use the entry point
292
+ poetry run brainpalace-serve
293
+ ```
294
+
295
+ ### API Documentation
296
+
297
+ Once running, visit:
298
+ - Swagger UI: http://127.0.0.1:8000/docs
299
+ - ReDoc: http://127.0.0.1:8000/redoc
300
+ - OpenAPI JSON: http://127.0.0.1:8000/openapi.json
301
+
302
+ ## API Endpoints
303
+
304
+ ### Health
305
+
306
+ - `GET /health` - Server health status
307
+ - `GET /health/status` - Detailed indexing status
308
+
309
+ ### Indexing
310
+
311
+ - `POST /index` - Start indexing documents from a folder
312
+ - `POST /index/add` - Add documents to existing index
313
+ - `DELETE /index` - Reset the index
314
+
315
+ ### Querying
316
+
317
+ - `POST /query` - Semantic search query
318
+ - `GET /query/count` - Get indexed document count
319
+
320
+ ## Example Usage
321
+
322
+ ### Index Documents
323
+
324
+ ```bash
325
+ curl -X POST http://localhost:8000/index \
326
+ -H "Content-Type: application/json" \
327
+ -d '{"folder_path": "/path/to/docs"}'
328
+ ```
329
+
330
+ ### Query Documents
331
+
332
+ ```bash
333
+ curl -X POST http://localhost:8000/query \
334
+ -H "Content-Type: application/json" \
335
+ -d '{"query": "How do I configure authentication?", "top_k": 5}'
336
+ ```
337
+
338
+ ## Architecture
339
+
340
+ ```
341
+ brainpalace_server/
342
+ ├── api/
343
+ │ ├── main.py # FastAPI application
344
+ │ └── routers/ # Endpoint handlers
345
+ ├── config/
346
+ │ └── settings.py # Configuration management
347
+ ├── models/ # Pydantic request/response models
348
+ ├── indexing/
349
+ │ ├── document_loader.py # Document loading
350
+ │ ├── chunking.py # Text chunking
351
+ │ └── embedding.py # Embedding generation
352
+ ├── services/
353
+ │ ├── indexing_service.py # Indexing orchestration
354
+ │ └── query_service.py # Query execution
355
+ └── storage/
356
+ └── vector_store.py # Chroma vector store
357
+ ```
358
+
359
+ ## Development
360
+
361
+ ### Running Tests
362
+
363
+ ```bash
364
+ poetry run pytest
365
+ ```
366
+
367
+ ### Code Formatting
368
+
369
+ ```bash
370
+ poetry run black brainpalace_server/
371
+ poetry run ruff check brainpalace_server/
372
+ ```
373
+
374
+ ### Type Checking
375
+
376
+ ```bash
377
+ poetry run mypy brainpalace_server/
378
+ ```
379
+
380
+ ## Documentation
381
+
382
+ - [User Guide](https://github.com/bxw91/brainpalace/wiki/User-Guide) - Getting started and usage
383
+ - [Developer Guide](https://github.com/bxw91/brainpalace/wiki/Developer-Guide) - Contributing and development
384
+ - [API Reference](https://github.com/bxw91/brainpalace/wiki/API-Reference) - Full API documentation
385
+
386
+ ## Release Information
387
+
388
+ - **Current Version**: See [pyproject.toml](./pyproject.toml)
389
+ - **Release Notes**: [GitHub Releases](https://github.com/bxw91/brainpalace/releases)
390
+ - **Changelog**: [Latest Release](https://github.com/bxw91/brainpalace/releases/latest)
391
+
392
+ ## Related Packages
393
+
394
+ - [brainpalace-cli](https://pypi.org/project/brainpalace-cli/) - Command-line interface for BrainPalace
395
+
396
+ ## License
397
+
398
+ MIT
399
+