Skip to content

arnavsharma990/EchoEmbed

Repository files navigation

EchoEmbed

EchoEmbed Banner

A retro-futurist multimodal bridge translating analog intent into digital logic via Gemini AI and Finite State Machines

React TypeScript Gemini AI License

FeaturesQuick StartArchitectureUsageExamples


What is EchoEmbed?

EchoEmbed is an AI-powered visual FSM (Finite State Machine) designer for embedded systems engineers. It bridges the gap between high-level system design and low-level firmware implementation through:

  • Voice Voice-Driven Design - Speak your system requirements, watch them materialize
  • AI AI-Powered Generation - Gemini 3 Pro translates natural language to FSM graphs
  • Simulation Live Simulation - Execute state machines with real-time visualization
  • Export Multi-Language Export - Generate Verilog, C++, Python, or Rust code
  • Hardware Hardware Integration - Connect to real microcontrollers via Web Serial API
  • Twin Digital Twin - Shadow mode synchronizes simulation with physical hardware

Features

For Everyone

  • Visual FSM Designer - Drag-and-drop state machine builder with retro UI
  • Natural Language Input - "Create a traffic light controller" → Complete FSM
  • Template Library - 40+ pre-built templates (BLDC motors, I2C drivers, MQTT clients)
  • Real-Time Simulation - Watch your state machine execute with animated transitions
  • Export Anywhere - Download as PNG, JSON, or generated firmware code

For Engineers

  • Hardware Abstraction Layer (HAL) - Simulated GPIO, PWM, ADC, UART interfaces
  • Guard Conditions - JavaScript-based transition logic with visual feedback
  • Register Map Generator - Auto-generate memory-mapped peripheral definitions
  • Code Analysis - Reverse engineer existing C/C++ code into FSM graphs
  • Unit Test Generation - Automatic GoogleTest suite creation
  • Low-Power Optimization - AI-powered sleep mode recommendations

For Advanced Users

  • Live Voice Agent - Conversational AI assistant (Neo) with canvas control
  • Shadow Mode - Sync simulation with real hardware state via serial protocol
  • Logic Analyzer - Multi-channel waveform viewer for signal debugging
  • Workspace Layouts - Customizable panel arrangements (Architect, Debug, Zen modes)
  • Hot Reload - Modify FSM during simulation without stopping execution

Quick Start

Prerequisites

Installation

# Clone the repository
git clone https://github.com/Abhishek-2808/EchoEmbed.git
cd EchoEmbed

# Install dependencies
npm install

# Set your API key
echo "GEMINI_API_KEY=your_key_here" > .env.local

# Start development server
npm run dev

Visit http://localhost:5173 and start designing!


Architecture

System Overview

┌─────────────────────────────────────────────────────────────┐
│                      USER INTERFACE                          │
│  ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌──────────┐   │
│  │  Canvas  │  │   Chat   │  │ Hardware │  │  Panels  │   │
│  │ (ReactFlow)│  │   AI    │  │   I/O    │  │ (Logs)   │   │
│  └─────┬────┘  └─────┬────┘  └─────┬────┘  └──────────┘   │
└────────┼─────────────┼─────────────┼───────────────────────┘
         │             │             │
         ▼             ▼             ▼
┌─────────────────────────────────────────────────────────────┐
│                     CORE SERVICES                            │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐     │
│  │ FSM Executor │  │Gemini Service│  │Hardware Bridge│     │
│  │  (Engine)    │  │  (AI Logic)  │  │ (Web Serial) │     │
│  └──────┬───────┘  └──────┬───────┘  └──────┬───────┘     │
│         │                  │                  │              │
│         ▼                  ▼                  ▼              │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐     │
│  │     HAL      │  │Ghost Engineer│  │ Live Service │     │
│  │ (Simulation) │  │ (Validator)  │  │ (Voice AI)   │     │
│  └──────────────┘  └──────────────┘  └──────────────┘     │
└─────────────────────────────────────────────────────────────┘

Data Flow

