mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-17 21:09:40 +02:00
Migrate matrix-project-doc-bot from raw fetch to @manacore/shared-llm and remove the unused openai npm package. The bot was already using mana-llm and mana-stt (not OpenAI directly), but the code still had raw fetch calls and the openai package installed. Changes: - generation.service.ts: raw fetch → llm.chat() via LlmClientService - app.module.ts: add LlmModule.forRootAsync() - Remove openai dependency (was unused in code) - Update CLAUDE.md: document actual AI stack (mana-llm + mana-stt) - Update TECH_STACK_INDEPENDENCE.md: mark Prio 1-3 as completed - Prio 1: Picture App → mana-image-gen ✅ - Prio 2: Project Doc Bot → Ollama + mana-stt ✅ - Prio 3: All LLM calls via mana-llm ✅ - Self-hosted percentage: 75% → ~80% Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
122 lines
2.9 KiB
Markdown
122 lines
2.9 KiB
Markdown
# Matrix Project Doc Bot - Claude Code Guidelines
|
|
|
|
## Overview
|
|
|
|
Matrix Project Doc Bot collects photos, voice notes, and text for projects and generates blog posts. GDPR-compliant replacement for telegram-project-doc-bot.
|
|
|
|
## Tech Stack
|
|
|
|
- **Framework**: NestJS 10
|
|
- **Matrix**: matrix-bot-sdk
|
|
- **Database**: Drizzle ORM + PostgreSQL
|
|
- **Storage**: S3 (MinIO)
|
|
- **AI**: mana-llm (Ollama/Gemma 3 for generation), mana-stt (Whisper for transcription) — fully self-hosted
|
|
|
|
## Commands
|
|
|
|
```bash
|
|
pnpm install
|
|
pnpm start:dev # Development with hot reload
|
|
pnpm build # Production build
|
|
pnpm type-check # TypeScript check
|
|
pnpm db:push # Push schema to database
|
|
pnpm db:studio # Open Drizzle Studio
|
|
```
|
|
|
|
## Matrix Commands
|
|
|
|
| Command | Description |
|
|
|---------|-------------|
|
|
| `!new [Name]` | Create new project |
|
|
| `!projects` | List all projects |
|
|
| `!switch [ID]` | Switch to project |
|
|
| `!status` | Show project status |
|
|
| `!archive` | Archive current project |
|
|
| `!generate` | Generate blog post (casual) |
|
|
| `!generate [style]` | Generate with specific style |
|
|
| `!styles` | Show available styles |
|
|
| `!export` | Export last generation |
|
|
|
|
## Media Handling
|
|
|
|
- **Photos**: Saved to S3, stored in database
|
|
- **Voice**: Saved to S3, transcribed via Whisper
|
|
- **Text**: Stored directly in database
|
|
|
|
## Blog Styles
|
|
|
|
| Style | Description |
|
|
|-------|-------------|
|
|
| `casual` | Friendly, personal blog post |
|
|
| `technical` | Detailed technical report |
|
|
| `tutorial` | Step-by-step guide |
|
|
| `social` | Short social media post |
|
|
| `story` | Storytelling format |
|
|
|
|
## Environment Variables
|
|
|
|
```env
|
|
PORT=3313
|
|
|
|
# Matrix
|
|
MATRIX_HOMESERVER_URL=http://localhost:8008
|
|
MATRIX_ACCESS_TOKEN=syt_xxx
|
|
MATRIX_ALLOWED_USERS=@user:mana.how
|
|
MATRIX_STORAGE_PATH=./data/bot-storage.json
|
|
|
|
# Database
|
|
DATABASE_URL=postgresql://postgres:password@localhost:5432/project_doc_bot
|
|
|
|
# S3 Storage
|
|
S3_ENDPOINT=http://localhost:9000
|
|
S3_REGION=us-east-1
|
|
S3_ACCESS_KEY=minioadmin
|
|
S3_SECRET_KEY=minioadmin
|
|
S3_BUCKET=project-doc-bot
|
|
|
|
# OpenAI
|
|
OPENAI_API_KEY=sk-xxx
|
|
OPENAI_MODEL=gpt-4o-mini
|
|
OPENAI_WHISPER_MODEL=whisper-1
|
|
```
|
|
|
|
## Database Schema
|
|
|
|
```sql
|
|
-- projects table
|
|
CREATE TABLE projects (
|
|
id UUID PRIMARY KEY,
|
|
matrix_user_id TEXT NOT NULL,
|
|
name TEXT NOT NULL,
|
|
status TEXT DEFAULT 'active',
|
|
created_at TIMESTAMP DEFAULT NOW(),
|
|
updated_at TIMESTAMP DEFAULT NOW()
|
|
);
|
|
|
|
-- project_items table
|
|
CREATE TABLE project_items (
|
|
id UUID PRIMARY KEY,
|
|
project_id UUID REFERENCES projects(id),
|
|
type TEXT NOT NULL, -- photo, voice, text
|
|
content TEXT,
|
|
media_url TEXT,
|
|
media_mxc_url TEXT,
|
|
duration INTEGER,
|
|
created_at TIMESTAMP DEFAULT NOW()
|
|
);
|
|
|
|
-- generations table
|
|
CREATE TABLE generations (
|
|
id UUID PRIMARY KEY,
|
|
project_id UUID REFERENCES projects(id),
|
|
style TEXT NOT NULL,
|
|
content TEXT NOT NULL,
|
|
created_at TIMESTAMP DEFAULT NOW()
|
|
);
|
|
```
|
|
|
|
## Health Check
|
|
|
|
```bash
|
|
curl http://localhost:3313/health
|
|
```
|