# deskiziarecords/7zero-reverse architecture

> Architecture diagram of the GitHub repository deskiziarecords/7zero-reverse, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/deskiziarecords/7zero-reverse
- Repository: https://github.com/deskiziarecords/7zero-reverse

## Overview

1. **Overall shape**
   This repo is a hybrid trading/analysis system: a **Rust core engine** does the market-data processing and pattern detection, while a **React/JavaScript terminal** renders the results. The two halves are connected through a **WASM boundary**.

2. **Primary runtime boundary**
   The important architecture line is:
   **market data in → Rust processing/detection → structured engine state/signals → frontend visualization**.
   The Rust side is optimized for low-latency, event-driven processing; the frontend is a read-only visualization/control surface.

3. **Data ingestion layer (`src/data`)**
   `realtime.rs` is the market-feed entry point, described as handling providers like **OANDA tick streaming**.  
   `candle_builder.rs` converts raw ticks into fixed-interval candles, which is the normalized data stream the rest of the engine consumes.

4. **Engine orchestration layer (`src/engine`)**
   `core.rs` is the central orchestrator: it advances the system one candle at a time, manages transitions, and triggers detection logic.  
   `state.rs` holds rolling market context and optimized state containers.  
   This is the core runtime loop of the backend.

5. **Detection subsystem (`src/engine/detectors.rs`)**
   The detector layer implements the repo’s “Lambda Detection Matrix” and related market-regime logic.  
   It classifies conditions such as phase entrapment, temporal alignment, spectral inversion, liquidity inversion, and a displacement veto.  
   In diagram terms, this is the decision layer between normalized market state and emitted trading/analysis signals.

6. **Shared domain model (`src/types`)**
   `types.rs` centralizes the core structs, configs, and system-state definitions used across data, engine, and models.  
   This is the main contract layer inside the Rust backend.

7. **Analytical/modeling support (`src/models`)**
   `math.rs` contains the low-level quantitative utilities such as SMA, ATR, standard deviation, and the “Adelic Manifold Validator.”  
   `meta_cognitive.rs` and `neuro_symbolic.rs` appear to be experimental or higher-level inference layers.  
   For architecture purposes, these are support modules feeding the detector/engine logic rather than separate services.

8. **Rust crate boundaries**
   `src/lib.rs` exposes the reusable backend logic, while `src/main.rs` is the runnable entrypoint for local execution/simulation.  
   This suggests the Rust code can act both as a library for WASM export and as a native executable for backend testing.

9. **Frontend application (`frontend/`)**
   The `frontend/` directory is a separate Vite-based React app.  
   It is the human-facing terminal: charting, indicator display, and engine-health monitoring.  
   The README specifically calls out **lightweight-charts** for financial visualization.

10. **WASM / JS integration**
    `frontend/src/engine.js` is the glue layer that bridges the browser UI with the Rust engine compiled to WASM via `wasm-pack` / `wasm-bindgen`.  
    The UI bootstraps through `frontend/src/main.jsx`, then consumes engine outputs for live rendering.

11. **Repo structure note**
    There is also a top-level `src/App.jsx` and `src/pages/PatternScanner.jsx`, which suggests an additional or shared JS UI surface outside `frontend/`.  
    For an architecture diagram, treat the Rust engine as the backend core and the React/Vite layer as the visualization frontend; the top-level JS files look like a secondary UI entrypoint or shared app shell.

12. **External dependencies that matter architecturally**
    The materially important external pieces are:
    - **OANDA**-style market ticks as the data source
    - **WASM toolchain** for Rust-to-JS bridging
    - **Vite/React** for the terminal UI
    - **lightweight-charts** for market visualization

13. **Build/runtime separation**
    Rust is built with **Cargo**; the browser UI is built with **npm/Vite**; the WASM artifact is produced separately with **wasm-pack**.  
    That means the repository has two deployment/runtime paths: a native Rust execution path and a browser-based visualization path.

