# denysskobalo/silico architecture

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

- Interactive diagram: https://gitdiagram.com/denysskobalo/silico
- Repository: https://github.com/denysskobalo/silico

## Overview

##### Project type and purpose
- The README documents ARM general-purpose, special-purpose and status registers, indicating the C code implements or simulates an ARM-like CPU core.
- The Makefile and .gitignore at the root enforce a unified build and versioning strategy for both components.

##### File structure
- Top-level:
- Makefile – orchestrates building the C library and the Go server (likely via cgo).
- backend/ – Go code; under cmd/server/main.go sits the HTTP server entry point.
- kernel/ – pure C code structured into:
– include/ – header files (types.h, registers.h, cpu.h, flags.h, utils.h, addresses.h) defining data structures and interfaces.
– src/ – implementation modules (cpu.c, utils.c, main.c) that implement CPU behavior.
– archive/ – legacy or experimental C sources (archive/main.c).
- No frontend folder implies the focus is on the backend-service + core library; clients (CLI or web-UI) are external or forthcoming.

##### README for additional insights
- README is a register reference guide rather than an architecture description, confirming that the “kernel” is really a CPU or emulator core.

##### Detail is key
- “archive” submodule as a separate component or note it as “legacy code.”
- External dependencies (Go standard library, C standard library).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    HTTPClient["HTTP Client"]:::client
    HTTPClient -->|"HTTP POST /simulate"| GoServer

    %% Backend Layer
    GoServer["Go API Server"]:::backend
    GoServer -->|"cgo: ExecuteCycle(), ReadRegister()"| CEngine

    %% C Engine Layer
    subgraph "C Simulation Engine" 
        direction TB
        CEngine["C Simulation Engine (Kernel)"]:::engine

        subgraph "Core Modules"
            direction TB
            CPUInterface["cpu.h"]:::module
            CPUImpl["cpu.c"]:::module
            UtilsInterface["utils.h"]:::module
            UtilsImpl["utils.c"]:::module
            RegDefs["registers.h"]:::module
            FlagDefs["flags.h"]:::module
            AddrDefs["addresses.h"]:::module
            TypeDefs["types.h"]:::module
        end

        CMain["main.c"]:::module
        Archive["archive/main.c"]:::module
    end

    %% Build System
    MakefileNode["Makefile"]:::build
    Gitignore[".gitignore"]:::build

    %% Inter-module Relationships
    CPUImpl -->|"calls ALU operations"| UtilsImpl
    CPUImpl -->|"uses definitions"| RegDefs
    CPUImpl -->|"uses definitions"| FlagDefs
    CPUImpl -->|"uses definitions"| AddrDefs
    UtilsImpl -->|"uses types"| TypeDefs
    CMain -->|"initializes CPU"| CPUImpl
    CMain -->|"includes interfaces"| CPUInterface
    Archive -->|"legacy code"| CPUInterface

    %% Build Relationships
    MakefileNode -.->|"compiles C Engine"| CEngine
    MakefileNode -.->|"builds Go Server"| GoServer
    Gitignore -.-> MakefileNode

    %% Click Events
    click GoServer "https://github.com/denysskobalo/silico/blob/main/backend/cmd/server/main.go"
    click CEngine "https://github.com/denysskobalo/silico/tree/main/kernel/"
    click CPUImpl "https://github.com/denysskobalo/silico/blob/main/kernel/src/cpu.c"
    click CPUInterface "https://github.com/denysskobalo/silico/blob/main/kernel/include/cpu.h"
    click UtilsImpl "https://github.com/denysskobalo/silico/blob/main/kernel/src/utils.c"
    click UtilsInterface "https://github.com/denysskobalo/silico/blob/main/kernel/include/utils.h"
    click RegDefs "https://github.com/denysskobalo/silico/blob/main/kernel/include/registers.h"
    click FlagDefs "https://github.com/denysskobalo/silico/blob/main/kernel/include/flags.h"
    click AddrDefs "https://github.com/denysskobalo/silico/blob/main/kernel/include/addresses.h"
    click TypeDefs "https://github.com/denysskobalo/silico/blob/main/kernel/include/types.h"
    click CMain "https://github.com/denysskobalo/silico/blob/main/kernel/src/main.c"
    click Archive "https://github.com/denysskobalo/silico/blob/main/kernel/archive/main.c"
    click MakefileNode "https://github.com/denysskobalo/silico/tree/main/Makefile"
    click Gitignore "https://github.com/denysskobalo/silico/blob/main/.gitignore"

    %% Styles
    classDef client fill:#FFD1DC,stroke:#D14769,stroke-width:2px
    classDef backend fill:#D1E8FF,stroke:#1967B2,stroke-width:2px
    classDef engine fill:#D1FFD1,stroke:#2E7D32,stroke-width:2px
    classDef module fill:#FFF8DC,stroke:#8B4513,stroke-width:1.5px
    classDef build fill:#FFF2CC,stroke:#BF9000,stroke-width:2px
```
