Skip to content

Architecture

ContextUnity is a uv workspace monorepo of modular Python services communicating over gRPC. Each service has a single responsibility and shares types through ContextCore (packages/core).

Ecosystem Map

architecture-ecosystem

Communication Pattern

All inter-service communication uses the ContextUnit protocol. Every RPC call carries a typed envelope with:

  • Payload — domain-specific data (google.protobuf.Struct / validated JsonDict)
  • Provenance — ordered trace of processing stages
  • Security — scopes for access control
  • Tracingtrace_id and parent_unit_id for distributed observability

architecture-sequence

Repository layout

contextunity/
├── packages/
│ ├── core/ # Kernel — types, protos, tokens, SDK clients
│ └── cli/ # ContextCLI — local stack orchestration
├── services/
│ ├── router/ # Agent orchestration (LangGraph)
│ ├── brain/ # Vectors, memory, taxonomy, RAG storage
│ ├── worker/ # Temporal + Huey workflows
│ ├── shield/ # Enterprise security
│ └── forge/ # Starlette dashboard + FastMCP + Lab tools
├── extensions/
│ ├── commerce/ # Django PIM + harvester (commercial)
│ ├── rag/ # Chat / Telegram gateway
│ └── spatial/ # Geospatial scaffold (planned capabilities)
├── types/django/ # Shared strict pyright baseline + Django stubs
├── website/ # This documentation site (Astro Starlight)
└── pyrightconfig.json # Single strict gate for all production src/

Service roles

ComponentRoleProtocolLicense
------------------------------------
ContextCoreShared kernel — types, protos, tokens, configlibraryApache 2.0
ContextCLILocal dev orchestration, migrations, stack targetsCLIApache 2.0
ContextRouterAgent orchestration — LangGraph, tools, PII privacygRPCApache 2.0
ContextBrainKnowledge — vectors, memory, taxonomy, RAG storagegRPCApache 2.0
ContextWorkerDurable workflows — Temporal (primary), Huey (local)gRPCApache 2.0
ContextShieldToken signing, AI firewall, secrets vaultgRPCCommercial
ContextForgeObservability dashboard, Brain Admin UI, DevTools/Docs MCPHTTP + MCPApache 2.0
ContextCommerceE-commerce PIM, harvester, matchingDjango + federated toolsApache 2.0
ContextRAGHTTP/Telegram chat gateway (Router-backed)HTTP + gRPC clientCommercial
ContextSpatialVoice/geo/AR scaffoldCommercial

Technology stack

  • Language: Python 3.13+
  • Inter-service: gRPC with Protocol Buffers (packages/core/protos/)
  • Agent framework: LangGraph (LangChain)
  • Database: PostgreSQL 16+ with pgvector and ltree
  • Task engines: Temporal.io (Worker), Huey/Redis (Commerce, local Worker)
  • LLM providers: OpenAI, Anthropic, Vertex AI, Groq, Perplexity, and others via Router
  • Package management: uv workspace
  • Static typing: basedpyright strict — see Code Quality & Types
  • Configuration: Pydantic via get_core_config() (env + YAML merge)