# pablisson/go-gateway architecture

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

- Interactive diagram: https://gitdiagram.com/pablisson/go-gateway
- Repository: https://github.com/pablisson/go-gateway

## Overview

##### Project type and purpose
- This is a Go-based backend service (an HTTP API “gateway”) with a clear layered architecture. It exposes endpoints, applies business logic, and persists data via a repository layer.

##### File structure
- cmd/app/main.go: application entrypoint that boots the HTTP server
- internal/web/server/server.go: configures and starts the HTTP server (router, middleware)
- internal/web/handlers: HTTP handlers (account_handler.go) that map routes to service methods
- internal/service: business-logic layer (account_service.go)
- internal/repository: data persistence adapters (account_repository.go)
- internal/domain: core domain definitions and repository interfaces (account.go, repository.go, errors.go)
- internal/dto: data‐transfer objects used at the HTTP boundary
- .env.example: environment variables (e.g., DB connection)
- go.mod / go.sum: module dependencies

##### README
- The README simply names the project (“go-gateway”)—we infer from the code that it’s a REST API gateway for account management.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Entrypoint"
        AppEntry["App Entry"]:::entry
    end

    subgraph "Web Adapter"
        HTTPServer["HTTP Server"]:::web
        Handlers["Web Handlers"]:::web
    end

    subgraph "DTO Layer"
        DTO["DTO Layer"]:::dto
    end

    subgraph "Service Layer"
        Service["Service Layer"]:::service
    end

    subgraph "Domain Core"
        DomainAccount["account.go"]:::domain
        DomainRepo["repository.go"]:::domain
        DomainErr["errors.go"]:::domain
    end

    subgraph "Repository Layer"
        Repo["Repository Layer"]:::repo
    end

    DB["External Database"]:::db

    subgraph "Config & Modules"
        Env[".env.example"]:::config
        GoMod["go.mod"]:::config
        GoSum["go.sum"]:::config
    end

    AppEntry -->|"Bootstraps Server"| HTTPServer
    HTTPServer -->|"Dispatches Request"| Handlers
    Handlers -->|"Bind to DTO"| DTO
    DTO -->|"Pass DTO"| Service
    Service -->|"Enforce Rules"| DomainAccount
    Service -->|"Call Interface"| Repo
    Repo -->|"SQL Operations"| DB
    DB -->|"Return Data"| Repo
    Repo -->|"Return Entities"| Service
    Service -->|"Return DTO"| DTO
    DTO -->|"Serialize Response"| Handlers

    click AppEntry "https://github.com/pablisson/go-gateway/blob/main/cmd/app/main.go"
    click HTTPServer "https://github.com/pablisson/go-gateway/blob/main/internal/web/server/server.go"
    click Handlers "https://github.com/pablisson/go-gateway/blob/main/internal/web/handlers/account_handler.go"
    click DTO "https://github.com/pablisson/go-gateway/blob/main/internal/dto/account.go"
    click Service "https://github.com/pablisson/go-gateway/blob/main/internal/service/account_service.go"
    click DomainAccount "https://github.com/pablisson/go-gateway/blob/main/internal/domain/account.go"
    click DomainRepo "https://github.com/pablisson/go-gateway/blob/main/internal/domain/repository.go"
    click DomainErr "https://github.com/pablisson/go-gateway/blob/main/internal/domain/errors.go"
    click Repo "https://github.com/pablisson/go-gateway/blob/main/internal/repository/account_repository.go"
    click Env "https://github.com/pablisson/go-gateway/blob/main/.env.example"
    click GoMod "https://github.com/pablisson/go-gateway/blob/main/go.mod"
    click GoSum "https://github.com/pablisson/go-gateway/blob/main/go.sum"

    classDef entry fill:#fef2c0,stroke:#333,stroke-width:1px;
    classDef web fill:#d0f0fd,stroke:#333,stroke-width:1px;
    classDef dto fill:#e2e8f0,stroke:#333,stroke-width:1px;
    classDef service fill:#fde2e2,stroke:#333,stroke-width:1px;
    classDef domain fill:#dbeafe,stroke:#333,stroke-width:1px;
    classDef repo fill:#ffe5b4,stroke:#333,stroke-width:1px;
    classDef db fill:#c0f2c0,stroke:#333,stroke-width:1px;
    classDef config fill:#f0f0f0,stroke:#333,stroke-width:1px;
```
