# eslam276/semi_smart_home architecture

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

- Interactive diagram: https://gitdiagram.com/eslam276/semi_smart_home
- Repository: https://github.com/eslam276/semi_smart_home

## Overview

##### Project Type and Purpose
- This is an embedded project centered around smart home functionality. The existence of modules like ADC (analog-to-digital conversion), CLCD (character LCD display), DIO (digital I/O), EXTI (external interrupt), KPD (keypad), LDR (light sensor), TIMER, UART, and others indicate that this system interacts directly with hardware sensors and actuators.
- The goal appears to be to monitor and control various home automation functionalities through a microcontroller-based environment.

##### Analyzing the File Structure
- The top-level “Smart Home” directory contains multiple modules. Each module typically has header files (indicating configuration, interfaces, and private or internal definitions) and source files (implementing functionality).
- For example, ADC, CLCD, DIO, and others follow a naming convention that separates configuration (cfg.h), interface (interface.h), and implementation (program.c).
- There is also a “Debug” folder containing makefiles and object files, which implies that the project uses a build process (likely with a toolchain for embedded C development).
- The main file (main.c) is at the root of the “Smart Home” directory, suggesting that it acts as the orchestrator, initializing and coordinating the various modules.

##### Extracting Architectural Insights from the Code Organization
- The system is modular – each hardware peripheral or service is encapsulated in separate modules with clear configuration and interfacing. This modular design is typical in embedded systems to separate concerns and improve maintainability.
- The separation of header files (for configurations, public interfaces, and private module internals) indicates careful use of abstraction and encapsulation.

a. Main Components:
- Central Microcontroller/System Core: Represent the microcontroller (or CPU) running main.c, which acts as the brain of the application.
- Hardware Abstraction Modules: Illustrate each peripheral module (ADC, CLCD, DIO, EXTI, GIE, KPD, LDR, MAP, PORT, TIMER, UART) as individual components.
- Debug/Build Environment: Optionally indicate that there is an associated debug/build environment responsible for compilation and linking (though this is secondary to runtime operation).

b. Relationships and Interactions:
- Main application (main.c) interacting with each module.
- That the modules interface with specific hardware registers and external sensors/actuators. For instance, ADC may be connected to analog sensors, CLCD to a display unit, KPD to user input, etc.
- Dependency of modules on shared libraries like BIT_MATH.h and STD_TYPES.h, which provide common utilities and type definitions.

c. Architectural Patterns or Design Principles:
- Modularization and layered abstraction. There is a clear separation between hardware control (e.g., PORT configurations, DIO handling) and higher-level application functionality (APP.c).
- Use of configuration and interface headers to decouple implementation details from usage.

d. Relevant Technologies/Frameworks:
- The use of makefiles and object files in the Debug folder signals a build and debugging process tailored for embedded development.
- There’s likely direct register manipulation and low-level programming, often seen in such embedded systems.

