Emergence-World/docs/ARCHITECTURE.md
DeepakAkkil f67ffd3005 V1
2026-05-13 17:18:08 +03:00

6.9 KiB

System Architecture

Emergence World is a full-stack simulation platform that runs autonomous AI agents in a persistent 3D world. This document describes the technical architecture — how the system is built, what technologies power it, and how the pieces connect.


High-Level Architecture

┌──────────────────────────────────────────────────────────────────────┐
│                         CLIENT (Browser)                             │
│                                                                      │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐               │
│  │  3D Viewport  │  │  UI Panels   │  │  Playback    │               │
│  │  React Three  │  │  React +     │  │  Engine      │               │
│  │  Fiber        │  │  Tailwind    │  │              │               │
│  └──────┬───────┘  └──────┬───────┘  └──────┬───────┘               │
│         │                  │                  │                       │
│         └──────────────────┼──────────────────┘                      │
│                            │                                         │
│                     TanStack Query                                   │
│                     WebSocket Client                                 │
└────────────────────────────┼─────────────────────────────────────────┘
                             │
                        HTTP / WebSocket
                             │
┌────────────────────────────┼─────────────────────────────────────────┐
│                      API GATEWAY (FastAPI)                           │
│                                                                      │
│  ┌─────────┐ ┌──────────┐ ┌───────────┐ ┌──────────┐ ┌───────────┐ │
│  │Buildings│ │Characters│ │Governance │ │ Credits  │ │  Blogs    │ │
│  │  API    │ │   API    │ │   API     │ │   API    │ │   API     │ │
│  └─────────┘ └──────────┘ └───────────┘ └──────────┘ └───────────┘ │
│  ┌─────────┐ ┌──────────┐ ┌───────────┐ ┌──────────┐ ┌───────────┐ │
│  │Billboard│ │   TTS    │ │  Human    │ │Newspaper │ │ Playback  │ │
│  │  API    │ │  Events  │ │Consult API│ │   API    │ │   API     │ │
│  └─────────┘ └──────────┘ └───────────┘ └──────────┘ └───────────┘ │
│  ┌─────────┐ ┌──────────┐ ┌───────────┐ ┌──────────┐               │
│  │  World  │ │  Agent   │ │ Feedback  │ │  Bricks  │               │
│  │Settings │ │ Control  │ │   API     │ │   API    │               │
│  └─────────┘ └──────────┘ └───────────┘ └──────────┘               │
│                                                                      │
│                      WebSocket Hub                                   │
└────────────────────────────┼─────────────────────────────────────────┘
                             │
              ┌──────────────┼──────────────┐
              │              │              │
┌─────────────▼──┐ ┌────────▼────────┐ ┌───▼──────────────┐
│  SIMULATION    │ │   AGENT          │ │   EXTERNAL       │
│  ENGINE        │ │   FRAMEWORK      │ │   SERVICES       │
│                │ │                  │ │                   │
│ • Turn Mgr    │ │ • em-agent-fw   │ │ • Vertex AI       │
│ • Scheduler   │ │ • Tool Registry │ │ • Anthropic API   │
│ • Reactive    │ │ • Memory Mgr    │ │ • OpenAI API      │
│   Conv System │ │ • Need System   │ │ • xAI API         │
│ • Event Mgr   │ │ • LLM Router    │ │ • Cloud TTS       │
│ • Weather Sync│ │ • Skill Loader  │ │ • Cloud Storage   │
│ • Credit Cycle│ │                  │ │ • Weather API     │
│               │ │                  │ │ • DALL-E          │
└───────┬───────┘ └────────┬────────┘ └───────────────────┘
        │                  │
        └──────────┬───────┘
                   │
          ┌────────▼────────┐
          │   PostgreSQL    │
          │                 │
          │  60+ tables     │
          │  Full state     │
          │  persistence    │
          └─────────────────┘

Tech Stack

Frontend

Technology Purpose
React 18 UI framework
TypeScript Type-safe development
React Three Fiber 3D rendering (Three.js wrapper for React)
@react-three/drei 3D helper components (cameras, controls, loaders)
TanStack Query Server state management, caching, real-time updates
Tailwind CSS Utility-first styling
shadcn/ui Component library (New York style variant)
Vite Build tool and dev server

Database

Technology Purpose
PostgreSQL 15+ Primary persistence (60+ tables)
Drizzle ORM Schema management and migrations (TypeScript side)