Skip to main content

Neural Architecture

Chaos Cypher is organized using a brain-inspired metaphor where each package plays a specialized role in the system.

Package Overview

Package Roles

PackageRoleTechnology
CoreBusiness logic, domain models, pluggable storage portsPure Python, Pydantic, Hexagonal Architecture
CortexREST APIFastAPI, Vertical Slice Architecture
NeuronBackground workersCustom async workers
InterfaceWeb UIReact 18, TypeScript, Vite
CLICommand-line interfaceClick, Core library
InfrastructureRoleTechnology
DatabasePluggable storage backendSQLite (default), more planned
Message QueueJob queue and task dispatchValkey (default)
Search IndexFulltext and vector searchFTS5 + sqlite-vec (in app.db)
Graph AnalyticsGraph algorithmsrustworkx (compiled Rust) — SQLite-backed storage, on-demand in-memory loading for analytics (PageRank, community detection, shortest path, centrality). See Knowledge Graph Storage.
OrchestrationContainer compositionDocker Compose (all-in-one default: Nginx, Valkey, Cortex, and Neuron in a single container; multi-container available for development)

Why This Separation?

Reusability

Core contains all business logic without any web framework dependencies. The CLI uses Core directly — no FastAPI, no HTTP, no web server. Neuron workers use Core for processing without the API layer.

Testability

Core's hexagonal architecture means every external dependency is behind a Protocol interface. Tests can mock storage, LLM providers, and search backends with plain Python objects.

Framework Independence

Core has zero knowledge of FastAPI, SQLModel, or any web framework. If you wanted to build a Django API or a desktop app, Core works without changes.

Dual Deployment

Core supports both async (Cortex/Neuron) and sync (CLI) execution modes through its adapter pattern.

Package Dependencies

  • Core depends on nothing (framework-agnostic)
  • Cortex (API) depends on Core
  • Neuron (Workers) depends on Core
  • CLI depends on Core
  • Interface communicates via HTTP (no Python dependency)

Monorepo Structure

packages/
├── core/ # chaoscypher-core — Business logic
├── cortex/ # chaoscypher-cortex — FastAPI backend
├── neuron/ # chaoscypher-neuron — Background workers
├── interface/ # chaoscypher-interface — React UI
├── cli/ # chaoscypher-cli — CLI tools
└── docker/ # Orchestration only — Docker Compose files

Each package has its own pyproject.toml (Python) or package.json (Node.js), tests, and Dockerfiles.

Next Steps