How gitaalekhyapaul/skynet-monorepo works
This repo is a TypeScript/Node + React monorepo for a cross-chain, semi-autonomous trading bot (“Skynet”) that:
• Lets users connect Okto wallets via a React frontend and pool funds.
• Runs an agentic decision layer (reAct-style agent, LangGraph/OpenAI) that:
• Creates cross-chain wallets (Polygon + Aptos) using Okto SDK (custom JWT auth),
• Executes gasless transactions,
• Reads Telegram sentiment (proposals + replies),
• Decides buy/sell actions based on community feedback.
File tree analysis (how the repo maps to architecture)
Top-level directories are already the system’s service boundaries:
• frontend/ — React UI client
• orchestration/ — API gateway + coordinator + queue manager + realtime updates (Socket.io)
• agent/ — decision-making worker/service (LangGraph + OpenAI SDK)
• implementation/ — “business logic & data layer” (DB ops, validation, core operations)
README architecture cues (what to reflect verbatim, and what to add)
• External dependencies: Okto SDK/Okto wallet, Polygon, Aptos, Telegram, OpenAI
• Trust boundaries: browser vs backend network; secrets only in backend; JWT issuance/validation path
• Sync vs async interactions: HTTP/WebSocket vs Redis queue jobs
• Data ownership: MongoDB as system-of-record for tasks, proposals, trades, user sessions (whatever is applicable)
• Runtime roles: Orchestrator as “control-plane”; Agent as “worker”; Implementation as “domain + persistence”
Context / C4 Level 1 (System Context)
• User (Browser)
• Okto (Wallet + JWT auth / SDK)
• Polygon + Aptos networks
• Telegram
• OpenAI (or “LLM Provider”)
• Optional: Monitoring/Logging if present (even if implied)
Container / C4 Level 2 (Service Topology)
• Frontend → Orchestrator: HTTPS + WebSocket (Socket.io)
• Orchestrator → Redis: enqueue/dequeue job metadata
• Agent → Redis: consume jobs
• Agent → Implementation: HTTP/gRPC (likely HTTP since Express is listed) for domain actions
• Implementation → MongoDB: persistence
• Agent/Implementation → Okto SDK → Chains: wallet creation + tx signing/submission (gasless)
• Agent → Telegram: read/post proposals + parse replies
• Agent → OpenAI: prompt/plan/decide (LangGraph)
• “User submits trading task / strategy update”
• “Agent posts proposal to Telegram → collects replies → decides → executes trade”
And label main components (specific to this repo)
Use these as your canonical nodes:
Client
• *Frontend (React/TS)*: wallet connect UI, strategy config, status view, task submission
Control-plane backend
• *Orchestration (Node/Express/TS)*:
• API Gateway (REST)
• WebSocket gateway (Socket.io) for realtime updates
• Task Manager / System State
• Redis Queue publisher
Async execution
• *Redis Queue*: task distribution + buffering + retry semantics (note retry/dlq if implemented)
• *Agent Service (LangGraph + OpenAI SDK)*:
• Task Processor
• ReAct/LangGraph workflow
• Telegram sentiment module
• Execution planner
• Status update publisher back to Orchestrator
Domain + persistence
• *Implementation Service (Express/TS)*:
• Business logic
• Data access layer
• Validation, normalization
• *MongoDB*: tasks, users, wallets metadata, proposals, trade records, audit logs (reflect what’s real once confirmed in code)
External systems
• Okto SDK / Okto Wallet + JWT auth
• Polygon + Aptos
• Telegram
• OpenAI/LLM
Architectural patterns used here (explicitly)
• API Gateway + Orchestrator pattern (Frontend has a single backend entrypoint)
• Queue-based worker pattern (Redis decouples request submission from execution)
• Agentic workflow pattern (LangGraph orchestrates tool calls: Telegram, Okto, DB, LLM)
• Separation of concerns: Agent = decisions; Implementation = domain + persistence
• Event/status streaming to UI (Socket.io)
Decision loop: Proposal → sentiment → decision → execution
It as a feedback loop (Telegram responses feed back into the agent state machine).
Async reliability: queue semantics
Job states (Queued/Running/Waiting on Telegram/Completed/Failed) and where they’re stored (MongoDB vs in-memory).
Security boundaries
• Browser has no chain execution secrets.
• Backend services hold Okto credentials/JWT handling.
• External calls (Telegram/LLM) are outbound from Agent.
“Don’t overthink it”: maximize component separation (what to split out)
Orchestration
• REST API
• Socket.io gateway
• Task Manager
• Queue publisher
• (Optional) Auth middleware for Okto session/wallet connect
Agent
• LangGraph workflow engine
• Tooling adapters:
• Telegram adapter
• Okto adapter
• Implementation service client
• LLM client
• State machine / memory (where stored?)
• Observability/logging
Implementation
• Domain services (trading proposal persistence, trade execution recordkeeping)
• Data access layer (MongoDB collections)
• Validators