graph LR
    A[User Input] -->|Voice/Text/Image| B[Gemini AI]
    B -->|JSON Graph| C[FSM Engine]
    C -->|Execute| D[HAL Simulation]
    D -->|Telemetry| E[UI Visualization]
    C -->|Code Gen| F[Export Firmware]
    C -->|Serial| G[Real Hardware]
    G -->|State Sync| C
Loading

Component Breakdown

1. FSM Executor (fsmEngine.ts)

  • Purpose: Runtime execution engine for state machines
  • Features:
    • Event-driven transitions with guard conditions
    • Entry/Exit action execution (JavaScript sandbox)
    • Breakpoint support for debugging
    • Hot reload capability
    • Shadow mode for hardware synchronization

2. Gemini Service (geminiService.ts)

  • Purpose: AI integration layer
  • Capabilities:
    • Natural language → FSM graph generation
    • Code reverse engineering (C/C++ → FSM)
    • Multi-language code generation (Verilog, C++, Python, Rust)
    • Register map generation
    • Unit test generation
    • Low-power optimization analysis
    • Datasheet analysis (text + image)

3. Hardware Abstraction Layer (hal.ts)

  • Purpose: Simulated embedded hardware interface
  • APIs:
    HAL.readPin(pin: number): boolean
    HAL.writePin(pin: number, value: boolean)
    HAL.getADC(channel: number): number  // 12-bit ADC
    HAL.setPWM(channel: number, duty: number)
    HAL.UART_Transmit(data: string)
    HAL.UART_Receive(): string | null
    HAL.enterSleepMode(mode: 'WFI' | 'STOP' | 'STANDBY')

4. Ghost Engineer (ghostEngineer.ts)

  • Purpose: Static analysis and validation
  • Checks:
    • Dead-end state detection
    • Unreachable state detection (BFS)
    • Race condition detection (non-deterministic transitions)

5. Live Service (liveService.ts)

  • Purpose: Real-time voice interaction with AI agent
  • Features:
    • Bidirectional audio streaming (Gemini Live API)
    • Tool calling (read_design, create_design, modify_design)
    • Conversational FSM editing

Usage

Basic Workflow

1. Design → 2. Simulate → 3. Validate → 4. Export → 5. Flash

1️⃣ Design Your FSM

Option A: Voice Input

<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3z"/><path d="M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"/></svg> "Create a smart thermostat with heating and cooling modes"

Option B: Text Chat

<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg> "Build an I2C master driver with error handling"

Option C: Manual Design

  • Right-click canvas → Add Node
  • Connect nodes by dragging handles
  • Double-click node → Edit logic

2️⃣ Simulate Execution

// Nodes automatically execute JavaScript logic
// Example Entry Action:
ctx.temperature = HAL.getADC(0);
if (ctx.temperature > 75) {
  HAL.writePin(FAN, true);
  dispatch("COOLING", 1000);
}

Controls:

  • Play - Start simulation
  • Pause - Freeze execution
  • Step - Advance one transition
  • Breakpoint - Pause at specific node

3️⃣ Validate Design

Ghost Engineer automatically detects:

  • Dead ends (states with no exit)
  • Unreachable states
  • Race conditions (duplicate event triggers)

4️⃣ Export Code

# Generate C++ for Arduino/ESP32
Export → C++ → Download

# Generate Verilog for FPGA
Export → Verilog → Download

# Generate Python for Raspberry Pi
Export → Python → Download

5️⃣ Flash to Hardware

# Connect via Web Serial
Toolbar → Connect Hardware → Select Port

# Flash firmware
Toolbar → Flash Device → Select Target MCU

Examples

Example 1: Traffic Light Controller

// STATE: GREEN
entryAction: `
  HAL.writePin(LED_GREEN, true);
  dispatch("TIMER", 5000);
`

// TRANSITION: TIMER → YELLOW
condition: `ctx.emergency === false`

// STATE: YELLOW
entryAction: `
  HAL.writePin(LED_GREEN, false);
  HAL.writePin(LED_YELLOW, true);
  dispatch("TIMER", 2000);
`

