[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 PackageResponsibility & Key ModulesLine Constraint
src/core/botMain loop coordinator, scanner, position manager, session metrics< 200 lines / file
src/core/marketExchangeRegistry, venue adapters, interval & symbol normalizers< 200 lines / file
src/core/strategyIndicators math (SMA 9/21, RSI 14, Vol20) and StrategyEngine< 200 lines / file
src/core/riskRiskManager with $1,000 notional cap and drawdown circuit breakers< 200 lines / file
src/core/memoryPolymorphic DatabaseAdapters (SQLite, PG, Mongo, Supabase, RAM)< 200 lines / file
src/core/exportTXT, CSV, Markdown, Word DOCX, and Vector PDF 1.4 serializers< 200 lines / file
src/tuiFullscreen 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 2026Maintained by Zenth Core