# brownbull/archie architecture

> Architecture diagram of the GitHub repository brownbull/archie, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/brownbull/archie
- Repository: https://github.com/brownbull/archie

## Overview

#### Purpose and Entry Points
Archie is a browser-based architecture-learning and design simulator: users compose system diagrams, inspect compatibility/constraints/economics, simulate demand and failures, and complete scored challenges. The React application boots at `src/main.tsx`, renders routing/mode selection through `src/App.tsx`, and is organized around an interactive canvas rather than a conventional server API.

#### Application Shell and Interaction Surface
The authenticated application shell coordinates workspace layout, toolbox, canvas, inspector, dashboard, and overlays. Canvas authoring uses custom nodes/edges and action controls; the inspector exposes component, connection, configuration, and data-context details.
- `src/components/layout/AppLayout.tsx`
- `src/components/canvas/CanvasView.tsx`
- `src/components/inspector/InspectorPanel.tsx`

#### Canonical Architecture State
Client-side stores are the primary control boundary. `architectureStore` owns the editable graph and derived architecture state; specialized stores own challenge session, simulation state, UI state, preferences, saved canvases, and user progression. UI components invoke store actions; calculation services and engines update derived results rather than directly owning UI state.
- `src/stores/architectureStore.ts`
- `src/stores/challengeStore.ts`
- `src/stores/simulationStore.ts`

#### Reference-Data and Schema Boundary
The simulator is data-driven: YAML component definitions, stacks, blueprints, challenges, and failure scenarios define what can be placed and how it behaves. Repositories load/normalize catalog data, while schemas validate imported and persisted architecture/challenge documents. This separates domain content from interaction and calculation code.
- `src/data/components/`
- `src/repositories/componentRepository.ts`
- `src/schemas/architectureFileSchema.ts`

#### Evaluation, Recalculation, and Guidance Pipeline
Graph edits flow through recalculation orchestration into pure engine stages: resolve ports and compatibility, validate topology and constraints, propagate demand, calculate dashboard/heatmap metrics, evaluate fit/tier/rubric outcomes, then produce recommendations, ghosts, and pathway guidance. These outputs feed canvas warnings, dashboard scores, and inspector guidance.
- `src/services/recalculationService.ts`
- `src/engine/recalculator.ts`
- `src/engine/constraintEvaluator.ts`

#### Simulation and Failure Modeling
Simulation is a distinct execution path over the authored architecture. Demand/traffic patterns and selected failures are injected, the simulation engine generates telemetry and outcomes, and simulation state drives playback/stat panels. Failure impact and break detection also support challenge “break it” feedback.
- `src/engine/simulationEngine.ts`
- `src/engine/demandEngine.ts`
- `src/services/failureImpact.ts`

#### Challenges, Progression, and Persistence
Challenge definitions seed constrained canvases and goals; scoring, attempts, hints, mastery tracks, and chain carry-forward turn the simulator into a progression experience. Persistence hooks/services bridge state to user-specific storage, while YAML import/export is a portable architecture-file boundary.
- `src/services/challengeLoader.ts`
- `src/hooks/useAttemptPersistence.ts`
- `src/services/yamlImporter.ts`

#### Runtime, Infrastructure, and External Services
The frontend is TypeScript/React built with Vite. Firebase is the material backend integration: authentication and Firestore-backed user/canvas/progress data, with security rules and deployment configuration in-repo. GitHub Actions supplies CI, preview, production, and Playwright E2E workflows. Catalog entries model many third-party technologies, but these are simulated reference data rather than runtime integrations.
- `src/lib/firebase.ts`
- `firebase.json`
- `.github/workflows/deploy-production.yml`