Main entry points: [`src/engine/detectors.rs`](https://github.com/deskiziarecords/7zero-reverse/blob/main/src/engine/detectors.rs) (Detectors), [`src/engine/core.rs`](https://github.com/deskiziarecords/7zero-reverse/blob/main/src/engine/core.rs) (Engine core), [`src/types/types.rs`](https://github.com/deskiziarecords/7zero-reverse/blob/main/src/types/types.rs) (Domain types), [`frontend/src/App.jsx`](https://github.com/deskiziarecords/7zero-reverse/blob/main/frontend/src/App.jsx) (Terminal app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_rust_core["Rust core"]
  node_src_data_realtime["Realtime feed<br/>ingest<br/>[realtime.rs]"]
  node_src_data_candle_builder["Candle builder<br/>normalize<br/>[candle_builder.rs]"]
  node_src_engine_core["Engine core<br/>orchestrator<br/>[core.rs]"]
  node_src_engine_state[("Engine state<br/>state store<br/>[state.rs]")]
  node_src_engine_detectors["Detectors<br/>decision layer<br/>[detectors.rs]"]
  node_src_types_types["Domain types<br/>contracts<br/>[types.rs]"]
  node_src_models_math["Quant math<br/>analytics<br/>[math.rs]"]
  node_src_models_meta_cognitive["Meta layer<br/>experimental model<br/>[meta_cognitive.rs]"]
  node_src_models_neuro_symbolic["Neuro-symbolic<br/>experimental model<br/>[neuro_symbolic.rs]"]
  node_src_lib["Rust lib<br/>crate API<br/>[lib.rs]"]
  node_src_main["Rust main<br/>native entry<br/>[main.rs]"]
end

subgraph group_web_terminal["Web terminal"]
  node_frontend_main["UI bootstrap<br/>frontend entry<br/>[main.jsx]"]
  node_frontend_engine["WASM bridge<br/>integration layer<br/>[engine.js]"]
  node_frontend_app["Terminal app<br/>react shell<br/>[App.jsx]"]
end

subgraph group_js_shell["JS shell"]
  node_src_app["Pattern shell<br/>react shell<br/>[App.jsx]"]
  node_src_pages_patternscanner["Pattern scanner<br/>view<br/>[PatternScanner.jsx]"]
end

subgraph group_external["External systems"]
  node_oanda_feed(("OANDA feed<br/>external market data"))
  node_wasm_toolchain(("WASM toolchain<br/>build/runtime"))
  node_vite_react(("Vite/React<br/>ui runtime"))
  node_lightweight_charts(("Charts lib<br/>visualization"))
end

node_oanda_feed -->|"ticks in"| node_src_data_realtime
node_src_data_realtime -->|"normalize"| node_src_data_candle_builder
node_src_data_candle_builder -->|"candles in"| node_src_engine_core
node_src_engine_core -->|"update state"| node_src_engine_state
node_src_engine_core -->|"run detection"| node_src_engine_detectors
node_src_engine_state -->|"context"| node_src_engine_detectors
node_src_types_types -->|"contracts"| node_src_data_realtime
node_src_types_types -->|"models"| node_src_engine_state
node_src_types_types -->|"signals"| node_src_engine_detectors
node_src_models_math -->|"features"| node_src_engine_detectors
node_src_models_meta_cognitive -.->|"support"| node_src_engine_detectors
node_src_models_neuro_symbolic -.->|"support"| node_src_engine_detectors
node_src_engine_core -->|"exposed by"| node_src_lib
node_src_main -->|"runs"| node_src_engine_core
node_src_lib -->|"compiled via"| node_wasm_toolchain
node_wasm_toolchain -->|"bridges"| node_frontend_engine
node_frontend_main -->|"mounts"| node_frontend_app
node_frontend_app -->|"consumes"| node_frontend_engine
node_frontend_app -->|"renders"| node_lightweight_charts
node_frontend_main -->|"served by"| node_vite_react
node_src_app -->|"navigates"| node_src_pages_patternscanner

click node_src_data_realtime "https://github.com/deskiziarecords/7zero-reverse/blob/main/src/data/realtime.rs"
click node_src_data_candle_builder "https://github.com/deskiziarecords/7zero-reverse/blob/main/src/data/candle_builder.rs"
click node_src_engine_core "https://github.com/deskiziarecords/7zero-reverse/blob/main/src/engine/core.rs"
click node_src_engine_state "https://github.com/deskiziarecords/7zero-reverse/blob/main/src/engine/state.rs"
click node_src_engine_detectors "https://github.com/deskiziarecords/7zero-reverse/blob/main/src/engine/detectors.rs"
click node_src_types_types "https://github.com/deskiziarecords/7zero-reverse/blob/main/src/types/types.rs"
click node_src_models_math "https://github.com/deskiziarecords/7zero-reverse/blob/main/src/models/math.rs"
click node_src_models_meta_cognitive "https://github.com/deskiziarecords/7zero-reverse/blob/main/src/models/meta_cognitive.rs"
click node_src_models_neuro_symbolic "https://github.com/deskiziarecords/7zero-reverse/blob/main/src/models/neuro_symbolic.rs"
click node_src_lib "https://github.com/deskiziarecords/7zero-reverse/blob/main/src/lib.rs"
click node_src_main "https://github.com/deskiziarecords/7zero-reverse/blob/main/src/main.rs"
click node_frontend_main "https://github.com/deskiziarecords/7zero-reverse/blob/main/frontend/src/main.jsx"
click node_frontend_engine "https://github.com/deskiziarecords/7zero-reverse/blob/main/frontend/src/engine.js"
click node_frontend_app "https://github.com/deskiziarecords/7zero-reverse/blob/main/frontend/src/App.jsx"
click node_src_app "https://github.com/deskiziarecords/7zero-reverse/blob/main/src/App.jsx"
click node_src_pages_patternscanner "https://github.com/deskiziarecords/7zero-reverse/blob/main/src/pages/PatternScanner.jsx"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_src_data_realtime,node_src_data_candle_builder,node_src_engine_core,node_src_engine_state,node_src_engine_detectors,node_src_types_types,node_src_models_math,node_src_models_meta_cognitive,node_src_models_neuro_symbolic,node_src_lib,node_src_main toneBlue
class node_frontend_main,node_frontend_engine,node_frontend_app toneAmber
class node_src_app,node_src_pages_patternscanner toneMint
class node_oanda_feed,node_wasm_toolchain,node_vite_react,node_lightweight_charts toneRose
```

## Components

### Rust core

Market-data ingestion, engine loop, shared domain, and analytical models.

- [Realtime feed](https://github.com/deskiziarecords/7zero-reverse/blob/main/src/data/realtime.rs): ingest · Entry point for live market ticks and provider streaming. · `src/data/realtime.rs`
- [Candle builder](https://github.com/deskiziarecords/7zero-reverse/blob/main/src/data/candle_builder.rs): normalize · Converts raw ticks into fixed-interval candles for the engine loop. · `src/data/candle_builder.rs`
- [Engine core](https://github.com/deskiziarecords/7zero-reverse/blob/main/src/engine/core.rs): orchestrator · Advances the system candle by candle and coordinates processing. · `src/engine/core.rs`
- [Engine state](https://github.com/deskiziarecords/7zero-reverse/blob/main/src/engine/state.rs): state store · Holds rolling market context and optimized runtime state. · `src/engine/state.rs`
- [Detectors](https://github.com/deskiziarecords/7zero-reverse/blob/main/src/engine/detectors.rs): decision layer · Implements regime and pattern classification, including matrix-style detection logic. · `src/engine/detectors.rs`
- [Domain types](https://github.com/deskiziarecords/7zero-reverse/blob/main/src/types/types.rs): contracts · Shared structs, configs, and system-state definitions used across the backend. · `src/types/types.rs`
- [Quant math](https://github.com/deskiziarecords/7zero-reverse/blob/main/src/models/math.rs): analytics · Low-level indicators and validation utilities used by the detection stack. · `src/models/math.rs`
- [Meta layer](https://github.com/deskiziarecords/7zero-reverse/blob/main/src/models/meta_cognitive.rs): experimental model · Higher-level inference support feeding the engine and detectors. · `src/models/meta_cognitive.rs`
- [Neuro-symbolic](https://github.com/deskiziarecords/7zero-reverse/blob/main/src/models/neuro_symbolic.rs): experimental model · Symbolic/inference support module for analysis and detection. · `src/models/neuro_symbolic.rs`
- [Rust lib](https://github.com/deskiziarecords/7zero-reverse/blob/main/src/lib.rs): crate API · Library boundary exposing reusable backend logic and WASM-facing code. · `src/lib.rs`
- [Rust main](https://github.com/deskiziarecords/7zero-reverse/blob/main/src/main.rs): native entry · Native executable entrypoint for local execution and simulation. · `src/main.rs`

### Web terminal

Browser UI and WASM bridge for visualization and control.

- [UI bootstrap](https://github.com/deskiziarecords/7zero-reverse/blob/main/frontend/src/main.jsx): frontend entry · Starts the browser app and mounts the React terminal. · `frontend/src/main.jsx`
- [WASM bridge](https://github.com/deskiziarecords/7zero-reverse/blob/main/frontend/src/engine.js): integration layer · Connects the browser UI to Rust engine outputs compiled to WebAssembly. · `frontend/src/engine.js`
- [Terminal app](https://github.com/deskiziarecords/7zero-reverse/blob/main/frontend/src/App.jsx): react shell · Main UI shell for charts, indicators, and engine status. · `frontend/src/App.jsx`

### JS shell

Top-level React surface outside the Vite frontend.

- [Pattern shell](https://github.com/deskiziarecords/7zero-reverse/blob/main/src/App.jsx): react shell · Top-level JS app surface and pattern-scanner view. · `src/App.jsx`
- [Pattern scanner](https://github.com/deskiziarecords/7zero-reverse/blob/main/src/pages/PatternScanner.jsx): view · Dedicated scanning page for pattern-focused analysis. · `src/pages/PatternScanner.jsx`

### External systems

Outside services and runtime toolchains that shape the architecture.

- **OANDA feed**: external market data · Live tick source implied by the realtime ingestion layer.
- **WASM toolchain**: build/runtime · Rust-to-JS compilation path via wasm-pack and wasm-bindgen.
- **Vite/React**: ui runtime · Frontend build and browser runtime for the terminal UI.
- **Charts lib**: visualization · Financial charting library used for market visualization.

## Connections

- OANDA feed → Realtime feed: ticks in · Live market ticks enter through the realtime provider layer.
- Realtime feed → Candle builder: normalize · Raw ticks are aggregated into candles.
- Candle builder → Engine core: candles in · Normalized candles drive the core runtime loop.
- Engine core → Engine state: update state · The orchestrator advances and mutates rolling engine state.
- Engine core → Detectors: run detection · Each candle step triggers regime and pattern detection.
- Engine state → Detectors: context · Detectors read rolling market context from state.
- Domain types → Realtime feed: contracts · Shared types define data and message shapes.
- Domain types → Engine state: models · State is structured by the shared domain model.
- Domain types → Detectors: signals · Detection outputs use shared system-state types.
- Quant math → Detectors: features · Indicators and validation utilities feed detection logic.
- Meta layer → Detectors: support · Experimental inference support contributes to analysis.
- Neuro-symbolic → Detectors: support · Symbolic reasoning support feeds the decision layer.
- Engine core → Rust lib: exposed by · Core engine logic is exported through the library boundary.
- Rust main → Engine core: runs · Native executable drives the engine loop for local execution.
- Rust lib → WASM toolchain: compiled via · The Rust library is built for browser use through the WASM toolchain.
- WASM toolchain → WASM bridge: bridges · WASM output is consumed by the browser integration layer.
- UI bootstrap → Terminal app: mounts · The UI bootstrap renders the main terminal app.
- Terminal app → WASM bridge: consumes · The terminal reads engine outputs through the JS bridge.
- Terminal app → Charts lib: renders · Charts are used for market visualization.
- UI bootstrap → Vite/React: served by · The browser app runs in the Vite/React frontend environment.
- Pattern shell → Pattern scanner: navigates · The shared JS shell includes the pattern scanner view.
