# ankitnayan83/house-bank architecture

> Architecture diagram of the GitHub repository ankitnayan83/house-bank, 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/ankitnayan83/house-bank
- Repository: https://github.com/ankitnayan83/house-bank

## Overview

##### Main Components
- API Service: Represent the files in the “api” directory (account.go, server.go, etc.) as the core service that handles HTTP requests and business logic.
- Database: Include a component for the database. This is illustrated by the “db” directory where you have migration SQL files (under db/migration) and the SQL queries along with auto-generated Go code (under db/sqlc).
- Data Access Layer: Highlight the SQLC-generated code as the translation layer between raw SQL and Go. This shows how queries (SQLC package, query and store components) are used by the API service.
- Utility/Configuration Layer: Represent the “util” package (config.go and random.go) to emphasize how configuration and helper routines are integrated into the system.
- CI/CD Pipeline: Since there is a .github/workflows directory with a cicd.yml, include a deployment/continuous integration component as well.

##### Relationships/Interactions
- Detail that the API interacts with the Data Access Layer (SQLC-generated code) which abstracts away raw SQL calls.
- Optionally, link the CI/CD component to both the application code and database migration processes, reflecting automated testing and deployment.

##### Architectural Patterns and Principles
- Separation of concerns: Highlight that the API layer (business logic and endpoint handling) is separate from the data access layer (SQLC-generated code and migration management).
- Code Generation: Emphasize the use of SQLC for generating strongly typed database access code, a key design decision that simplifies query interactions.
- Testing: Note the inclusion of test files (e.g., account_test.go, main_test.go) which underscores an emphasis on verifying each component separately.

##### Relevant Technologies
- Go as the language (evidenced by go.mod, go.sum, and .go files).
- SQL migrations (likely for PostgreSQL or MySQL) managed via explicit up/down SQL scripts.
- SQLC for code-generation and type safe database operations.
- GitHub Actions for CI/CD as seen in the .github/workflows/cicd.yml file.
- Utility configuration for environment settings (util/config.go).

##### Instructing the Principal Software Engineer
- Blue for application code (API Service, utilities)
- Green for the database and its layers (SQLC, migration)
- Orange for operational components (CI/CD)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Application Layer"
        API["API Service Layer"]:::api
        UTIL["Utility/Configuration"]:::api
    end

    subgraph "Data Access Layer"
        SQLC["SQLC Data Access Layer"]:::db
    end

    subgraph "Database Layer"
        DB["SQL Database"]:::db
        MIG["Migrations"]:::db
    end

    subgraph "CI/CD Operations"
        CI["CI/CD Pipeline"]:::ops
    end

    API -->|"usesConfig"| UTIL
    API -->|"callsSQLC"| SQLC
    SQLC -->|"queriesDB"| DB
    MIG -->|"updatesSchema"| DB
    CI -->|"deploysService"| API
    CI -->|"triggersMigrations"| MIG

    click API "https://github.com/ankitnayan83/house-bank/tree/main/api/"
    click UTIL "https://github.com/ankitnayan83/house-bank/tree/main/util/"
    click SQLC "https://github.com/ankitnayan83/house-bank/tree/main/db/sqlc/"
    click MIG "https://github.com/ankitnayan83/house-bank/tree/main/db/migration/"
    click CI "https://github.com/ankitnayan83/house-bank/blob/main/.github/workflows/cicd.yml"

    classDef api fill:#a2d2ff,stroke:#1d3557,stroke-width:2px;
    classDef db fill:#bde0fe,stroke:#457b9d,stroke-width:2px;
    classDef ops fill:#ffd166,stroke:#f4a261,stroke-width:2px;
```
