# 0jk6/triemap architecture

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

- Interactive diagram: https://gitdiagram.com/0jk6/triemap
- Repository: https://github.com/0jk6/triemap

## Overview

##### Main Components

a) HTTP Server Layer
- Entry point (main.go)
- REST API endpoints (/store, /get, /prefix, /suffix)

b) Handler Layer (internal/handlers)
- Request processing
- Response formatting
- API route handling

c) Core Components
- Trie Data Structure (internal/trie)
- Cache System (internal/cache)
- Utility Functions (internal/utils)

**┌─ Client Layer ─────┐**
- HTTP Requests      │
- ┬────────┘
- ↓
**┌─ API Layer ───────┐**
- REST Endpoints    │
- ┬────────┘
- ↓
**┌─ Handler Layer ───┐**
- Request Processing│
- ┬────────┘
- ↓
**┌─ Core Layer ──────┐**
- ┌─────┐  ┌─────┐ │
- Cache│  │Trie │ │
- ┘  └─────┘ │
- ┘

##### Data Flow Representation

- Client requests → HTTP endpoints
- HTTP endpoints → Handlers
- Handlers → Core components (Trie/Cache)
- Return paths for responses

##### Component Details

For each component, include:
- Component name
- Primary responsibilities
- Interactions with other components

##### Technical Specifications

- Go version requirement (>=1.22)
- Port number (8080)
- Supported HTTP methods (GET, POST)
- Data format (JSON)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    Client(("Client"))
    
    %% HTTP Server Layer
    subgraph Server["HTTP Server Layer"]
        direction TB
        MainServer["HTTP Server"]:::server
        API1["/store"]:::api
        API2["/get"]:::api
        API3["/prefix"]:::api
        API4["/suffix"]:::api
    end

    %% Handler Layer
    subgraph Handlers["Request Handler Layer"]
        direction TB
        ReqHandler["Request Processing"]:::handler
        RespHandler["Response Formatting"]:::handler
    end

    %% Core Components Layer
    subgraph Core["Core Components"]
        direction TB
        Trie["Trie Data Structure"]:::core
        Cache["Cache System"]:::core
        Utils["Utility Functions"]:::utils
    end

    %% Connections
    Client --> MainServer
    MainServer --> API1 & API2 & API3 & API4
    API1 & API2 & API3 & API4 --> ReqHandler
    ReqHandler --> RespHandler
    ReqHandler --> Trie
    ReqHandler --> Cache
    Trie <--> Cache
    Utils --> ReqHandler
    Utils --> Trie
    Utils --> Cache
    RespHandler --> MainServer

    %% Click Events
    click MainServer "https://github.com/0jk6/triemap/blob/main/main.go"
    click ReqHandler "https://github.com/0jk6/triemap/blob/main/internal/handlers/handlers.go"
    click Trie "https://github.com/0jk6/triemap/blob/main/internal/trie/trie.go"
    click Cache "https://github.com/0jk6/triemap/blob/main/internal/cache/cache.go"
    click Utils "https://github.com/0jk6/triemap/blob/main/internal/utils/utils.go"

    %% Styles
    classDef server fill:#1E88E5,stroke:#0D47A1,color:white
    classDef api fill:#42A5F5,stroke:#1565C0,color:white
    classDef handler fill:#4CAF50,stroke:#2E7D32,color:white
    classDef core fill:#FFC107,stroke:#FFA000,color:black
    classDef utils fill:#9E9E9E,stroke:#616161,color:white

    %% Legend
    subgraph Legend["Legend"]
        L1["HTTP Server"]:::server
        L2[API Endpoint]:::api
        L3[Handler Component]:::handler
        L4[Core Component]:::core
        L5[Utility Component]:::utils
    end
```
