# nieele/invacc_desktop architecture

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

- Interactive diagram: https://gitdiagram.com/nieele/invacc_desktop
- Repository: https://github.com/nieele/invacc_desktop

## Overview

##### And illustrate the primary system components
- Frontend: Represent this with a component labeled “Frontend” containing HTML pages (index, catalog, item, etc.), CSS, JS, and static assets. This layer handles user interaction and presentation.
- Backend: Represent the backend as a service or set of services. Inside the backend, include:
- Command / Server Layer: The main.go file that starts the server.
- Routing Layer: Including the router (router.go) that directs incoming HTTP requests.
- Handlers: For example, auth_handler, customer_handler, item_handler, and rent_handler, which process various API endpoints.
- Middleware: To handle cross-cutting concerns like authentication or logging (found in the middleware directory).
- Business Logic/Services: Auth, Customer, Item, Rent services which encapsulate core business rules.
- Repository Layer: Abstract database interactions (auth_repository, customer_repository, etc.).
- Configuration: The config module that loads and processes settings.
- Utility Modules: Any shared packages, such as the PostgreSQL connection defined in pkg/db.
- Database: A component representing the data persistence layer. Highlight that this is likely a PostgreSQL database, including the relevant SQL scripts found in the “base/createDB” folder for tables, audit, functions, triggers, views, roles, and extensions.

##### Relationships and interactions between components
- Within the Backend, clearly illustrate how the server’s entry point (main.go) invokes the router which, in turn, calls appropriate handlers.
- That each handler uses the service layer to process business logic and then delegates data operations to the repository layer.
- That some configuration and environmental settings (from config modules or template.yaml) influence how the backend operates.

##### Architectural patterns and design principles
- That the backend follows a layered (or possibly hexagonal) architecture with clear separation between routing/HTTP handling, business logic (services), and data access (repositories).
- Optionally, highlight the MVC-like division (even though it isn’t strictly MVC, the separation of concerns is evident).
- For the database, note that initialization and schema definitions (SQL scripts in “base/createDB”) are part of the complete system design.

##### Relevant technologies and integrations
- Frontend: Vanilla HTML, CSS, and JavaScript.
- Backend: Go (with dependency management using go.mod and go.sum), and its standard libraries as well as any third-party packages indicated by the structure.
- Database: PostgreSQL, as implied by the package “pkg/db/postgresql.go” and the SQL scripts.
- Additional modules: Mention any config templating and deployment scripts evident in the project.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        FE("Frontend UI"):::frontend
    end

    subgraph "Backend Layer"
        BS("Backend Server"):::backend
        AR("API Routing Layer"):::backend
        MW("Middleware"):::backend
        subgraph "Request Handlers"
            AUTHH("Auth Handler"):::handler
            CUSTH("Customer Handler"):::handler
            ITMH("Item Handler"):::handler
            RENTH("Rent Handler"):::handler
        end
        subgraph "Business Logic/Services"
            AUTHS("Auth Service"):::service
            CUSTS("Customer Service"):::service
            ITMS("Item Service"):::service
            RENTS("Rent Service"):::service
        end
        subgraph "Repository Layer"
            REPOAUTH("Auth Repository"):::repository
            REPOCUST("Customer Repository"):::repository
            REPOITM("Item Repository"):::repository
            REPORENT("Rent Repository"):::repository
        end
        DC("Database Connectivity Utility"):::backend
        CONF("Application Configuration"):::backend
        CONF2("Configuration Template"):::backend
    end

    subgraph "Database Layer"
        DB("PostgreSQL Database"):::database
        DS("Database Schema Initialization"):::database
        DD("Database Diagrams & Artifacts"):::database
        DBSeed("Database Seed Data & Dump"):::database
    end

    %% Connections between layers
    FE -->|"HTTPRequest"| BS
    BS -->|"initialize"| AR
    AR -->|"apply"| MW
    MW -->|"route"| AUTHH
    MW -->|"route"| CUSTH
    MW -->|"route"| ITMH
    MW -->|"route"| RENTH
    AUTHH -->|"calls"| AUTHS
    CUSTH -->|"calls"| CUSTS
    ITMH -->|"calls"| ITMS
    RENTH -->|"calls"| RENTS
    AUTHS -->|"uses"| REPOAUTH
    CUSTS -->|"uses"| REPOCUST
    ITMS -->|"uses"| REPOITM
    RENTS -->|"uses"| REPORENT
    REPOAUTH -->|"ops"| DC
    REPOCUST -->|"ops"| DC
    REPOITM -->|"ops"| DC
    REPORENT -->|"ops"| DC
    DC -->|"connects"| DB

    CONF ---|"configures"| BS
    CONF2 ---|"configures"| BS
    DS ---|"initSchema"| DB
    DD ---|"definesSchema"| DB
    DBSeed ---|"seeds"| DB

    %% Click Events
    click FE "https://github.com/nieele/invacc_desktop/tree/master/frontend/"
    click BS "https://github.com/nieele/invacc_desktop/blob/master/backend/cmd/server/main.go"
    click AR "https://github.com/nieele/invacc_desktop/blob/master/backend/internal/app/router.go"
    click AUTHH "https://github.com/nieele/invacc_desktop/blob/master/backend/internal/handlers/auth_handler.go"
    click CUSTH "https://github.com/nieele/invacc_desktop/blob/master/backend/internal/handlers/customer_handler.go"
    click ITMH "https://github.com/nieele/invacc_desktop/blob/master/backend/internal/handlers/item_handler.go"
    click RENTH "https://github.com/nieele/invacc_desktop/blob/master/backend/internal/handlers/rent_handler.go"
    click MW "https://github.com/nieele/invacc_desktop/blob/master/backend/internal/middleware/middleware.go"
    click AUTHS "https://github.com/nieele/invacc_desktop/blob/master/backend/internal/service/auth_service.go"
    click CUSTS "https://github.com/nieele/invacc_desktop/blob/master/backend/internal/service/customer_service.go"
    click ITMS "https://github.com/nieele/invacc_desktop/blob/master/backend/internal/service/item_service.go"
    click RENTS "https://github.com/nieele/invacc_desktop/blob/master/backend/internal/service/rent_service.go"
    click REPOAUTH "https://github.com/nieele/invacc_desktop/blob/master/backend/internal/repository/auth_repository.go"
    click REPOCUST "https://github.com/nieele/invacc_desktop/blob/master/backend/internal/repository/customer_repository.go"
    click REPOITM "https://github.com/nieele/invacc_desktop/blob/master/backend/internal/repository/item_repository.go"
    click REPORENT "https://github.com/nieele/invacc_desktop/blob/master/backend/internal/repository/rent_repository.go"
    click DC "https://github.com/nieele/invacc_desktop/blob/master/backend/pkg/db/postgresql.go"
    click CONF "https://github.com/nieele/invacc_desktop/blob/master/backend/internal/config/config.go"
    click CONF2 "https://github.com/nieele/invacc_desktop/blob/master/backend/configs/template.yaml"
    click DS "https://github.com/nieele/invacc_desktop/tree/master/base/createDB/"
    click DD "https://github.com/nieele/invacc_desktop/blob/master/base/diagrams/diagram_drawdb_vercel_app.json"
    click DBSeed "https://github.com/nieele/invacc_desktop/blob/master/base/InsertTestData.sql"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef handler fill:#FFD700,stroke:#000,stroke-width:1px;
    classDef service fill:#FFB6C1,stroke:#000,stroke-width:1px;
    classDef repository fill:#DDA0DD,stroke:#000,stroke-width:1px;
    classDef database fill:#FFA07A,stroke:#000,stroke-width:1px;
```
