Architecture

EonFlow is composed of four main layers:

  1. Core (eonflow/core/*)

    • provider.py — unified Alchemy providers for HTTP & WebSocket with reconnect logic and per‑chain registries (get_provider, get_ws_provider).

    • chains.py — chain IDs and metadata (Ethereum, Base) used by routers/providers.

    • router_unified.py & dex_base.py — DEX abstractions and routing primitives (extend with concrete DEX integrations).

    • accounts.py — simple models/utilities for addresses and signing contexts.

    • state_store.py — central state persistence abstraction (see also root variants like state_store.py and patches).

  2. Panel (Telegram UX) (eonflow/panel/* + eonflow/telegram_bot/*)

    • ui_handlers.py — aiogram v3 handlers for inline keyboards, callbacks, and input modes (wallet menu, creation, selection).

    • ui_render.py — text/markup rendering for dashboard & sub‑panels.

    • ui_state.py — compact state machine around chat/user scope.

    • telegram_bot/bot.py — bot bootstrap, dispatcher wiring, and polling.

  3. API & Metrics (eonflow/api/server.py)

    • Minimal FastAPI app with /healthz, /metrics (Prometheus), and /info (static capabilities). Metrics include counters for trades, gas spent, open positions, and a runtime status gauge.

  4. Runtime & Scripts

    • Entry points: eonflow/main.py, start_eonflow.py, launcher.py.

    • Utilities & setup: scripts/bootstrap.py.

    • Data: data/*.json for local state (wallets, trades, positions, follows, settings).


Data Flow (high level)

Telegram (user) → aiogram handlers → UIState → Core (providers/router) →
(orders/reads) → metrics emitted → FastAPI /metrics → Prometheus/Grafana
                                  ↘ state_store (JSON/SQLite) for persistence
  • Provider selection is chain‑aware (ETH/Base) and built to support both HTTP RPC and WebSocket subscriptions.

  • Panel actions call into the core to query balances, wallets, or place operations (copy/snipe), then render back inline responses.

  • Metrics provide coarse telemetry for dashboards and alerts.


Extensibility

  • Add a new chain in core/chains.py, register providers in core/provider.py.

  • Implement a new DEX by subclassing dex_base.py and wiring it in router_unified.py.

  • Add new panel actions in panel/ui_handlers.py and surface them in panel/ui_render.py.

  • Persist new entities via core/state_store.py (or swap for a DB adapter).