Main entry points: [`src/stores/architectureStore.ts`](https://github.com/brownbull/archie/blob/main/src/stores/architectureStore.ts) (Architecture store), [`src/stores/challengeStore.ts`](https://github.com/brownbull/archie/blob/main/src/stores/challengeStore.ts) (Challenge store), [`src/engine/simulationEngine.ts`](https://github.com/brownbull/archie/blob/main/src/engine/simulationEngine.ts) (Simulation engine), [`src/components/layout/AppLayout.tsx`](https://github.com/brownbull/archie/blob/main/src/components/layout/AppLayout.tsx) (Workspace layout)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Interactive UI"]
  node_bootstrap(("React bootstrap<br/>entry point<br/>[main.tsx]"))
  node_app["App routing &amp; modes<br/>application shell<br/>[App.tsx]"]
  node_layout["Workspace layout<br/>authenticated shell<br/>[AppLayout.tsx]"]
  node_canvas["Diagram canvas<br/>authoring surface<br/>[CanvasView.tsx]"]
  node_inspector["Inspector<br/>detail panel<br/>[InspectorPanel.tsx]"]
end

subgraph group_state["Client State"]
  node_architecture_store[("Architecture store<br/>canonical graph state")]
  node_challenge_store[("Challenge store<br/>session state<br/>[challengeStore.ts]")]
  node_simulation_store[("Simulation store<br/>playback state<br/>[simulationStore.ts]")]
end

subgraph group_domain["Catalog &amp; Evaluation"]
  node_catalog["Component catalog<br/>YAML reference data"]
  node_component_repo["Component repository<br/>catalog loader"]
  node_architecture_schema["Architecture schema<br/>document validation"]
  node_recalculation["Recalculation service<br/>orchestrator"]
  node_recalculator{{"Evaluation pipeline<br/>graph engine<br/>[recalculator.ts]"}}
  node_constraints{{"Constraint evaluator<br/>validation engine"}}
end

subgraph group_progress["Simulation &amp; Progression"]
  node_simulation_engine{{"Simulation engine<br/>execution engine"}}
  node_demand_engine{{"Demand engine<br/>traffic model<br/>[demandEngine.ts]"}}
  node_failure_impact["Failure impact<br/>failure analysis<br/>[failureImpact.ts]"]
  node_challenge_loader["Challenge loader<br/>challenge seeding<br/>[challengeLoader.ts]"]
  node_attempt_persistence["Attempt persistence<br/>progress bridge"]
  node_yaml_importer["YAML import/export<br/>portable file boundary<br/>[yamlImporter.ts]"]
end

subgraph group_platform["Platform"]
  node_firebase[("Firebase<br/>auth and Firestore backend<br/>[firebase.ts]")]
  node_firebase_deploy["Firebase deployment<br/>hosting configuration<br/>[firebase.json]"]
  node_ci["Production workflow<br/>GitHub Actions CI/CD"]
end

node_bootstrap -->|"renders"| node_app
node_app -->|"selects workspace"| node_layout
node_layout -->|"hosts"| node_canvas
node_layout -->|"hosts"| node_inspector
node_canvas -->|"edits graph"| node_architecture_store
node_inspector -->|"reads and updates"| node_architecture_store
node_architecture_store -->|"graph changes"| node_recalculation
node_recalculation -->|"runs"| node_recalculator
node_recalculator -->|"evaluates constraints"| node_constraints
node_recalculator -->|"derived results"| node_architecture_store
node_component_repo -->|"loads"| node_catalog
node_component_repo -->|"supplies definitions"| node_architecture_store
node_architecture_schema -.->|"validates documents"| node_architecture_store
node_challenge_loader -->|"seeds sessions"| node_challenge_store
node_challenge_store -->|"applies goals and canvas"| node_architecture_store
node_architecture_store -->|"authored architecture"| node_simulation_engine
node_demand_engine -->|"traffic patterns"| node_simulation_engine
node_failure_impact -->|"failure inputs"| node_simulation_engine
node_simulation_engine -->|"telemetry and outcomes"| node_simulation_store
node_simulation_store -->|"playback overlays"| node_canvas
node_failure_impact -->|"break feedback"| node_challenge_store
node_attempt_persistence -->|"persists attempts"| node_challenge_store
node_attempt_persistence -->|"stores user progress"| node_firebase
node_yaml_importer -->|"validates imports"| node_architecture_schema
node_yaml_importer -->|"imports and exports"| node_architecture_store
node_firebase_deploy -.->|"deploys hosting"| node_firebase
node_ci -->|"production deploy"| node_firebase_deploy

click node_bootstrap "https://github.com/brownbull/archie/blob/main/src/main.tsx"
click node_app "https://github.com/brownbull/archie/blob/main/src/App.tsx"
click node_layout "https://github.com/brownbull/archie/blob/main/src/components/layout/AppLayout.tsx"
click node_canvas "https://github.com/brownbull/archie/blob/main/src/components/canvas/CanvasView.tsx"
click node_inspector "https://github.com/brownbull/archie/blob/main/src/components/inspector/InspectorPanel.tsx"
click node_architecture_store "https://github.com/brownbull/archie/blob/main/src/stores/architectureStore.ts"
click node_challenge_store "https://github.com/brownbull/archie/blob/main/src/stores/challengeStore.ts"
click node_simulation_store "https://github.com/brownbull/archie/blob/main/src/stores/simulationStore.ts"
click node_component_repo "https://github.com/brownbull/archie/blob/main/src/repositories/componentRepository.ts"
click node_architecture_schema "https://github.com/brownbull/archie/blob/main/src/schemas/architectureFileSchema.ts"
click node_recalculation "https://github.com/brownbull/archie/blob/main/src/services/recalculationService.ts"
click node_recalculator "https://github.com/brownbull/archie/blob/main/src/engine/recalculator.ts"
click node_constraints "https://github.com/brownbull/archie/blob/main/src/engine/constraintEvaluator.ts"
click node_simulation_engine "https://github.com/brownbull/archie/blob/main/src/engine/simulationEngine.ts"
click node_demand_engine "https://github.com/brownbull/archie/blob/main/src/engine/demandEngine.ts"
click node_failure_impact "https://github.com/brownbull/archie/blob/main/src/services/failureImpact.ts"
click node_challenge_loader "https://github.com/brownbull/archie/blob/main/src/services/challengeLoader.ts"
click node_attempt_persistence "https://github.com/brownbull/archie/blob/main/src/hooks/useAttemptPersistence.ts"
click node_yaml_importer "https://github.com/brownbull/archie/blob/main/src/services/yamlImporter.ts"
click node_firebase "https://github.com/brownbull/archie/blob/main/src/lib/firebase.ts"
click node_firebase_deploy "https://github.com/brownbull/archie/blob/main/firebase.json"
click node_ci "https://github.com/brownbull/archie/blob/main/.github/workflows/deploy-production.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_bootstrap,node_app,node_layout,node_canvas,node_inspector toneBlue
class node_architecture_store,node_challenge_store,node_simulation_store toneAmber
class node_catalog,node_component_repo,node_architecture_schema,node_recalculation,node_recalculator,node_constraints toneMint
class node_simulation_engine,node_demand_engine,node_failure_impact,node_challenge_loader,node_attempt_persistence,node_yaml_importer toneRose
class node_firebase,node_firebase_deploy,node_ci toneIndigo
```

## Components

### Interactive UI

- [React bootstrap](https://github.com/brownbull/archie/blob/main/src/main.tsx): entry point · `src/main.tsx`
- [App routing & modes](https://github.com/brownbull/archie/blob/main/src/App.tsx): application shell · `src/App.tsx`
- [Workspace layout](https://github.com/brownbull/archie/blob/main/src/components/layout/AppLayout.tsx): authenticated shell · `src/components/layout/AppLayout.tsx`
- [Diagram canvas](https://github.com/brownbull/archie/blob/main/src/components/canvas/CanvasView.tsx): authoring surface · Custom nodes, edges, and authoring controls. · `src/components/canvas/CanvasView.tsx`
- [Inspector](https://github.com/brownbull/archie/blob/main/src/components/inspector/InspectorPanel.tsx): detail panel · `src/components/inspector/InspectorPanel.tsx`

### Client State

- [Architecture store](https://github.com/brownbull/archie/blob/main/src/stores/architectureStore.ts): canonical graph state · Owns editable and derived architecture state. · `src/stores/architectureStore.ts`
- [Challenge store](https://github.com/brownbull/archie/blob/main/src/stores/challengeStore.ts): session state · `src/stores/challengeStore.ts`
- [Simulation store](https://github.com/brownbull/archie/blob/main/src/stores/simulationStore.ts): playback state · `src/stores/simulationStore.ts`

### Catalog & Evaluation

- **Component catalog**: YAML reference data · Defines placeable components and their behavior.
- [Component repository](https://github.com/brownbull/archie/blob/main/src/repositories/componentRepository.ts): catalog loader · Loads and normalizes reference definitions. · `src/repositories/componentRepository.ts`
- [Architecture schema](https://github.com/brownbull/archie/blob/main/src/schemas/architectureFileSchema.ts): document validation · `src/schemas/architectureFileSchema.ts`
- [Recalculation service](https://github.com/brownbull/archie/blob/main/src/services/recalculationService.ts): orchestrator · `src/services/recalculationService.ts`
- [Evaluation pipeline](https://github.com/brownbull/archie/blob/main/src/engine/recalculator.ts): graph engine · Resolves ports, topology, demand, metrics, and guidance. · `src/engine/recalculator.ts`
- [Constraint evaluator](https://github.com/brownbull/archie/blob/main/src/engine/constraintEvaluator.ts): validation engine · `src/engine/constraintEvaluator.ts`

### Simulation & Progression

- [Simulation engine](https://github.com/brownbull/archie/blob/main/src/engine/simulationEngine.ts): execution engine · Generates telemetry and outcomes from demand and failures. · `src/engine/simulationEngine.ts`
- [Demand engine](https://github.com/brownbull/archie/blob/main/src/engine/demandEngine.ts): traffic model · `src/engine/demandEngine.ts`
- [Failure impact](https://github.com/brownbull/archie/blob/main/src/services/failureImpact.ts): failure analysis · `src/services/failureImpact.ts`
- [Challenge loader](https://github.com/brownbull/archie/blob/main/src/services/challengeLoader.ts): challenge seeding · `src/services/challengeLoader.ts`
- [Attempt persistence](https://github.com/brownbull/archie/blob/main/src/hooks/useAttemptPersistence.ts): progress bridge · `src/hooks/useAttemptPersistence.ts`
- [YAML import/export](https://github.com/brownbull/archie/blob/main/src/services/yamlImporter.ts): portable file boundary · `src/services/yamlImporter.ts`

### Platform

- [Firebase](https://github.com/brownbull/archie/blob/main/src/lib/firebase.ts): auth and Firestore backend · Stores user, canvas, and progress data. · `src/lib/firebase.ts`
- [Firebase deployment](https://github.com/brownbull/archie/blob/main/firebase.json): hosting configuration · `firebase.json`
- [Production workflow](https://github.com/brownbull/archie/blob/main/.github/workflows/deploy-production.yml): GitHub Actions CI/CD · `.github/workflows/deploy-production.yml`

## Connections

- React bootstrap → App routing & modes: renders
- App routing & modes → Workspace layout: selects workspace
- Workspace layout → Diagram canvas: hosts
- Workspace layout → Inspector: hosts
- Diagram canvas → Architecture store: edits graph
- Inspector → Architecture store: reads and updates
- Architecture store → Recalculation service: graph changes
- Recalculation service → Evaluation pipeline: runs
- Evaluation pipeline → Constraint evaluator: evaluates constraints
- Evaluation pipeline → Architecture store: derived results
- Component repository → Component catalog: loads
- Component repository → Architecture store: supplies definitions
- Architecture schema → Architecture store: validates documents
- Challenge loader → Challenge store: seeds sessions
- Challenge store → Architecture store: applies goals and canvas
- Architecture store → Simulation engine: authored architecture
- Demand engine → Simulation engine: traffic patterns
- Failure impact → Simulation engine: failure inputs
- Simulation engine → Simulation store: telemetry and outcomes
- Simulation store → Diagram canvas: playback overlays
- Failure impact → Challenge store: break feedback
- Attempt persistence → Challenge store: persists attempts
- Attempt persistence → Firebase: stores user progress
- YAML import/export → Architecture schema: validates imports
- YAML import/export → Architecture store: imports and exports
- Firebase deployment → Firebase: deploys hosting
- Production workflow → Firebase deployment: production deploy
