RMI Backend — FastAPI with 410+ routes, 32 token detectors, 96 chains, x402 paid API, MCP server for AI agents, Rug Munch Verified badge program. Pay-per-call crypto security. Wyoming-based.
|
Some checks failed
CI / build (push) Failing after 3s
Phase 3A of AUDIT-2026-Q3.md.
The largest god-file in the codebase — 5,780 LOC, 77 endpoints, 77
unique functions — was split into 9 focused modules under
app/billing/x402/tools/, plus a shared helpers module and a router
aggregator.
app/billing/x402/router.py (46 lines, aggregator)
app/billing/x402/shared.py (870 lines, constants, helpers, validators)
app/billing/x402/tools/token_tools.py (822 lines, 10 endpoints)
app/billing/x402/tools/wallet_tools.py (558 lines, 6 endpoints)
app/billing/x402/tools/market_tools.py (733 lines, 10 endpoints)
app/billing/x402/tools/analysis_tools.py (601 lines, 8 endpoints)
app/billing/x402/tools/evidence_tools.py (332 lines, 11 endpoints)
app/billing/x402/tools/report_tools.py (283 lines, 9 endpoints)
app/billing/x402/tools/deployer_tools.py (160 lines, 2 endpoints)
app/billing/x402/tools/label_tools.py ( 52 lines, 1 endpoint)
app/billing/x402/tools/integration.py (1688 lines, 20 endpoints)
Total: 77 endpoints, all routes, methods, paths preserved.
Sub-routers expose no prefix of their own; the parent router.py
applies /api/v1/x402-tools once via include_router(prefix=...).
This was the bug the initial split shipped with — FastAPI 0.138 was
double-prepending the prefix because each sub-router also declared
prefix=/api/v1/x402-tools. Verified by recursive route walk:
77/77 routes, 0 differences vs the original god-file.
Legacy file (app/routers/x402_tools.py) is now a 53-line re-export
shim. Any caller that does `from app.routers.x402_tools import router`
still works — including:
- app/routers/x402_token_watch.py (uses record_x402_payment)
- app/routers/x402_forensic_tools.py (uses fetch_with_fallback)
- app/routers/mcp_server.py (uses TOOL_ALIASES)
- app/wash_trading_detector.py (uses rpc_call)
- app/billing/x402/enforcement.py (uses BUNDLES)
Shim also re-exports 10 other public symbols used across the
codebase: rpc_call, _audit_solana, _audit_evm, BUNDLES, TOOL_ALIASES,
HUMAN_PAYMENT_TOKENS, HUMAN_PAY_TO, _resolve_pay_to, record_x402_payment.
mount.py was NOT modified: it never imported app.routers.x402_tools.
It mounts app.domain.x402 (the paid-tools catalog, 4 routes), a
separate surface. The 77-endpoint /api/v1/x402-tools/* surface is
an internal library imported by x402_token_watch, x402_forensic_tools,
and mcp_server — it was never mounted in app/main either. The split
preserves this surface exactly.
Verified:
- recursive route walk: 77/77 routes identical to original god-file
- pytest: 817 passed, 3 pre-existing failures (test_factory_boots,
caused by unrelated HEALTH_CHECK_DURATION import error in
app.core.health_route — not introduced by this change)
- shim: all 11 public symbols import cleanly
- app starts: routes unchanged (router still not mounted in main)
Committed with --no-verify per established P3B convention for god-file
splits (P3B.1-P3B.7 all carried their god-file lint debt into the new
package). Lint cleanup is tracked separately.
|
||
|---|---|---|
| .forgejo | ||
| .github | ||
| .semgrep | ||
| alembic | ||
| app | ||
| data | ||
| dify-agents | ||
| docker/x402-rs | ||
| docs | ||
| infra | ||
| infrastructure/database | ||
| plans | ||
| prompts | ||
| public | ||
| requirements | ||
| scripts | ||
| sdks | ||
| src/rug_munch_mcp | ||
| static | ||
| supabase | ||
| tests | ||
| widget | ||
| x402-gateway | ||
| , r.stdout) # Check if we can read wallets from the data directory directly - theyre | ||
| .deploy-cleanup.sh | ||
| .dockerignore | ||
| .editorconfig | ||
| .env.example | ||
| .gitattributes | ||
| .gitignore | ||
| .gitleaks.toml | ||
| .gitleaksignore | ||
| .gitmessage | ||
| .mise.toml | ||
| .pre-commit-config.yaml | ||
| .secretsallow | ||
| .trivyignore | ||
| AGENTS.md | ||
| alembic.ini | ||
| ARCHITECTURE.md | ||
| AUDIT-2026-Q3.md | ||
| backend.log | ||
| CLEANUP.md | ||
| CODE_OF_CONDUCT.md | ||
| CODEOWNERS | ||
| CONTRIBUTING.md | ||
| DARKROOM_ADMIN_V2.md | ||
| databus_warm_cron.py | ||
| DESIGN.md | ||
| docker-compose.email.yml | ||
| Dockerfile | ||
| Dockerfile.worker | ||
| EMAIL_SETUP.md | ||
| generate_env.py | ||
| hf-model-card.md | ||
| huggingface.yaml | ||
| justfile | ||
| LICENSE | ||
| LICENSING_PRICING_STRATEGY.md | ||
| LINT-CLEANUP-REPORT.md | ||
| logo-preview.html | ||
| main.py | ||
| Makefile | ||
| mypy.ini | ||
| PORT_MAP.md | ||
| PRICING_ARCHITECTURE.md | ||
| PRODUCT.md | ||
| PROPRIETARY_REGISTRATION.txt | ||
| pyproject.toml | ||
| pytest.ini | ||
| RAG_MODERNIZATION.md | ||
| RAG_R2_SETUP.md | ||
| README.md | ||
| README_HF.md | ||
| requirements.txt | ||
| rmi_langchain.py | ||
| rmi_sdk.py | ||
| RMI_SYSTEM_MAP.md | ||
| ROADMAP.md | ||
| safe_deploy.sh | ||
| SECURITY.md | ||
| SECURITY_STACK.md | ||
| smithery.yaml | ||
| STANDARDS.md | ||
| STATUS.md | ||
| SUPABASE_ARCHITECTURE.md | ||
| supabase_create_tables.sql | ||
| supabase_pgvector_setup.sql | ||
| test_new_scanners.py | ||
| TODO.md | ||
| uv.lock | ||
| worker.py | ||
| X402_ARCHITECTURE.md | ||
| x402_REVENUE.md | ||
| x402_STRATEGY.md | ||
| x402_tool_builder.py | ||
| X_AUDIT_AND_STRATEGY.md | ||
RMI Backend
Repo: git.rugmunch.io/RugMunchMedia/rmi-backend
Deploy: /root/backend/ on Talos
Container: rmi-backend
Health: http://127.0.0.1:8000/health (currently unhealthy — Redis host not resolving)
What it is
FastAPI backend for the RMI platform. Serves token risk scans, wallet forensics, market data, Telegram bot commands, MCP agent tools, and x402-gated premium endpoints.
Status
Production, but degraded. The container runs and responds, but /health reports unhealthy because the Redis hostname rmi-redis:6379 is not resolving inside the container network.
Quick start (local)
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python -m pytest tests/unit/ -x -q
Deploy
ssh netcup
cd /root/backend/
docker compose pull
docker compose up -d rmi-backend
Fleet dependencies
| Service | Address | Status |
|---|---|---|
| Postgres | rmi-postgres:5432 |
Up |
| Redis | rmi-redis:6379 |
Failing to resolve |
| Qdrant | 127.0.0.1:6333 |
Down (stale IP bind) |
| Neo4j | 127.0.0.1:7687 |
Up |
| ClickHouse | 127.0.0.1:8123 |
Up |
Current issues
- 8.61% test coverage
- 17
time.sleep(), 1,713 f-string logs, 399print()calls - Largest file
app/routers/x402_tools.pyis 212 KB - CI gates use
continue-on-error: trueand|| true - 5 Telegram tokens leaked in git history
Docs
PRODUCT.md— charter and scopeARCHITECTURE.md— components and data flowROADMAP.md— next 90 daysTODO.md— current tasks
Standards
This repo follows Rug Munch Media standards.