| # /root/backend/ β RMI CANONICAL BACKEND |
|
|
| ## β οΈ THIS IS THE ONE AND ONLY BACKEND |
|
|
| All other copies are dead. If you find code at `/srv/rugmuncher-backend/main.py`, |
| `/root/rmi/backend/`, or anywhere else β it's STALE. Work here ONLY. |
|
|
| ## Architecture |
|
|
| ``` |
| /root/backend/ |
| βββ main.py # FastAPI app (5040 lines) β entry point |
| βββ Dockerfile # Backend container build |
| βββ Dockerfile.worker # Worker container build |
| βββ requirements.txt # Python dependencies |
| βββ .env.example # All required env vars documented |
| βββ generate_env.py # Auto-generate .env from Hermes config |
| βββ app/ # All application modules |
| β βββ news_service.py # 15+ source news aggregator |
| β βββ rag_service.py # Redis-based RAG vector store |
| β βββ auth.py # Authentication |
| β βββ payments.py # Payment processing |
| β βββ content_syndicate.py # Multi-platform content publishing |
| β βββ ... (80+ modules) |
| ``` |
|
|
| ## How to Use |
|
|
| ### Backend changes (Python): |
| ```bash |
| # Edit files here. Volume mount means changes are LIVE: |
| docker restart rmi-backend |
| |
| # Or for dependency changes, rebuild: |
| cd /srv/rugmuncher-backend |
| docker compose build backend --no-cache |
| docker compose up -d backend |
| ``` |
|
|
| ### Environment setup: |
| ```bash |
| python3 generate_env.py --force |
| # Then edit .env to fill in missing values |
| ``` |
|
|
| ### API documentation: |
| - Swagger: http://localhost:8000/docs |
| - Health: http://localhost:8000/health |
|
|
| ## Docker Compose |
|
|
| Compose file: `/srv/rugmuncher-backend/docker-compose.yml` |
| Context: `context: /root/backend` (builds from here) |
| Mount: `/root/backend:/app` (live code, no rebuild needed) |
|
|
| All container names use hyphens: `rmi-backend`, `rmi-worker`, `rmi-n8n`, etc. |
|
|
| ## Development Rules |
|
|
| 1. **Never edit files outside this directory** for backend work |
| 2. **Always `python3 generate_env.py`** after adding new env vars |
| 3. **`.env` never committed** β use `.env.example` as template |
| 4. **Test with `curl localhost:8000/health`** after changes |
| 5. **Volume mount = live reload** β just restart the container |
| |
| ## Related Systems |
| |
| | System | Location | Container | |
| |--------|----------|-----------| |
| | n8n workflows | /root/n8n-data/ | rmi-n8n | |
| | Orchestrator | /srv/rugmuncher-backend/orchestrator/ | rmi-orchestrator | |
| | Telegram bot | /srv/rugmuncher-backend/bots/telegram/ | rmi-telegram-bot | |
| | Frontend | /srv/rugmuncher-backend/rmi-frontend/ | Vercel/Cloudflare | |
| | Hermes AI | /root/.hermes/ | CLI process | |
| | Langfuse | /srv/langfuse/ | Separate compose | |
| | Redis | Composed | rmi-redis | |
| |