# alsey89/gogetter architecture

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

- Interactive diagram: https://gitdiagram.com/alsey89/gogetter
- Repository: https://github.com/alsey89/gogetter

## Overview

##### Main Components

A. CLI Tool Component:
- Main CLI commands (init, run, stop) as entry points
- Template generator system
- To the configuration management system

B. Module System:
- Core modules in a logical manner:
- Infrastructure Modules (Server, Database)
- Security Modules (Token/JWT)
- Utility Modules (Logger, Config)
- Communication Modules (Mailer)

C. Configuration Management:
- 3-tier configuration system:
1. Environmental Variables
2. Config Files
3. Fallback Config

**┌─ User Interaction Layer ─────────────────────┐**
- CLI Commands (init, run, stop)              │
- Template Generation                         │
- ┬──────────────────────────┘
- ↓
**┌─ Core Module Layer ──────────────────────────┐**
- ┌─ Infrastructure ─┐  ┌─ Security ────────┐ │
- Echo Server      │  │ JWT/Token Handler │ │
- GORM/PostgreSQL  │  └─────────────────┬─┘ │
- ┬────────┘                    │    │
- ┌─ Utilities ────────┼────┤
- Logger (Zap)       │    │
- Config (Viper)     │    │
- ┬─┘    │
- ┌─ Communications ───────┘      │
- Mailer (GoMail)              │

- ┼───────────────────────────────┘
- ↓
**┌─ Dependency Injection Layer ────────────────┐**
- Uber Fx Framework                 │
- ┘

##### Important Elements to Highlight

- Blue: CLI components
- Green: Core modules
- Yellow: Configuration system
- Purple: External dependencies
- Red: Security components

b. Connection Types:

##### Technical Details

- Framework versions and key dependencies
- Configuration file formats (YAML)
- Environmental variable patterns
- Docker integration points

##### Notes for Implementation

- Use standard UML notation where applicable
- Version information for major components
- Notes about configuration precedence
- Example environmental variable patterns

Remember to include documentation references and note any optional components that can be enabled during initialization. This will help developers understand both the current state and potential expansions of the system.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph CLI["CLI Layer"]
        direction TB
        CLI_MAIN["Main Entry Point"]:::cli
        CLI_INIT["Init Command"]:::cli
        CLI_RUN["Run Command"]:::cli
        CLI_STOP["Stop Command"]:::cli
        CLI_ROOT["Root Command"]:::cli
        CLI_SURVEY["Survey Handler"]:::cli

        CLI_MAIN --> CLI_INIT
        CLI_MAIN --> CLI_RUN
        CLI_MAIN --> CLI_STOP
        CLI_MAIN --> CLI_ROOT
        CLI_INIT --> CLI_SURVEY
    end

    subgraph TEMPLATES["Template System"]
        direction TB
        TPL_DIR["Templates"]:::template
        TPL_DOCKER["Dockerfile Template"]:::template
        TPL_COMPOSE["Docker Compose Template"]:::template
        TPL_MAIN["Main Template"]:::template
        TPL_CONFIG["Config Template"]:::template

        TPL_DIR --> TPL_DOCKER
        TPL_DIR --> TPL_COMPOSE
        TPL_DIR --> TPL_MAIN
        TPL_DIR --> TPL_CONFIG
    end

    subgraph CORE["Core Module Layer"]
        direction TB
        subgraph INFRA["Infrastructure"]
            SERVER["Echo Server"]:::module
            DB["GORM/PostgreSQL"]:::module
        end

        subgraph SECURITY["Security"]
            TOKEN["JWT/Token Handler"]:::security
        end

        subgraph UTILS["Utilities"]
            LOGGER["Logger (Zap)"]:::util
            CONFIG["Config (Viper)"]:::util
            FORMATTER["Formatter"]:::util
        end

        subgraph COMMS["Communications"]
            MAILER["Mailer (GoMail)"]:::comms
        end
    end

    subgraph DI["Dependency Injection"]
        FX["Uber Fx Framework"]:::framework
    end

    subgraph CONFIG_SYSTEM["Configuration System"]
        direction TB
        ENV["Environmental Variables"]:::config
        CONF_FILES["Config Files"]:::config
        FALLBACK["Fallback Config"]:::config

        ENV --> CONF_FILES
        CONF_FILES --> FALLBACK
    end

    CLI --> TEMPLATES
    CLI --> CORE
    CORE --> FX
    CONFIG_SYSTEM --> CORE

    %% Click Events
    click CLI_MAIN "https://github.com/alsey89/gogetter/blob/main/cmd/gogetter/main.go"
    click CLI_INIT "https://github.com/alsey89/gogetter/blob/main/cmd/init.go"
    click CLI_RUN "https://github.com/alsey89/gogetter/blob/main/cmd/run.go"
    click CLI_STOP "https://github.com/alsey89/gogetter/blob/main/cmd/stop.go"
    click CLI_ROOT "https://github.com/alsey89/gogetter/blob/main/cmd/root.go"
    click CLI_SURVEY "https://github.com/alsey89/gogetter/blob/main/cmd/survey/survey.go"
    
    click TPL_DIR "https://github.com/alsey89/gogetter/tree/main/cmd/templates"
    click TPL_DOCKER "https://github.com/alsey89/gogetter/blob/main/cmd/templates/Dockerfile.tpl"
    click TPL_COMPOSE "https://github.com/alsey89/gogetter/blob/main/cmd/templates/docker-compose.yaml.tpl"
    click TPL_MAIN "https://github.com/alsey89/gogetter/blob/main/cmd/templates/main.go.tpl"
    click TPL_CONFIG "https://github.com/alsey89/gogetter/blob/main/cmd/templates/gogetter.yaml.tpl"
    
    click SERVER "https://github.com/alsey89/gogetter/blob/main/pkg/server/module.go"
    click DB "https://github.com/alsey89/gogetter/blob/main/pkg/pgconn/module.go"
    click TOKEN "https://github.com/alsey89/gogetter/blob/main/pkg/token/module.go"
    click LOGGER "https://github.com/alsey89/gogetter/blob/main/pkg/logger/module.go"
    click CONFIG "https://github.com/alsey89/gogetter/blob/main/pkg/config/module.go"
    click FORMATTER "https://github.com/alsey89/gogetter/blob/main/pkg/util/formatter.go"
    click MAILER "https://github.com/alsey89/gogetter/blob/main/pkg/mailer/module.go"
    click CONF_FILES "https://github.com/alsey89/gogetter/blob/main/config.yaml"

    %% Styles
    classDef cli fill:#2196F3,stroke:#1565C0,color:white
    classDef template fill:#4CAF50,stroke:#2E7D32,color:white
    classDef module fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef security fill:#F44336,stroke:#C62828,color:white
    classDef util fill:#FF9800,stroke:#EF6C00,color:white
    classDef comms fill:#795548,stroke:#4E342E,color:white
    classDef framework fill:#607D8B,stroke:#37474F,color:white
    classDef config fill:#FFEB3B,stroke:#FBC02D,color:black
```
