AnyaSelf Docs

Architecture Overview

System context, service topology, and data flow for the AnyaSelf platform.

System Context (C4 Level 1)

AnyaSelf is a personal fashion assistant platform that coordinates AI reasoning, headless browser automation, and virtual try-on inference across multiple external systems.

graph TB
  subgraph Users
    U["๐Ÿ‘ค Household Members<br/>(React SPA / Mobile Browser)"]
  end

  subgraph AnyaSelf["AnyaSelf Platform"]
    GW["API Gateway<br/>:8080"]
    SERVICES["8 Microservices"]
  end

  subgraph External["External Systems"]
    VERTEX["Google Cloud<br/>Vertex AI"]
    GEMINI["Gemini Live<br/>Voice API"]
    HYPERBEAM_API["Hyperbeam<br/>Cloud Browsers"]
    OIDC["OIDC / Firebase Auth<br/>Identity Provider"]
    BRANDS["Brand E-Commerce<br/>Stores"]
    GCS["Google Cloud<br/>Storage"]
    UNSPLASH["Unsplash<br/>Photo API"]
  end

  U -- "HTTPS / WSS" --> GW
  GW --> SERVICES
  SERVICES -- "Reasoning Engine" --> VERTEX
  GW -- "WebSocket Proxy" --> GEMINI
  SERVICES -- "Ephemeral Browsers" --> HYPERBEAM_API
  GW -- "JWT Verification" --> OIDC
  SERVICES -- "DOM Automation" --> BRANDS
  SERVICES -- "Image Storage" --> GCS
  GW -- "Discover Feed" --> UNSPLASH

Container Diagram (C4 Level 2)

graph TB
  CLIENT["๐Ÿ–ฅ๏ธ client-web<br/>React + Vite + TypeScript<br/>Port: 3000"]

  subgraph Gateway["Edge Layer"]
    GW["๐Ÿ” api-gateway<br/>FastAPI ยท :8080<br/>Auth, Routing, Voice Proxy,<br/>Purchases, Audit Logs"]
  end

  subgraph Core["Core Services"]
    ORCH["๐Ÿง  orchestrator<br/>FastAPI ยท :8003<br/>Vertex AI Agent, Missions,<br/>Tool Execution Loop"]
    WARD["๐Ÿ‘— wardrobe<br/>FastAPI ยท :8081<br/>Items, Outfits, Feed,<br/>Collections, Image Upload"]
    COMM["๐Ÿ›’ commerce<br/>FastAPI ยท :8002<br/>Offer Ingestion,<br/>Semantic Search, Scoring"]
    VTO_SVC["๐ŸŽจ vto<br/>FastAPI ยท :8004<br/>Try-On Inference,<br/>Diffusion Pipeline"]
  end

  subgraph Automation["Browser Automation"]
    HB["๐ŸŒ hyperbeam-bridge<br/>FastAPI ยท :8006<br/>Cloud Browser Sessions,<br/>DOM Indexing, Agent Actions"]
    CP["๐Ÿ›๏ธ headless-cartprep<br/>FastAPI ยท :8005<br/>Cart Automation Jobs,<br/>Playwright Runner"]
  end

  subgraph Observability["Observability"]
    AA["๐Ÿ“‹ artifacts-audit<br/>FastAPI ยท :8007<br/>Mission Plans, Transcripts,<br/>Recordings, Audit Events"]
  end

  CLIENT -- "Bearer JWT" --> GW
  GW -- "proxy" --> ORCH
  GW -- "proxy" --> WARD
  GW -- "proxy" --> COMM
  GW -- "proxy" --> VTO_SVC
  GW -- "proxy" --> HB
  GW -- "proxy" --> CP

  ORCH -- "list_wardrobe tool" --> WARD
  ORCH -- "search_commerce tool" --> COMM
  ORCH -- "prepare_cart tool" --> CP
  ORCH -- "create_hyperbeam_session tool" --> HB
  ORCH -- "artifacts" --> AA
  GW -- "audit logs" --> AA
  HB -- "bridge events" --> ORCH
  HB -- "recordings" --> AA
  CP -- "recordings" --> AA

Agentic Data Flow

