feat: brain service — self-contained second brain knowledge manager
Full backend service with: - FastAPI REST API with CRUD, search, reprocess endpoints - PostgreSQL + pgvector for items and semantic search - Redis + RQ for background job processing - Meilisearch for fast keyword/filter search - Browserless/Chrome for JS rendering and screenshots - OpenAI structured output for AI classification - Local file storage with S3-ready abstraction - Gateway auth via X-Gateway-User-Id header - Own docker-compose stack (6 containers) Classification: fixed folders (Home/Family/Work/Travel/Knowledge/Faith/Projects) and fixed tags (28 predefined). AI assigns exactly 1 folder, 2-3 tags, title, summary, and confidence score per item. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
104
services/brain/docker-compose.yml
Normal file
104
services/brain/docker-compose.yml
Normal file
@@ -0,0 +1,104 @@
|
||||
services:
|
||||
# ── API ──
|
||||
brain-api:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.api
|
||||
container_name: brain-api
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./storage:/app/storage
|
||||
environment:
|
||||
- DATABASE_URL=postgresql+asyncpg://brain:brain@brain-db:5432/brain
|
||||
- REDIS_URL=redis://brain-redis:6379/0
|
||||
- MEILI_URL=http://brain-meili:7700
|
||||
- MEILI_MASTER_KEY=${MEILI_MASTER_KEY:-brain-meili-key}
|
||||
- BROWSERLESS_URL=http://brain-browserless:3000
|
||||
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
||||
- OPENAI_MODEL=${OPENAI_MODEL:-gpt-4o-mini}
|
||||
- PORT=8200
|
||||
- DEBUG=${DEBUG:-0}
|
||||
- TZ=${TZ:-America/Chicago}
|
||||
depends_on:
|
||||
brain-db:
|
||||
condition: service_healthy
|
||||
brain-redis:
|
||||
condition: service_started
|
||||
brain-meili:
|
||||
condition: service_started
|
||||
networks:
|
||||
- default
|
||||
- pangolin
|
||||
|
||||
# ── Worker ──
|
||||
brain-worker:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.worker
|
||||
container_name: brain-worker
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./storage:/app/storage
|
||||
environment:
|
||||
- DATABASE_URL=postgresql+asyncpg://brain:brain@brain-db:5432/brain
|
||||
- REDIS_URL=redis://brain-redis:6379/0
|
||||
- MEILI_URL=http://brain-meili:7700
|
||||
- MEILI_MASTER_KEY=${MEILI_MASTER_KEY:-brain-meili-key}
|
||||
- BROWSERLESS_URL=http://brain-browserless:3000
|
||||
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
||||
- OPENAI_MODEL=${OPENAI_MODEL:-gpt-4o-mini}
|
||||
- TZ=${TZ:-America/Chicago}
|
||||
depends_on:
|
||||
brain-db:
|
||||
condition: service_healthy
|
||||
brain-redis:
|
||||
condition: service_started
|
||||
|
||||
# ── PostgreSQL + pgvector ──
|
||||
brain-db:
|
||||
image: pgvector/pgvector:pg16
|
||||
container_name: brain-db
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- POSTGRES_USER=brain
|
||||
- POSTGRES_PASSWORD=brain
|
||||
- POSTGRES_DB=brain
|
||||
volumes:
|
||||
- ./data/postgres:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U brain"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
|
||||
# ── Redis ──
|
||||
brain-redis:
|
||||
image: redis:7-alpine
|
||||
container_name: brain-redis
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./data/redis:/data
|
||||
|
||||
# ── Meilisearch ──
|
||||
brain-meili:
|
||||
image: getmeili/meilisearch:v1.12
|
||||
container_name: brain-meili
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- MEILI_MASTER_KEY=${MEILI_MASTER_KEY:-brain-meili-key}
|
||||
- MEILI_ENV=production
|
||||
volumes:
|
||||
- ./data/meili:/meili_data
|
||||
|
||||
# ── Browserless (headless Chrome for JS rendering + screenshots) ──
|
||||
brain-browserless:
|
||||
image: ghcr.io/browserless/chromium:latest
|
||||
container_name: brain-browserless
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- MAX_CONCURRENT_SESSIONS=3
|
||||
- TIMEOUT=30000
|
||||
|
||||
networks:
|
||||
pangolin:
|
||||
external: true
|
||||
Reference in New Issue
Block a user