##### Essential Elements
- Use clear labels for each component, identifying each module and the core application clearly.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core System
    subgraph "Embedded System Core"
        CentralController["Central Controller (main.c, APP.c, APP.h)"]:::central
    end

    %% Hardware Modules
    subgraph "Hardware Abstraction Modules"
        ADC["ADC Module"]:::module
        CLCD["CLCD Module"]:::module
        DIO["DIO Module"]:::module
        EXTI["EXTI Module"]:::module
        GIE["GIE Module"]:::module
        KPD["KPD Module"]:::module
        LDR["LDR Module"]:::module
        MAP["MAP Module"]:::module
        PORT["PORT Module"]:::module
        TIMER["TIMER Module"]:::module
        UART["UART Module"]:::module
    end

    %% Utility and Debug
    Util["Utility Libraries"]:::utility
    Debug["Debug/Build Environment"]:::debug

    %% External Devices
    Sensors["Sensors/Actuators"]:::external
    Display["Display Device"]:::external

    %% Relationships from Core Controller to Modules
    CentralController -->|"init_&_call"| ADC
    CentralController -->|"init_&_call"| CLCD
    CentralController -->|"init_&_call"| DIO
    CentralController -->|"init_&_call"| EXTI
    CentralController -->|"init_&_call"| GIE
    CentralController -->|"init_&_call"| KPD
    CentralController -->|"init_&_call"| LDR
    CentralController -->|"init_&_call"| MAP
    CentralController -->|"init_&_call"| PORT
    CentralController -->|"init_&_call"| TIMER
    CentralController -->|"init_&_call"| UART

    %% Modules use Utility Libraries
    ADC -.->|"uses"| Util
    CLCD -.->|"uses"| Util
    DIO -.->|"uses"| Util
    EXTI -.->|"uses"| Util
    GIE -.->|"uses"| Util
    KPD -.->|"uses"| Util
    LDR -.->|"uses"| Util
    MAP -.->|"uses"| Util
    PORT -.->|"uses"| Util
    TIMER -.->|"uses"| Util
    UART -.->|"uses"| Util
    CentralController -.->|"uses"| Util

    %% Debug/Build Environment builds the Core
    Debug -->|"builds"| CentralController

    %% Modules interfacing with external hardware
    ADC -->|"sensor_data"| Sensors
    LDR -->|"light_input"| Sensors
    KPD -->|"user_input"| Sensors
    CLCD -->|"displays"| Display

    %% Click Events for Central Controller
    click CentralController "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/main.c"
    click CentralController "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/APP.c"
    click CentralController "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/APP.h"

    %% Click Events for ADC Module
    click ADC "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/ADC_cfg.h"
    click ADC "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/ADC_interface.h"
    click ADC "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/ADC_private.h"
    click ADC "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/ADC_program.c"
    click ADC "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/ADC_reg.h"

    %% Click Events for CLCD Module
    click CLCD "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/CLCD_cfg.h"
    click CLCD "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/CLCD_interface.h"
    click CLCD "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/CLCD_program.c"
    click CLCD "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/CLCD_prv.h"

    %% Click Events for DIO Module
    click DIO "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/DIO_cfg.h"
    click DIO "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/DIO_interface.h"
    click DIO "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/DIO_program.c"
    click DIO "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/DIO_prv.h"
    click DIO "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/DIO_reg.h"

    %% Click Events for EXTI Module
    click EXTI "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/EXTI_cfg.h"
    click EXTI "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/EXTI_interface.h"
    click EXTI "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/EXTI_private.h"
    click EXTI "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/EXTI_program.c"
    click EXTI "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/EXTI_reg.h"

    %% Click Events for GIE Module
    click GIE "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/GIE_interface.h"
    click GIE "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/GIE_program.c"
    click GIE "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/GIE_reg.h"

    %% Click Events for KPD Module
    click KPD "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/KPD_cfg.h"
    click KPD "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/KPD_interface.h"
    click KPD "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/KPD_private.h"
    click KPD "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/KPD_program.c"

    %% Click Events for LDR Module
    click LDR "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/LDR.h"
    click LDR "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/LDR.c"

    %% Click Events for MAP Module
    click MAP "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/MAP.h"
    click MAP "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/MAP.c"

    %% Click Events for PORT Module
    click PORT "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/PORT_cfg.h"
    click PORT "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/PORT_interface.h"
    click PORT "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/PORT_private.h"
    click PORT "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/PORT_prog.c"
    click PORT "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/PORT_reg.h"

    %% Click Events for TIMER Module
    click TIMER "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/TIMER_cfg.h"
    click TIMER "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/TIMER_interface.h"
    click TIMER "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/TIMER_private.h"
    click TIMER "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/TIMER_prog.c"
    click TIMER "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/TIMER_reg.h"

    %% Click Events for UART Module
    click UART "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/UART_cfg.h"
    click UART "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/UART_interface.h"
    click UART "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/UART_private.h"
    click UART "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/UART_prog.c"
    click UART "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/UART_reg.h"

    %% Click Events for Utility Libraries
    click Util "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/BIT_MATH.h"
    click Util "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/STD_TYPES.h"
    click Util "https://github.com/eslam276/semi_smart_home/blob/main/Smart Home/defines.h"

    %% Click Events for Debug/Build Environment
    click Debug "https://github.com/eslam276/semi_smart_home/tree/main/Smart Home/Debug"

    %% Styles
    classDef central fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef module fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef utility fill:#FAD7A0,stroke:#D68910,stroke-width:2px;
    classDef debug fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef external fill:#D5F5E3,stroke:#28B463,stroke-width:2px;
```
