# v-barros/sider architecture

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

- Interactive diagram: https://gitdiagram.com/v-barros/sider
- Repository: https://github.com/v-barros/sider

## Overview

##### Project Type and Purpose
- It listens on a TCP port, parses incoming RESP commands, executes them against an in-memory hash table, and returns RESP-formatted responses.

##### File Structure
- Top-level C modules map to logical components:
- networking.c/.h + connection.c/.h → socket management & client I/O
- eventloop.c/.h → reactor pattern for multiplexed I/O
- resp_parser.c/.h + parser.c/.h + commands.c → protocol decoding & command dispatch
- ht.c/.h → in-memory hash table (data store)
- server.c/.h → bootstrap, configuration, wiring all components
- utils.c/.h + string.c/.h → helper routines
- No build directories—Makefile drives compilation, LICENSE and README stand alone.

##### README for Additional Insights
- README is minimal, so architecture must be reverse-engineered from modules.
- No external dependencies or services, all runtime functionality lives in this single process.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client & Network Layer
    subgraph "Client & Network Layer"
        direction TB
        Client["External Client"]:::external
        Networking["Networking\n(networking.c/.h)"]:::network
        Connection["Connection Manager\n(connection.c/.h)"]:::network
    end

    %% Core Engine Layer
    subgraph "Core Engine Layer"
        direction TB
        Server["Server Bootstrap\n(server.c/.h)"]:::core
        EventLoop["Event Loop\n(eventloop.c/.h)"]:::core
        RespParser["RESP Parser\n(resp_parser.c/.h)"]:::core
        ParserCore["Parser Core\n(parser.c/.h)"]:::core
        Dispatcher["Command Dispatcher\n(commands.c)"]:::core
    end

    %% Storage Layer
    subgraph "Storage Layer"
        direction TB
        DataStore["In-Memory Hashtable\n(ht.c/.h)"]:::storage
    end

    %% Helpers & Build
    subgraph "Helpers & Build"
        direction TB
        Helpers["Utilities & String Helpers\n(utils.c/.h, string.c/.h)"]:::util
        Make["Build & Docs\n(Makefile, LICENSE, README.md)"]:::util
    end

    %% Data Flow
    Client -->|"TCP Connect"| Networking
    Networking -->|"socket_read()"| EventLoop
    EventLoop -->|"on_read"| RespParser
    RespParser -->|"parse_resp()"| ParserCore
    ParserCore -->|"dispatch_command()"| Dispatcher
    Dispatcher -->|"ht_set()/ht_get()"| DataStore
    DataStore -->|"data_response"| Dispatcher
    Dispatcher -->|"build_resp()"| RespParser
    RespParser -->|"RESP out"| EventLoop
    EventLoop -->|"socket_write()"| Networking
    Networking -->|"TCP Response"| Client

    %% Initialization & Dependencies
    Server --> EventLoop
    Server --> Networking
    Server --> Dispatcher
    Server --> DataStore
    Server --> Helpers
    Helpers --> RespParser
    Helpers --> DataStore

    %% Click Events
    click Networking "https://github.com/v-barros/sider/blob/dev/networking.c"
    click Networking "https://github.com/v-barros/sider/blob/dev/networking.h"
    click Connection "https://github.com/v-barros/sider/blob/dev/connection.c"
    click Connection "https://github.com/v-barros/sider/blob/dev/connection.h"
    click EventLoop "https://github.com/v-barros/sider/blob/dev/eventloop.c"
    click EventLoop "https://github.com/v-barros/sider/blob/dev/eventloop.h"
    click RespParser "https://github.com/v-barros/sider/blob/dev/resp_parser.c"
    click RespParser "https://github.com/v-barros/sider/blob/dev/resp_parser.h"
    click ParserCore "https://github.com/v-barros/sider/blob/dev/parser.c"
    click ParserCore "https://github.com/v-barros/sider/blob/dev/parser.h"
    click Dispatcher "https://github.com/v-barros/sider/blob/dev/commands.c"
    click DataStore "https://github.com/v-barros/sider/blob/dev/ht.c"
    click DataStore "https://github.com/v-barros/sider/blob/dev/ht.h"
    click Server "https://github.com/v-barros/sider/blob/dev/server.c"
    click Server "https://github.com/v-barros/sider/blob/dev/server.h"
    click Helpers "https://github.com/v-barros/sider/blob/dev/utils.c"
    click Helpers "https://github.com/v-barros/sider/blob/dev/utils.h"
    click Helpers "https://github.com/v-barros/sider/blob/dev/string.c"
    click Helpers "https://github.com/v-barros/sider/blob/dev/string.h"
    click Make "https://github.com/v-barros/sider/tree/dev/Makefile"
    click Make "https://github.com/v-barros/sider/tree/dev/LICENSE"
    click Make "https://github.com/v-barros/sider/blob/dev/README.md"

    %% Styles
    classDef external fill:#fff2cc,stroke:#333,stroke-width:1px
    classDef network fill:#cfe2f3,stroke:#333,stroke-width:1px
    classDef core fill:#d9ead3,stroke:#333,stroke-width:1px
    classDef storage fill:#f4cccc,stroke:#333,stroke-width:1px
    classDef util fill:#e7e6e6,stroke:#333,stroke-width:1px
```
