# rsta2/circle architecture

> Architecture diagram of the GitHub repository rsta2/circle, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rsta2/circle
- Repository: https://github.com/rsta2/circle

## Overview

##### Main System Components

a) Hardware Abstraction Layer
- SoC Devices (GPIO, UART, DMA, etc.)
- USB Controllers
- Network Controllers
- Sound/Audio Devices
- /Graphics

b) Core System Services
- Memory Management
- Interrupt Handling
- Multi-core Support
- Scheduler
- Device Management

c) Libraries and Drivers
- File Systems (FAT)
- USB Device Drivers
- Network Stack
- Graphics Libraries
- Sound System

d) Application Layer
- Sample Applications
- Test Programs
- -on Modules

##### Component Relationships

Use these connection types:
- Double lines: Hardware interfaces

##### Detailed Component Breakdown

Core Components:
**[Hardware] → [Circle Core (lib/)] → [Device Drivers] → [System Services] → [Applications]**

Key Subsystems:
**USB Stack:**
**[USB Controller] → [HCI Driver] → [Hub Driver] → [Device Classes]**

**Network Stack:**
**[Network Hardware] → [Link Layer] → [Network Layer] → [Transport Layer] → [Applications]**

**File Systems:**
**[Storage Hardware] → [Device Driver] → [FAT Driver] → [File Operations]**

- Applications  |

- Libraries    |

- System Services|

- Drivers     |

- Hardware     |

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Hardware
        HW_GPIO[GPIO]:::hw
        HW_USB[USB Controllers]:::hw
        HW_NET[Network Hardware]:::hw
        HW_SOUND[Sound Hardware]:::hw
        HW_DISPLAY[Display Hardware]:::hw
    end

    subgraph HAL[Hardware Abstraction Layer]
        GPIO["GPIO Controller"]:::hal
        DMA["DMA Controller"]:::hal
        USB_CTRL["USB Controller"]:::hal
        GRAPHICS["Graphics Controller"]:::hal
        SOUND["Sound Controller"]:::hal
    end

    subgraph CORE[Core System Services]
        MEMORY["Memory Manager"]:::core
        INTERRUPT["Interrupt Handler"]:::core
        MULTICORE["Multi-core Support"]:::core
        SCHEDULER["Scheduler"]:::core
        DEVICE_MGR["Device Manager"]:::core
    end

    subgraph LIBS[Libraries and Drivers]
        FAT["FAT File System"]:::lib
        USB_DRIVERS["USB Drivers"]:::lib
        NET_STACK["Network Stack"]:::lib
        SOUND_SYS["Sound System"]:::lib
    end

    subgraph APPS[Application Layer]
        SAMPLES["Sample Apps"]:::app
        TESTS["Test Programs"]:::app
        ADDONS["Add-on Modules"]:::app
    end

    %% Hardware to HAL connections
    HW_GPIO --> GPIO
    HW_USB --> USB_CTRL
    HW_NET --> NET_STACK
    HW_SOUND --> SOUND
    HW_DISPLAY --> GRAPHICS

    %% HAL to Core connections
    GPIO --> DEVICE_MGR
    DMA --> DEVICE_MGR
    USB_CTRL --> DEVICE_MGR
    GRAPHICS --> DEVICE_MGR
    SOUND --> DEVICE_MGR

    %% Core interconnections
    INTERRUPT --> MEMORY
    MULTICORE --> MEMORY
    SCHEDULER --> MEMORY
    DEVICE_MGR --> MEMORY

    %% Core to Libraries connections
    DEVICE_MGR --> FAT
    DEVICE_MGR --> USB_DRIVERS
    DEVICE_MGR --> NET_STACK
    DEVICE_MGR --> SOUND_SYS

    %% Libraries to Apps connections
    FAT --> SAMPLES
    USB_DRIVERS --> SAMPLES
    NET_STACK --> SAMPLES
    SOUND_SYS --> SAMPLES
    
    FAT --> TESTS
    USB_DRIVERS --> TESTS
    NET_STACK --> TESTS
    SOUND_SYS --> TESTS
    
    FAT --> ADDONS
    USB_DRIVERS --> ADDONS
    NET_STACK --> ADDONS
    SOUND_SYS --> ADDONS

    %% Styling
    classDef hw fill:#90EE90
    classDef hal fill:#ADD8E6
    classDef core fill:#FF6961
    classDef lib fill:#FFB347
    classDef app fill:#DDA0DD

    %% Click events
    click GPIO "https://github.com/rsta2/circle/blob/master/include/circle/gpiopin.h"
    click DMA "https://github.com/rsta2/circle/blob/master/include/circle/dmachannel.h"
    click USB_CTRL "https://github.com/rsta2/circle/blob/master/include/circle/usb/dwhci.h"
    click GRAPHICS "https://github.com/rsta2/circle/blob/master/include/circle/bcmframebuffer.h"
    click SOUND "https://github.com/rsta2/circle/blob/master/include/circle/sound/soundbasedevice.h"
    click MEMORY "https://github.com/rsta2/circle/blob/master/include/circle/memory.h"
    click INTERRUPT "https://github.com/rsta2/circle/blob/master/include/circle/interrupt.h"
    click MULTICORE "https://github.com/rsta2/circle/blob/master/include/circle/multicore.h"
    click SCHEDULER "https://github.com/rsta2/circle/blob/master/include/circle/sched/scheduler.h"
    click DEVICE_MGR "https://github.com/rsta2/circle/blob/master/include/circle/device.h"
    click FAT "https://github.com/rsta2/circle/blob/master/include/circle/fs/fat/fat.h"
    click USB_DRIVERS "https://github.com/rsta2/circle/blob/master/include/circle/usb/usbdevice.h"
    click NET_STACK "https://github.com/rsta2/circle/blob/master/include/circle/net/netsubsystem.h"
    click SOUND_SYS "https://github.com/rsta2/circle/blob/master/include/circle/sound/soundcontroller.h"
    click SAMPLES "https://github.com/rsta2/circle/tree/master/sample"
    click TESTS "https://github.com/rsta2/circle/tree/master/test"
    click ADDONS "https://github.com/rsta2/circle/tree/master/addon"
```
