[DECOUPLED_TIERS][<200_LINES/FILE][ES2022/NodeNext][STRICT_TYPES]
System Architecture & Invariants
Decoupled multi-tier system topology, clean domain separation, and hard architectural invariants under 200 lines per file.
Decoupled Multi-Tier System Topology
Zenth is structured into four independent layers ensuring zero coupling between exchange feeds, strategy computation, risk controls, memory persistence, and terminal presentation.
MARKET LAYER
6 Feeds
Zero Private API Keys
STRATEGY ENGINE
SMA + RSI
Deterministic Signals
CAPITAL GUARD
$1,000 Cap
Hard Real-Time Ceilings
PERSISTENCE
5 Backends
Supabase RLS & Local
Domain Package Map
Every functional domain is strictly partitioned into dedicated directories:
| Directory Package | Responsibility & Key Modules | Line Constraint |
|---|---|---|
| src/core/bot | Main loop coordinator, scanner, position manager, session metrics | < 200 lines / file |
| src/core/market | ExchangeRegistry, venue adapters, interval & symbol normalizers | < 200 lines / file |
| src/core/strategy | Indicators math (SMA 9/21, RSI 14, Vol20) and StrategyEngine | < 200 lines / file |
| src/core/risk | RiskManager with $1,000 notional cap and drawdown circuit breakers | < 200 lines / file |
| src/core/memory | Polymorphic DatabaseAdapters (SQLite, PG, Mongo, Supabase, RAM) | < 200 lines / file |
| src/core/export | TXT, CSV, Markdown, Word DOCX, and Vector PDF 1.4 serializers | < 200 lines / file |
| src/tui | Fullscreen ANSI compositor, pinned HUD, themes & slash command palette | < 200 lines / file |
The Under 200 Lines Invariant
Every source file in the repository must not exceed 200 lines of code. High-complexity domains are decomposed into single-responsibility submodules (e.g. `loopIteration.ts`, `loopEntryEvaluator.ts`, `loopPositionMonitor.ts`), ensuring zero circular dependencies and maximum testability.
ARCHITECTURAL INVARIANT
Hard ceiling: <= 200 lines per file. Enforced continuously in CI and development.
Last verified: August 2026•Maintained by Zenth Core