# ybonda/go-http architecture

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

- Interactive diagram: https://gitdiagram.com/ybonda/go-http
- Repository: https://github.com/ybonda/go-http

## Overview

##### Main Components

a) HTTP Server Layer
- Main HTTP service (port 8080)
- This is the entry point for all client requests

b) Application Layer
- Books Service (from books/books.go)
- Main application logic (from books/main.go)

c) Data Layer
- JSON File Storage (books.json and new-books.json)
- Represents the persistence mechanism

d) Container Environment
- Docker container configuration
- Two distinct targets: dev and runtime

- [Client/Browser] (Top)
- ↓
- [HTTP Server Layer]
- ↓
- [Books Service Layer]
- ↓
- [JSON File Storage] (Bottom)

- Docker Container   |
- [Your Service Stack] |
- (Port 8080)      |

##### Specific Elements

a) Components:
- Use rectangles for service components
- Use hexagons for external interfaces (HTTP endpoint)

b) Interactions:
- Port mapping (8080:8080)
- File I/O operations between service and JSON files

##### Additional Details
- Two JSON file sources
- Both development and runtime container configurations
- Go version information

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        C[Client Requests]
    end

    subgraph "HTTP Server Layer"
        S["HTTP Server (8080)"]:::server
    end

    subgraph "Business Logic Layer"
        BL["Books Service"]:::service
    end

    subgraph "Data Layer"
        D1["books.json"]:::storage
        D2["new-books.json"]:::storage
    end

    subgraph "Container Context"
        direction TB
        DC["Docker Container"]:::container
        VM["Volume Mount"]:::container
    end

    C --> S
    S --> BL
    BL --> D1
    BL --> D2
    DC -.-> S
    VM -.-> D1
    VM -.-> D2

    %% Click events for component mapping
    click S "https://github.com/ybonda/go-http/blob/main/books/main.go"
    click BL "https://github.com/ybonda/go-http/blob/main/books/books.go"
    click D1 "https://github.com/ybonda/go-http/blob/main/books/books.json"
    click D2 "https://github.com/ybonda/go-http/blob/main/books/new-books.json"
    click DC "https://github.com/ybonda/go-http/tree/main/Dockerfile"

    %% Styling
    classDef server fill:#2374f7,stroke:#000,stroke-width:2px,color:#fff
    classDef service fill:#85d075,stroke:#000,stroke-width:2px
    classDef storage fill:#f7d123,stroke:#000,stroke-width:2px
    classDef container fill:#cccccc,stroke:#000,stroke-width:2px,stroke-dasharray: 5 5

    %% Legend
    subgraph Legend
        L1["HTTP Server"]:::server
        L2["Service Component"]:::service
        L3["Storage"]:::storage
        L4["Container Component"]:::container
    end
```
