# mohamed-12-tarek/microarch-lab architecture

> Architecture diagram of the GitHub repository mohamed-12-tarek/microarch-lab, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mohamed-12-tarek/microarch-lab
- Repository: https://github.com/mohamed-12-tarek/microarch-lab

## Overview

MicroArch Lab is a browser-based processor simulator. A user edits or uploads assembly, requests a simulation, then inspects registers, memory, errors, and pipeline timing with cycle controls. The backend exposes simulation and upload routes; the named core and simulator modules indicate parsing, processor execution, pipeline handling, and cycle-by-cycle state/history. Major UI and simulation capabilities are represented, but available excerpts do not show the call wiring, and the README provides no architecture details; uncertain links are dashed and uncited.

Main entry points: [`frontend/src/pages/Simulator.jsx`](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/pages/Simulator.jsx) (Simulator page), [`backend/app/core/processor.py`](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/core/processor.py) (Processor), [`backend/app/core/pipeline.py`](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/core/pipeline.py) (Simulation runner), [`frontend/src/hooks/useSimulation.js`](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/hooks/useSimulation.js) (Simulation state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Web interface"]
  node_app["App shell<br/>[App.jsx]"]
  node_simulator_page["Simulator page<br/>[Simulator.jsx]"]
  node_editor["Assembly editor<br/>[AssemblyEditor.jsx]"]
  node_upload["File upload<br/>[FileUpload.jsx]"]
  node_playback["Cycle controls<br/>[CycleControls.jsx]"]
  node_timeline["Pipeline timeline"]
  node_row["Instruction row<br/>[PipelineRow.jsx]"]
  node_register_view["Register viewer<br/>[RegisterViewer.jsx]"]
  node_memory_view["Memory viewer<br/>[MemoryViewer.jsx]"]
  node_errors["Error panel<br/>[ErrorPanel.jsx]"]
  node_hook["Simulation state<br/>[useSimulation.js]"]
end

subgraph group_transport["API boundary"]
  node_client["Simulation client<br/>[simulationApi.js]"]
  node_api["HTTP routes<br/>[routes.py]"]
  node_service["API service<br/>[service.py]"]
end

subgraph group_execution["Simulation execution"]
  node_runner["Simulation runner<br/>[pipeline.py]"]
  node_parser["Assembly parser<br/>[parser.py]"]
  node_cycle["Cycle engine<br/>[cycle_engine.py]"]
end

subgraph group_machine["Processor model"]
  node_processor["Processor<br/>[processor.py]"]
  node_control["Control unit<br/>[control_unit.py]"]
  node_alu["ALU<br/>[alu.py]"]
  node_hazards["Hazard unit<br/>[hazard_unit.py]"]
  node_registers["Register file<br/>[registers.py]"]
  node_memory[("Memory<br/>[memory.py]")]
end

subgraph group_state["Simulation state"]
  node_history["Run history<br/>[history.py]"]
  node_pipeline_state["Pipeline state<br/>[pipeline_state.py]"]
end

node_user(("User"))

node_user -.->|"uses"| node_app
node_app -.->|"shows"| node_simulator_page
node_simulator_page -.->|"edits"| node_editor
node_simulator_page -.->|"uploads"| node_upload
node_simulator_page -.->|"manages"| node_hook
node_hook -.->|"requests"| node_client
node_client -.->|"calls"| node_api
node_api -.->|"delegates"| node_service
node_service -.->|"runs"| node_runner
node_runner -.->|"parses"| node_parser
node_runner -.->|"executes"| node_processor
node_runner -.->|"advances"| node_cycle
node_cycle -.->|"updates"| node_pipeline_state
node_cycle -.->|"records"| node_history
node_processor -.->|"uses"| node_control
node_processor -.->|"uses"| node_alu
node_processor -.->|"checks"| node_hazards
node_processor -.->|"reads/writes"| node_registers
node_processor -.->|"reads/writes"| node_memory
node_hook -.->|"drives"| node_playback
node_simulator_page -.->|"displays"| node_timeline
node_timeline -.->|"renders"| node_row
node_simulator_page -.->|"displays"| node_register_view
node_simulator_page -.->|"displays"| node_memory_view
node_simulator_page -.->|"displays"| node_errors

click node_app "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/App.jsx"
click node_simulator_page "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/pages/Simulator.jsx"
click node_editor "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/components/AssemblyEditor.jsx"
click node_upload "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/components/FileUpload.jsx"
click node_playback "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/components/CycleControls.jsx"
click node_timeline "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/components/PipelineDiagram.jsx"
click node_row "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/components/PipelineRow.jsx"
click node_register_view "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/components/RegisterViewer.jsx"
click node_memory_view "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/components/MemoryViewer.jsx"
click node_errors "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/components/ErrorPanel.jsx"
click node_hook "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/hooks/useSimulation.js"
click node_client "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/services/simulationApi.js"
click node_api "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/api/routes.py"
click node_service "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/api/service.py"
click node_runner "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/core/pipeline.py"
click node_parser "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/core/parser.py"
click node_cycle "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/simulator/cycle_engine.py"
click node_history "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/simulator/history.py"
click node_pipeline_state "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/simulator/pipeline_state.py"
click node_processor "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/core/processor.py"
click node_control "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/core/control_unit.py"
click node_alu "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/core/alu.py"
click node_hazards "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/core/hazard_unit.py"
click node_registers "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/core/registers.py"
click node_memory "https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/core/memory.py"

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_app,node_simulator_page,node_editor,node_upload,node_playback,node_timeline,node_row,node_register_view,node_memory_view,node_errors,node_hook,node_user toneBlue
class node_client,node_api,node_service toneAmber
class node_runner,node_parser,node_cycle toneMint
class node_processor,node_control,node_alu,node_hazards,node_registers,node_memory toneRose
class node_history,node_pipeline_state toneIndigo
```

## Components

### Web interface

- [App shell](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Simulator page](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/pages/Simulator.jsx): `frontend/src/pages/Simulator.jsx`
- [Assembly editor](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/components/AssemblyEditor.jsx): `frontend/src/components/AssemblyEditor.jsx`
- [File upload](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/components/FileUpload.jsx): `frontend/src/components/FileUpload.jsx`
- [Cycle controls](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/components/CycleControls.jsx): `frontend/src/components/CycleControls.jsx`
- [Pipeline timeline](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/components/PipelineDiagram.jsx): `frontend/src/components/PipelineDiagram.jsx`
- [Instruction row](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/components/PipelineRow.jsx): `frontend/src/components/PipelineRow.jsx`
- [Register viewer](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/components/RegisterViewer.jsx): `frontend/src/components/RegisterViewer.jsx`
- [Memory viewer](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/components/MemoryViewer.jsx): `frontend/src/components/MemoryViewer.jsx`
- [Error panel](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/components/ErrorPanel.jsx): `frontend/src/components/ErrorPanel.jsx`
- [Simulation state](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/hooks/useSimulation.js): `frontend/src/hooks/useSimulation.js`

### API boundary

- [Simulation client](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/frontend/src/services/simulationApi.js): `frontend/src/services/simulationApi.js`
- [HTTP routes](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/api/routes.py): `backend/app/api/routes.py`
- [API service](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/api/service.py): `backend/app/api/service.py`

### Simulation execution

- [Simulation runner](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/core/pipeline.py): `backend/app/core/pipeline.py`
- [Assembly parser](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/core/parser.py): `backend/app/core/parser.py`
- [Cycle engine](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/simulator/cycle_engine.py): `backend/app/simulator/cycle_engine.py`

### Processor model

- [Processor](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/core/processor.py): `backend/app/core/processor.py`
- [Control unit](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/core/control_unit.py): `backend/app/core/control_unit.py`
- [ALU](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/core/alu.py): `backend/app/core/alu.py`
- [Hazard unit](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/core/hazard_unit.py): `backend/app/core/hazard_unit.py`
- [Register file](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/core/registers.py): `backend/app/core/registers.py`
- [Memory](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/core/memory.py): `backend/app/core/memory.py`

### Simulation state

- [Run history](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/simulator/history.py): `backend/app/simulator/history.py`
- [Pipeline state](https://github.com/mohamed-12-tarek/microarch-lab/blob/main/backend/app/simulator/pipeline_state.py): `backend/app/simulator/pipeline_state.py`

### Other components

- **User**

## Connections

- User → App shell: uses
- App shell → Simulator page: shows
- Simulator page → Assembly editor: edits
- Simulator page → File upload: uploads
- Simulator page → Simulation state: manages
- Simulation state → Simulation client: requests
- Simulation client → HTTP routes: calls
- HTTP routes → API service: delegates
- API service → Simulation runner: runs
- Simulation runner → Assembly parser: parses
- Simulation runner → Processor: executes
- Simulation runner → Cycle engine: advances
- Cycle engine → Pipeline state: updates
- Cycle engine → Run history: records
- Processor → Control unit: uses
- Processor → ALU: uses
- Processor → Hazard unit: checks
- Processor → Register file: reads/writes
- Processor → Memory: reads/writes
- Simulation state → Cycle controls: drives
- Simulator page → Pipeline timeline: displays
- Pipeline timeline → Instruction row: renders
- Simulator page → Register viewer: displays
- Simulator page → Memory viewer: displays
- Simulator page → Error panel: displays
