mts1b-frontends
All frontends: webui (Next.js), TUI (Textual), CLI (
mts+ Python helpers).
Repo: github.com/MTS1B/mts1b-frontends Layer: 7 Wave: 2 (months 4-7) Depends on: foundation, every service repo's gRPC/REST API Audience: every operator
What it is
Three UIs sharing a common API client + visualization layer:
| Frontend | Audience | When to use |
|---|---|---|
| webui (Next.js) | operators, researchers | day-to-day desk view, dashboards, deep dives |
| TUI (Textual) | over SSH, ops | when you only have a terminal |
CLI (mts) | scripts, automation | composable, pipeable, scriptable |
Module layout
mts1b_frontends/
├── webui/
│ ├── apps/web/ # Next.js 14 app
│ │ ├── app/
│ │ │ ├── desks/<desk>/page.tsx
│ │ │ ├── replay/page.tsx # backtest replay UI
│ │ │ ├── matrix/page.tsx # session matrix
│ │ │ ├── lab/page.tsx
│ │ │ ├── signals/page.tsx
│ │ │ ├── zilla/page.tsx
│ │ │ └── ...
│ │ └── lib/api/ # auto-gen from foundation OpenAPI
├── tui/
│ ├── apps/textual/ # Textual app
│ │ ├── screens/
│ │ │ ├── positions.py
│ │ │ ├── orders.py
│ │ │ ├── halts.py
│ │ │ └── ...
│ │ └── widgets/
├── cli/
│ ├── bin/mts # entrypoint
│ ├── cmds/
│ │ ├── cmd_halt.py
│ │ ├── cmd_resume.py
│ │ ├── cmd_cancel_all.py
│ │ ├── cmd_flatten_paper.py
│ │ └── ...
│ └── helpers/ # python helpers for scripts
└── api_client/ # shared client used by all three
├── __init__.py
├── client.py
└── generated/ # auto-gen from OpenAPI specs
webui (Next.js)
Multiple "desks" — focused views per workflow:
| Desk | Purpose |
|---|---|
| Replay | step-through backtest with bookmarks + screenshots + manual paper-trade |
| Matrix | session-matrix grid (6 sessions × 5 asset classes) of candidate strategies |
| LAB | parameter sweep visualization, sensitivity heatmaps, MC/bootstrap CIs |
| Signals | cross-asset signal IC matrix, decay curves, conditional distributions |
| Zilla | 40+ pre-built and adaptive baskets vs SPY |
| Funds | per-fund NAV, exposure, P/L attribution |
| Risk | live envelope status, gate-failure breakdown |
| Ops | halt control, audit timeline, watchdog status |
Hot-reload during dev: npm run dev in webui/apps/web.
TUI (Textual)
Same primitives as webui but rendered for the terminal. Useful over SSH or during a panic:
mts tui
Keyboard navigation, mouse where supported. All operator commands (halt / cancel-all / flatten / resume) are one keystroke.
CLI (mts)
The most composable interface. Designed for pipes + scripts:
mts mts1b-treasury funds list --json | jq '.[] | select(.broker == "ibkr")'
mts mts1b-oms positions list --fund-id live-momentum --format csv > positions.csv
mts mts1b-research strategies list --enabled-only \
| mts mts1b-research strategy show --strategy-id $(awk '{print $1}')
Top-level commands by service:
mts mts1b-treasury funds, transfers, nav
mts mts1b-oms orders, positions, fills
mts mts1b-research strategies, factors, ladder, drift
mts mts1b-riskengine envelope, gates, halts
mts mts1b-brokers status, test
mts mts1b-deploy install, status, logs, restart, ...
mts mts1b-platform tail (NATS), audit
mts cmd halt, resume, cancel-all, flatten-paper
Plus shorthand:
mts ls # positions across all funds
mts halt # firm-wide halt with confirmation
mts logs <service> # tail a service's logs
API client (shared)
Auto-generated from each service's OpenAPI spec (which is derived from mts1b-foundation types):
// webui/apps/web/lib/api/oms.ts (generated)
import { OmsClient } from "@mts1b/api-client";
const oms = new OmsClient({ baseUrl: "http://localhost:8001" });
const positions = await oms.getPositions({ fundId: "paper-momentum" });
# tui + cli use the same client (Python)
from mts1b_frontends.api_client import OmsClient
oms = OmsClient(base_url="http://localhost:8001")
positions = await oms.get_positions(fund_id="paper-momentum")
Regenerated whenever mts1b-foundation ships a new minor version.
Auth
OAuth2 (Authentik) for webui; static token for TUI/CLI (per-operator). Tokens stored in ~/.mts1b/auth.json (chmod 600).
mts auth login # opens browser to Authentik
mts auth whoami
mts auth logout
Themes
Dark + light. webui is dark by default. TUI follows terminal color scheme. CLI uses Rich for formatting (auto-detects 256-color / truecolor / no-color).
Build + run
# webui
cd webui/apps/web
npm install
npm run dev # localhost:3000
# TUI
cd tui/apps/textual
pip install -e .
mts tui
# CLI
cd cli
pip install -e .
mts --help
Deployment
Via mts1b-deploy:
- webui: containerized Next.js standalone build, served by Caddy
- TUI: not deployed; users install locally for SSH connections to the host
- CLI: pre-installed in every Docker image; users
pip install mts1b-clion their workstation
Roadmap
| Version | Items |
|---|---|
| 0.1 (Wave 2) | webui (replay/matrix/lab/signals/zilla/funds/risk/ops), TUI, CLI |
| 0.2 (Wave 2) | mobile-responsive webui, Authentik OAuth |
| 0.3 (Wave 3) | Real-time WebSocket updates across the board |
| 0.4 (Wave 3) | iPad/touch optimization |
| 1.0 (LTS) | Stable URL structure |
See also
- Foundation OpenAPI exports — the source of truth for the API client
- All services' REST/gRPC APIs — consumed here