BeCoin_EcoSim_LLM

๐Ÿช™ BeCoin EcoSim

BeCoin EcoSim is a self-contained simulation of an autonomous startup economy. It models treasury health, agent productivity, project pipelines, and the CEO discovery workflow that surfaces proposals and operational patterns. A FastAPI dashboard exposes the evolving state while the economy engine enforces BeCoin accounting rules and prevents catastrophic overspending.

โœจ Key Capabilities

๐Ÿงฑ Architecture Overview

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     snapshot      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     JSON files
โ”‚ BecoinEconomy   โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถ  โ”‚ Dashboard Exporter โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถ office-ui.html
โ”‚  (engine.py)    โ”‚                  โ”‚  (exporter.py)     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚ transactions & metrics               โ”‚ REST + WS
       โ–ผ                                      โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Treasury /      โ”‚                 โ”‚ FastAPI Server      โ”‚
โ”‚ Agent Models    โ”‚                 โ”‚ (dashboard/server) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
  1. Simulation โ€“ BecoinEconomy coordinates treasury movements, agent activity, and project status while guarding against overspending.
  2. Export โ€“ build_dashboard_payload turns a snapshot into the five JSON files the dashboard expects (treasury.json, agent-roster.json, projects.json, impact-ledger.json, orchestrator-status.json).
  3. Presentation โ€“ the FastAPI service exposes CEO discovery data over REST and WebSockets; the static HTML dashboard reads both the generated JSON and live discovery updates.

๐Ÿ“‚ Code Map

Path Purpose
becoin_economy/models.py Dataclasses for treasury, agents, projects, transactions, and immutable snapshots.
becoin_economy/engine.py Economy orchestration logic plus safeguards against overspending.
becoin_economy/exporter.py Converts economy snapshots into dashboard JSON payloads.
dashboard/server.py FastAPI app exposing CEO discovery endpoints and WebSocket broadcasts.
dashboard/ceo_data_bridge.py Reads discovery session JSON from .claude-flow/discovery-sessions.
dashboard/websocket_manager.py Manages WebSocket clients for live updates.
dashboard/tests/ API, WebSocket, and data bridge tests.
becoin_economy/tests/ Engine, exporter, and stress simulation tests.
autonomous_agents/ Autonomous execution system with local LLMs and specialized agents.
autonomous_agents/orchestrator.py Main orchestrator that executes implementation plans autonomously.
autonomous_agents/personalities/ Loads 51 specialized agent personalities from Agency_of_Agents.
docs/plans/ Implementation plans in markdown format for autonomous execution.

๐Ÿงช Testing & Quality Gates

Every critical handover is covered by automated tests:

Run the full suite from the repository root:

pytest

๐Ÿš€ Running the Dashboard

  1. Install dashboard dependencies:

    cd dashboard
    pip install -r requirements.txt
    
  2. Start the FastAPI server:

    uvicorn server:app --reload --port 3000
    
  3. Serve the static dashboard (separate terminal):

    python3 -m http.server 8080
    
  4. Open http://localhost:9001/dashboard/office-ui.html and watch the BeCoin office in action. The page polls the FastAPI endpoints and listens for WebSocket events.

๐Ÿค– Autonomous Agents

The project includes an autonomous execution system that can implement entire feature plans independently using local LLMs and specialized agent personalities.

Quick Start

# One-click setup (installs Ollama, downloads Qwen2.5-Coder 7B, loads 51 agent personalities)
./autonomous_agents/setup_autonomous_agents.sh

# Execute a plan with dry-run (shows what would happen without executing)
python3 autonomous_agents/orchestrator.py docs/plans/example-plan.md --dry-run

# Execute a plan autonomously
python3 autonomous_agents/orchestrator.py docs/plans/example-plan.md

# Monitor progress in real-time (separate terminal)
python3 autonomous_agents/monitor.py -f

Key Features

See autonomous_agents/README.md for complete documentation.

๐Ÿ› ๏ธ Generating Dashboard Payloads

The dashboard expects five JSON files located under dashboard/becoin-economy/ (or any directory served alongside the HTML). Use the exporter to generate them from any economy instance:

import json

from becoin_economy import BecoinEconomy, Agent, Project, Treasury, build_dashboard_payload

treasury = Treasury(start_capital=10000, balance=10000)
agents = [...]  # list of Agent objects
projects = [...]  # list of Project objects
economy = BecoinEconomy(treasury=treasury, agents=agents, projects=projects)

payload = build_dashboard_payload(economy)
for name, data in payload.items():
    with open(f"dashboard/becoin-economy/{name}", "w") as fh:
        json.dump(data, fh, indent=2)

๐Ÿงญ CEO Discovery Integration

The FastAPI layer surfaces discovery insights stored as JSON in .claude-flow/discovery-sessions/. Endpoints include:

๐Ÿง‘โ€๐Ÿ’ป Development Workflow

  1. Update or extend the economy in becoin_economy/engine.py.
  2. Regenerate payloads via build_dashboard_payload if structure changes.
  3. Adjust the dashboard or FastAPI server to expose new insights.
  4. Run pytest to verify economy invariants and API contracts before committing.

๐Ÿ“„ License

BeCoin EcoSim is released under the MIT License. See LICENSE for details.