When a user interacts with the styling agent in a "Mission", the Orchestrator executes a reasoning loop, reaching out to other microservices via internal HTTP APIs (acting as "Tools" for the LLM).

sequenceDiagram
    participant C as Client
    participant GW as API Gateway
    participant O as Orchestrator / Vertex AI Agent
    participant W as Wardrobe Service
    participant CM as Commerce Service
    participant HB as Hyperbeam Bridge
    participant CP as Headless CartPrep
    participant AA as Artifacts Audit

    C->>GW: POST /households/{id}/orchestrator/missions/chat
    GW->>O: Forward JWT + Chat Payload

    rect rgb(24, 24, 27)
        Note over O,CM: Agent Tool Execution Loop
        O->>O: LLM reasoning โ€” determine action
        O->>W: GET /items (list_wardrobe tool)
        W-->>O: Return household items
        O->>CM: POST /search (search_commerce tool)
        CM-->>O: Return scored offers
        O->>HB: POST /sessions (create_hyperbeam_session tool)
        HB-->>O: Return embed URL + session ID
        O->>CP: POST /jobs (prepare_cart tool)
        CP-->>O: Return job ID
    end

    O->>AA: POST /artifacts (persist plan + transcript)
    O-->>GW: Return Assistant Response
    GW-->>C: Stream Response + Embedded Browser URL

    opt Virtual Try-On
        C->>GW: POST /households/{id}/vto/jobs
        GW->>GW: Forward to VTO service
    end

    opt User Browser Takeover
        C->>GW: POST /.../sessions/{id}/takeover
        Note over C,HB: User controls browser, Agent paused
        C->>GW: POST /.../sessions/{id}/release
        HB->>O: Bridge event (takeover changed)
    end

Service Responsibility Matrix

ServicePortPrimary ResponsibilityData StoreExternal Deps
api-gateway8080Auth, routing, purchases, voice proxyFirestore / in-memoryOIDC, Gemini Live, Unsplash
orchestrator8003AI agent, missions, tool executionFirestore / in-memoryVertex AI
wardrobe8081Items, outfits, feed, image uploadsFirestore / in-memoryGCS
commerce8002Offer ingestion, semantic searchFirestore / in-memoryโ€”
vto8004Try-on inference pipelineFirestore / in-memoryGPU cluster
headless-cartprep8005Cart automation jobsFirestore / in-memoryPlaywright
hyperbeam-bridge8006Cloud browser sessions, DOM indexingFirestore / in-memoryHyperbeam API
artifacts-audit8007Plans, transcripts, recordings, auditFirestore / in-memoryโ€”

Backend Abstraction Pattern

Every service follows a consistent hexagonal architecture pattern:

src/
โ”œโ”€โ”€ main.py              # Uvicorn entrypoint
โ”œโ”€โ”€ app.py               # FastAPI app factory
โ”œโ”€โ”€ api/
โ”‚   โ”œโ”€โ”€ routes.py         # HTTP endpoints
โ”‚   โ””โ”€โ”€ dependencies.py   # FastAPI Depends (auth, request context)
โ”œโ”€โ”€ core/
โ”‚   โ”œโ”€โ”€ config.py         # Pydantic Settings (env vars)
โ”‚   โ”œโ”€โ”€ security.py       # JWT verification
โ”‚   โ”œโ”€โ”€ errors.py         # Exception handlers
โ”‚   โ””โ”€โ”€ request_context.py
โ”œโ”€โ”€ domain/
โ”‚   โ””โ”€โ”€ models.py         # Pydantic domain models + enums
โ”œโ”€โ”€ repositories/
โ”‚   โ”œโ”€โ”€ types.py          # Abstract repository interface
โ”‚   โ”œโ”€โ”€ factory.py        # Backend selection (firestore | inmemory)
โ”‚   โ”œโ”€โ”€ firestore.py      # Google Firestore implementation
โ”‚   โ””โ”€โ”€ in_memory.py      # Dict-backed stub for local dev
โ””โ”€โ”€ services/
    โ””โ”€โ”€ *.py              # Business logic + inter-service clients

All services support dual persistence backends (PERSISTENCE_BACKEND=firestore|inmemory), allowing the entire stack to run locally without cloud credentials.

On this page