mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-19 10:21:24 +02:00
Replace 21 separate NestJS Matrix bot processes (~2.1 GB RAM, ~4.2 GB Docker images) with a single Go binary using plugin architecture (8.6 MB binary, ~30 MB RAM). New services: - services/mana-matrix-bot/ — Go Matrix bot with 21 plugins (mautrix-go, Redis sessions) - services/mana-api-gateway-go/ — Go API gateway (rate limiting, API keys, credit billing) Deleted: - 21 services/matrix-*-bot/ directories - packages/bot-services/ and packages/matrix-bot-common/ - Legacy deploy scripts and CI build jobs Updated: - docker-compose.macmini.yml: new Go services, legacy bots removed - CI/CD: change detection + build jobs for Go services - Root package.json: new dev:matrix, build:matrix, test:matrix scripts Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1.5 KiB
1.5 KiB
mana-api-gateway (Go)
Go replacement for the NestJS API Gateway. Handles API key management, rate limiting, credit billing, and service proxying.
Architecture
- Language: Go 1.25
- Database: PostgreSQL (pgx v5)
- Cache/RateLimit: Redis (sliding window)
- Port: 3030
Endpoints
Public API (X-API-Key auth)
POST /v1/search— Web search (1 credit)POST /v1/extract— Content extraction (1 credit)POST /v1/stt/transcribe— Speech-to-text (10 credits/min)POST /v1/tts/synthesize— Text-to-speech (1 credit/1000 chars)
Management API (JWT auth)
POST /api-keys— Create API keyGET /api-keys— List user's keysDELETE /api-keys/{id}— Delete keyGET /api-keys/{id}/usage— Daily usage stats
System
GET /health— Health check (DB + Redis)GET /metrics— Prometheus metrics
Pricing Tiers
| Tier | Rate Limit | Monthly Credits | Price |
|---|---|---|---|
| Free | 10 req/min | 100 | €0 |
| Pro | 100 req/min | 5,000 | €19/mo |
| Enterprise | 1,000 req/min | 50,000 | €99/mo |
Commands
go run ./cmd/server # Dev
go build ./cmd/server # Build
go test ./... # Test
Environment Variables
PORT— Server port (3030)DATABASE_URL— PostgreSQL connectionREDIS_HOST,REDIS_PORT,REDIS_PASSWORDSEARCH_SERVICE_URL,STT_SERVICE_URL,TTS_SERVICE_URLMANA_CORE_AUTH_URL— JWT validationADMIN_USER_IDS— Comma-separated admin user IDs