# shawnzxx/banking-auth architecture

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

- Interactive diagram: https://gitdiagram.com/shawnzxx/banking-auth
- Repository: https://github.com/shawnzxx/banking-auth

## Overview

##### Main Components
a. Client/API Entry Point: Represent the external interface that triggers the authentication (likely through HTTP requests routed to app handlers).
b. Application Layer (App Package): Include app/app.go and authHandlers.go. This layer is responsible for handling incoming requests and routing them to appropriate services.
c. Service Layer (Service Package): Represent authService.go. This layer orchestrates business logic and acts as an intermediary between the application layer and the domain logic.
d. Domain Layer (Domain Package): Include core domain files like authRepository.go, login.go, role.go, and token.go. This layer encapsulates business rules, user sessions, roles, tokens, and the persistence logic.
f. Configuration: Represent the local.env file and its role in setting essential environment variables.
g. Build & Dependency Management: Represent files like go.mod, go.sum, and the vendor directory that handle dependencies and build configuration.

##### Relationships and Interactions
- Interactions between the Application Layer and the DTO layer to show that login requests/responses are marshalled into/from the corresponding DTO formats.
- Configuration (local.env) as a dependency that feeds critical operational parameters into the main application at startup.

##### Architectural Patterns and Design Principles
- The project appears to follow a layered architecture (or hexagonal/Clean architecture style), clearly delineating concerns between API handling, service orchestration, and core domain logic.
- The use of a separate DTO layer signals an emphasis on ensuring that data exposed to the client is well-defined and decoupled from internal domain models.
- The presence of an authRepository within the domain package may indicate the use of repository patterns for data persistence, even if the storage specifics aren’t detailed in the current file list.

##### Relevant Technologies/Frameworks
- Even though specific web frameworks aren’t explicitly mentioned, the existence of app handlers suggests that the project likely uses a Go web framework or the net/http package to manage HTTP endpoints.
- Dependency management via go.mod, go.sum, and vendor indicate adherence to Go module best practices.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        CLIENT["Client/API Entry Point"]:::clientStyle
    end

    %% Initialization Layer
    subgraph "Initialization"
        MAIN["main.go"]:::infraStyle
    end

    %% Configuration Layer
    subgraph "Configuration"
        CONFIG["local.env"]:::infraStyle
    end

    %% Build & Dependency Management
    subgraph "Build & Dependency Management"
        GO_MOD["go.mod"]:::infraStyle
        GO_SUM["go.sum"]:::infraStyle
        VENDOR["vendor/"]:::infraStyle
    end

    %% Application Layer
    subgraph "Application Layer"
        APP_MAIN["app/app.go"]:::appStyle
        AUTH_HANDLERS["app/authHandlers.go"]:::appStyle
    end

    %% Data Transfer Layer
    subgraph "Data Transfer Layer"
        DTO_REQ["dto/loginRequest.go"]:::dtoStyle
        DTO_RESP["dto/loginResponse.go"]:::dtoStyle
    end

    %% Service Layer
    subgraph "Service Layer"
        AUTH_SERVICE["service/authService.go"]:::serviceStyle
    end

    %% Domain Layer
    subgraph "Domain Layer"
        AUTH_REPO["domain/authRepository.go"]:::domainStyle
        LOGIN["domain/login.go"]:::domainStyle
        ROLE["domain/role.go"]:::domainStyle
        TOKEN["domain/token.go"]:::domainStyle
    end

    %% Connections
    CLIENT -->|"HTTP_Request"| MAIN
    CONFIG -.->|"config_load"| MAIN
    GO_MOD -.->|"dependency_load"| MAIN
    GO_SUM -.->|"dependency_load"| MAIN
    VENDOR -.->|"dependency_load"| MAIN

    MAIN -->|"Routes_to"| AUTH_HANDLERS
    APP_MAIN -->|"Contains"| AUTH_HANDLERS

    AUTH_HANDLERS -->|"Parse_Request"| DTO_REQ
    AUTH_HANDLERS -->|"Prepare_Response"| DTO_RESP
    AUTH_HANDLERS -->|"Delegate_Auth"| AUTH_SERVICE
    DTO_RESP -->|"Send_Response"| CLIENT

    AUTH_SERVICE -->|"Validate_Login"| LOGIN
    AUTH_SERVICE -->|"Manage_Roles"| ROLE
    AUTH_SERVICE -->|"Generate_Token"| TOKEN
    AUTH_SERVICE -->|"Access_Repository"| AUTH_REPO
    AUTH_REPO -- "Repository_Feedback" --> AUTH_SERVICE

    %% Styles
    classDef clientStyle fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef infraStyle fill:#FDEDEC,stroke:#E74C3C,stroke-width:2px;
    classDef appStyle fill:#D6EAF8,stroke:#3498DB,stroke-width:2px;
    classDef dtoStyle fill:#FCF3CF,stroke:#F1C40F,stroke-width:2px;
    classDef serviceStyle fill:#D5F5E3,stroke:#2ECC71,stroke-width:2px;
    classDef domainStyle fill:#F9E79F,stroke:#F39C12,stroke-width:2px;

    %% Click Events
    click MAIN "https://github.com/shawnzxx/banking-auth/blob/master/main.go"
    click CONFIG "https://github.com/shawnzxx/banking-auth/blob/master/local.env"
    click GO_MOD "https://github.com/shawnzxx/banking-auth/blob/master/go.mod"
    click GO_SUM "https://github.com/shawnzxx/banking-auth/blob/master/go.sum"
    click VENDOR "https://github.com/shawnzxx/banking-auth/tree/master/vendor/"
    click APP_MAIN "https://github.com/shawnzxx/banking-auth/blob/master/app/app.go"
    click AUTH_HANDLERS "https://github.com/shawnzxx/banking-auth/blob/master/app/authHandlers.go"
    click AUTH_SERVICE "https://github.com/shawnzxx/banking-auth/blob/master/service/authService.go"
    click AUTH_REPO "https://github.com/shawnzxx/banking-auth/blob/master/domain/authRepository.go"
    click LOGIN "https://github.com/shawnzxx/banking-auth/blob/master/domain/login.go"
    click ROLE "https://github.com/shawnzxx/banking-auth/blob/master/domain/role.go"
    click TOKEN "https://github.com/shawnzxx/banking-auth/blob/master/domain/token.go"
    click DTO_REQ "https://github.com/shawnzxx/banking-auth/blob/master/dto/loginRequest.go"
    click DTO_RESP "https://github.com/shawnzxx/banking-auth/blob/master/dto/loginResponse.go"
```
