# empitrix/zenith architecture

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

- Interactive diagram: https://gitdiagram.com/empitrix/zenith
- Repository: https://github.com/empitrix/zenith

## Overview

##### Main Components

a. Application Layer
- Example applications (blink, timer, rotary-encoder, etc.)
- As top-level components

b. Zenith Abstraction Layer (Core)
- Board Support Package (BLUE-PILL)
- GPIO abstraction
- Timer abstraction
- Encoder drivers

c. Hardware Abstraction Layer (HAL)
- STM32F1xx HAL
- Core functionality
- Peripheral drivers

d. Hardware Layer
- STM32F103C8T6 microcontroller
- Physical peripherals (GPIO, Timers, etc.)

**┌─────────────────────────────────────────┐**
- Applications                            │
- ┌─────┐ ┌──────────────┐ ┌──────────┐  │
- Blink│ │Rotary Encoder│ │Timer Apps│  │
- ┘ └──────────────┘ └──────────┘  │
- ┬───────────────────────┘
- ↓
**┌─────────────────────────────────────────┐**
- Zenith Abstraction Layer                │
- ┌─────────┐ ┌───────┐ ┌─────────────┐  │
- Board API│ │Drivers│ │Sensor Module│  │
- ┬────┘ └───┬───┘ └──────┬──────┘  │
- ┼──────────┼───────────-┼─────────┘
- ↓          ↓            ↓
**┌─────────────────────────────────────────┐**
- STM32F1xx HAL                           │
- ┌────────┐ ┌────────┐ ┌──────────────┐ │
- GPIO HAL│ │Timer HAL│ │Other HAL Modules│
- ┘ └────────┘ └──────────────┘ │
- ┬───────────────────────┘
- ↓
**┌─────────────────────────────────────────┐**
- Hardware (STM32F103C8T6)               │
- ┌────────┐ ┌─────────┐ ┌────────────┐  │
- GPIO Pins│ │Timers   │ │Peripherals │  │
- ┘ └─────────┘ └────────────┘  │
- ┘

##### Important Elements to Highlight

a. Data Flow
- Bidirectional communication between layers

b. Key Abstractions
- Board support package (BLUE-PILL)
- Main driver components
- Relationship between sensors and drivers

##### Additional Details

A side panel showing:
- Configuration components (cmake, build system)
- System initialization flow
- Key dependencies between components

##### Implementation Notes

- Use standardized UML notation where appropriate
- Notes for critical interfaces and abstraction boundaries
- Version information and compatibility notes

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style definitions
    classDef app fill:#b3d1ff,stroke:#333,stroke-width:2px
    classDef zenith fill:#90EE90,stroke:#333,stroke-width:2px
    classDef hal fill:#FFB366,stroke:#333,stroke-width:2px
    classDef hw fill:#E6E6E6,stroke:#333,stroke-width:2px

    %% Application Layer
    subgraph AppLayer["Application Layer"]
        Blink["Blink App"]
        RotaryEncoder["Rotary Encoder App"]
        Timer["Timer App"]
        BtnInt["Button Interrupt App"]
    end

    %% Zenith Abstraction Layer
    subgraph ZenithLayer["Zenith Abstraction Layer"]
        BSP["Board Support Package"]
        GPIO["GPIO Abstraction"]
        TimerAbs["Timer Abstraction"]
        EncDriver["Encoder Driver"]
    end

    %% HAL Layer
    subgraph HALLayer["HAL Layer"]
        CoreHAL["Core HAL"]
        GPIOHAL["GPIO HAL"]
        TimerHAL["Timer HAL"]
        RCCHAL["RCC HAL"]
    end

    %% Hardware Layer
    subgraph HWLayer["Hardware Layer"]
        CoreMCU["Core MCU Definitions"]
        CMSISCore["CMSIS Core"]
        SysConfig["System Configuration"]
        Startup["Startup Code"]
    end

    %% Connections between layers
    AppLayer --> ZenithLayer
    ZenithLayer --> HALLayer
    HALLayer --> HWLayer

    %% Style applications
    Blink:::app
    RotaryEncoder:::app
    Timer:::app
    BtnInt:::app

    BSP:::zenith
    GPIO:::zenith
    TimerAbs:::zenith
    EncDriver:::zenith

    CoreHAL:::hal
    GPIOHAL:::hal
    TimerHAL:::hal
    RCCHAL:::hal

    CoreMCU:::hw
    CMSISCore:::hw
    SysConfig:::hw
    Startup:::hw

    %% Click events for component mapping
    click Blink "https://github.com/Empitrix/Zenith/blob/master/src/apps/blink/main.c"
    click RotaryEncoder "https://github.com/Empitrix/Zenith/blob/master/src/apps/rotary-encoder/main.c"
    click Timer "https://github.com/Empitrix/Zenith/blob/master/src/apps/timer/main.c"
    click BtnInt "https://github.com/Empitrix/Zenith/blob/master/src/apps/btn-interrupt/main.c"
    click BSP "https://github.com/Empitrix/Zenith/blob/master/src/boards/BLUE-PILL/board.h"
    click GPIO "https://github.com/Empitrix/Zenith/blob/master/src/boards/BLUE-PILL/gpio.h"
    click TimerAbs "https://github.com/Empitrix/Zenith/blob/master/src/boards/BLUE-PILL/timer.h"
    click EncDriver "https://github.com/Empitrix/Zenith/blob/master/drivers/encoder/encoder.h"
    click CoreHAL "https://github.com/Empitrix/Zenith/blob/master/src/mcu/stm32f1xx/HAL/Inc/stm32f1xx_hal.h"
    click GPIOHAL "https://github.com/Empitrix/Zenith/blob/master/src/mcu/stm32f1xx/HAL/Inc/stm32f1xx_hal_gpio.h"
    click TimerHAL "https://github.com/Empitrix/Zenith/blob/master/src/mcu/stm32f1xx/HAL/Inc/stm32f1xx_hal_tim.h"
    click RCCHAL "https://github.com/Empitrix/Zenith/blob/master/src/mcu/stm32f1xx/HAL/Inc/stm32f1xx_hal_rcc.h"
    click CoreMCU "https://github.com/Empitrix/Zenith/blob/master/src/mcu/stm32f1xx/CMSIS/Headers/stm32f103xb.h"
    click CMSISCore "https://github.com/Empitrix/Zenith/blob/master/src/mcu/stm32f1xx/CMSIS/Include/core_cm3.h"
    click SysConfig "https://github.com/Empitrix/Zenith/blob/master/src/mcu/stm32f1xx/Core/Inc/stm32f1xx_hal_conf.h"
    click Startup "https://github.com/Empitrix/Zenith/blob/master/src/mcu/stm32f1xx/Core/Startup/startup_stm32f103c8tx.s"
```