Example 2: BLDC Motor Controller

// STATE: ALIGN_ROTOR
entryAction: `
  HAL.setPWM(PHASE_A, 10);
  ctx.alignment_time = 0;
  dispatch("ALIGNED", 500);
`

// STATE: OPEN_LOOP_RAMP
entryAction: `
  ctx.speed += 10;
  HAL.setPWM(PHASE_A, ctx.speed);
  if (ctx.speed > 100) {
    dispatch("BEMF_VALID", 0);
  } else {
    dispatch("RAMPING", 100);
  }
`

Example 3: MQTT Client

// STATE: TCP_CONNECT
entryAction: `
  ctx.socket = connect("broker.hivemq.com", 1883);
  dispatch("CONNECTED", 500);
`

// STATE: MQTT_CONNECT
entryAction: `
  ctx.socket.send("CONNECT");
  dispatch("CONNACK", 500);
`

// STATE: PUBLISH
entryAction: `
  ctx.socket.send({
    topic: "sensors/temp",
    payload: HAL.getADC(0)
  });
  dispatch("DONE", 100);
`

Advanced Features

Shadow Mode (Digital Twin)

Synchronize simulation with real hardware:

// Hardware sends state updates via UART
// Format: "STATE:RUNNING\n"

// EchoEmbed automatically syncs visualization
// No manual intervention needed

Use Cases:

  • Debug firmware on real hardware with visual feedback
  • Monitor production systems in real-time
  • Validate FSM behavior against physical constraints

Register Map Generation

// Analyze FSM logic
ctx.control_reg = 0x01;
ctx.status_flag = true;
ctx.data_buffer = [0, 1, 2];

// AI generates:
// - Memory map with offsets
// - Bitfield definitions
// - C header file

Output:

#define BASE_ADDR 0x40000000
#define CONTROL_REG (BASE_ADDR + 0x00)
#define STATUS_REG  (BASE_ADDR + 0x04)
#define DATA_BUF    (BASE_ADDR + 0x08)

Code Reverse Engineering

// Input: Existing C++ firmware
enum State { IDLE, RUNNING, ERROR };
State current = IDLE;

void loop() {
  switch(current) {
    case IDLE:
      if (button_pressed()) current = RUNNING;
      break;
    case RUNNING:
      motor_control();
      if (fault_detected()) current = ERROR;
      break;
  }
}

// Output: Visual FSM graph with 3 nodes and transitions

UI Themes

EchoEmbed supports 4 visual themes:

Theme Description Use Case
NEURO Clean, minimal, light Documentation, presentations
CYBERPUNK Dark, neon accents Late-night coding sessions
BLUEPRINT Blue engineering paper Technical design reviews
TERMINAL Green-on-black CRT Retro hacker aesthetic

Configuration

API Key Setup

# Option 1: Environment variable
export GEMINI_API_KEY="your_key_here"

# Option 2: .env.local file
echo "GEMINI_API_KEY=your_key_here" > .env.local

# Option 3: In-app settings
Settings → API Key → Paste key

Workspace Layouts

  • Mission Control - All panels visible
  • Architect - Design + Properties focus
  • Engineer - Simulation + Registers
  • Debug Focus - Logs + Hardware I/O
  • Zen Mode - Canvas only

Contributing

We welcome contributions! Areas of interest:

  • New FSM templates (automotive, aerospace, medical)
  • Additional hardware targets (STM32, nRF52, RP2040)
  • Language support (Spanish, Chinese, Japanese)
  • Test coverage improvements
  • Documentation and tutorials

License

MIT License - see LICENSE for details


Acknowledgments

  • Google Gemini - AI-powered code generation and analysis
  • ReactFlow - Visual graph editing framework
  • Lucide Icons - Beautiful icon library
  • Tailwind CSS - Utility-first styling

Support


Built with ❤️ for the embedded systems community

Star us on GitHub Follow on Twitter

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors