# vasilzhigilei/liftlogger architecture

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

- Interactive diagram: https://gitdiagram.com/vasilzhigilei/liftlogger
- Repository: https://github.com/vasilzhigilei/liftlogger

## Overview

##### Main Components

A. Client-Side (Frontend):
- Static content layer (HTML, CSS, JS files)
- Templates directory for HTML templates
- Static directory for assets
- Key frontend features:
- Chart.js visualization
- Bootstrap UI components
- Input handling (bootstrap-input-spinner.js)

B. Server-Side (Backend):
- Golang HTTP Server (using Gorilla/mux)
- Session Management (Redis)
- Database Layer (PostgreSQL)

##### Component Relationships

**[Client Layer] <---> [Server Layer] <---> [Data Layer]**

##### Detailed Component Breakdown

Client Layer:

- Frontend Stack     |

- HTML Templates       |
- Bootstrap UI        |
- Chart.js            |
- Custom JS Scripts   |

Server Layer:

- Golang Backend     |

- Gorilla/mux Router  |
- Request Handlers    |
- Helper Functions    |

Data Layer:

- Data Storage       |

- PostgreSQL (User    |
- Data & Progress)    |
- Redis (Sessions)    |

##### Flow Representation

- HTTP requests between client and server
- Session validation flow through Redis
- Data persistence flow to PostgreSQL
- Static asset serving

##### Important Details

A. File Organization:
- How main.go, handlers.go, and dbmanager.go interact
- Template rendering system
- Static file serving setup

B. Data Flow:
- User authentication flow
- Session management
- Workout data storage and retrieval
- Chart data generation

##### Technical Specifications

- Technologies used (Go, PostgreSQL, Redis, Bootstrap, Chart.js)
- Version information
- Environment details (Heroku deployment)

##### The database interaction patterns

Remember to include a note about the Heroku deployment environment, as this affects how the components interact in production.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Templates[HTML Templates]
        Static[Static Content]
        Charts["Chart.js Visualization"]
        InputHandler["Input Handler"]
        FrontendScripts["Frontend Scripts"]
        Styles["CSS Styling"]
        AuthTemplates["Auth Templates"]
    end

    subgraph Server
        MainServer["Main Server"]
        Handlers["Request Handlers"]
        Helpers["Helper Functions"]
        DBManager["Database Manager"]
    end

    subgraph DataStores
        PostgreSQL[(PostgreSQL)]
        Redis[(Redis Sessions)]
    end

    %% Client Layer Relationships
    Static --> Charts
    Static --> InputHandler
    Static --> FrontendScripts
    Static --> Styles
    Templates --> AuthTemplates

    %% Server Layer Relationships
    MainServer --> Handlers
    Handlers --> Helpers
    Handlers --> DBManager

    %% Cross-Layer Relationships
    Client <--> Server
    DBManager --> PostgreSQL
    Handlers --> Redis

    %% Component Mappings
    click Static "https://github.com/vasilzhigilei/LiftLogger/tree/master/static"
    click Charts "https://github.com/vasilzhigilei/LiftLogger/blob/master/static/chartscript.js"
    click InputHandler "https://github.com/vasilzhigilei/LiftLogger/blob/master/static/bootstrap-input-spinner.js"
    click FrontendScripts "https://github.com/vasilzhigilei/LiftLogger/blob/master/static/generate.js"
    click Styles "https://github.com/vasilzhigilei/LiftLogger/blob/master/static/styles.css"
    click Templates "https://github.com/vasilzhigilei/LiftLogger/tree/master/templates"
    click AuthTemplates "https://github.com/vasilzhigilei/LiftLogger/blob/master/templates/loginbtn.html"
    click MainServer "https://github.com/vasilzhigilei/LiftLogger/blob/master/main.go"
    click Handlers "https://github.com/vasilzhigilei/LiftLogger/blob/master/handlers.go"
    click Helpers "https://github.com/vasilzhigilei/LiftLogger/blob/master/helper.go"
    click DBManager "https://github.com/vasilzhigilei/LiftLogger/blob/master/dbmanager.go"

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black

    class Templates,Static,Charts,InputHandler,FrontendScripts,Styles,AuthTemplates frontend
    class MainServer,Handlers,Helpers,DBManager backend
    class PostgreSQL,Redis database

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Component"]:::backend
        Database["Database"]:::database
    end
```
