# tanmaykhot/pixvault architecture

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

- Interactive diagram: https://gitdiagram.com/tanmaykhot/pixvault
- Repository: https://github.com/tanmaykhot/pixvault

## Overview

##### Project type and purpose
- Pixvault is a monolithic, server-rendered, full-stack web application written in Go. It provides user authentication, photo galleries, email-based flows (password reset, email signin), and image storage/serving, inspired by Google Photos.

##### File structure
- Top-level:
- cmd/—standalone CLI tools (bcrypt password hasher, experimental “exp” app)
- main.go & lenslocked folder—entrypoint for the HTTP server
- controllers/—HTTP handlers (MVC “Controller” layer)
- views/ & templates/—presentation layer (Go templates + Tailwind)
- models/ & migrations/—data layer (PostgreSQL access, schema SQL files)
- context/—request-scoped user/session context injection
- docker-compose.yml & modd.conf—development orchestration and hot reload
- rand/, errors/—utility packages

##### README
- Confirms it’s a photo storage/management application with user flows around signup, signin, galleries, password resets, and email signin.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["Web Browser"]:::external

    subgraph "Pixvault Server"
        HTTPServer["main.go & lenslocked/"]:::server

        subgraph "Controllers Layer"
            CGO["controllers/cookie.go"]:::server
            GGO["controllers/galleries.go"]:::server
            SGO["controllers/static.go"]:::server
            TGO["controllers/templates.go"]:::server
            UGO["controllers/users.go"]:::server
        end

        subgraph "Context Layer"
            CUSR["context/users.go"]:::server
        end

        subgraph "Models Layer"
            MPG["models/postgres.go"]:::server
            UMG["models/user.go"]:::server
            SSM["models/session.go"]:::server
            PRM["models/password_reset.go"]:::server
            ESM["models/email_signin.go"]:::server
            GMG["models/gallery.go"]:::server
            ELM["models/email.go"]:::server
            ERM["models/errors.go"]:::server
        end

        subgraph "Migrations"
            M01["migrations/00001_users.sql"]:::server
            M02["migrations/00002_sessions.sql"]:::server
            M03["migrations/00003_password_reset.sql"]:::server
            M04["migrations/00004_email_signin.sql"]:::server
            M05["migrations/00005_galleries.sql"]:::server
            M06["migrations/00006_galleries_private.sql"]:::server
            MF["migrations/fs.go"]:::server
        end

        subgraph "View Renderer & Templates"
            VTR["views/template.go"]:::server
            TTW["templates/tailwind.gohtml"]:::server
            TGH["templates/*.gohtml"]:::server
            TGG["templates/galleries/*.gohtml"]:::server
        end

        subgraph "Utility Packages"
            RAND["rand/rand.go"]:::util
            ERPUB["errors/public.go"]:::util
            ERWRAP["errors/wrappers.go"]:::util
        end
    end

    Postgres[(PostgreSQL)]:::db
    FileStore[/"File Storage (FS or S3)"/]:::storage
    EmailSvc["External Email Service"]:::external
    Developers["Developers"]:::external

    subgraph "CLI Tools"
        BCRYPT["cmd/bcrypt/bcrypt.go"]:::cli
        EXPGO["cmd/exp/exp.go"]:::cli
        EXPHTML["cmd/exp/hello.gohtml"]:::cli
    end

    Browser -->|HTTPS| HTTPServer
    HTTPServer --> CGO
    HTTPServer --> GGO
    HTTPServer --> SGO
    HTTPServer --> TGO
    HTTPServer --> UGO

    CGO --> CUSR
    GGO --> CUSR
    SGO --> CUSR
    TGO --> CUSR
    UGO --> CUSR

    CGO --> MPG
    GGO --> MPG
    SGO --> MPG
    TGO --> MPG
    UGO --> MPG

    CGO --> FileStore
    GGO --> FileStore
    SGO --> FileStore
    TGO --> FileStore
    UGO --> FileStore

    UGO --> EmailSvc

    MPG --> Postgres
    UMG --> Postgres
    SSM --> Postgres
    PRM --> Postgres
    ESM --> Postgres
    GMG --> Postgres
    ELM --> Postgres
    ERM --> Postgres

    M01 --> Postgres
    M02 --> Postgres
    M03 --> Postgres
    M04 --> Postgres
    M05 --> Postgres
    M06 --> Postgres
    MF --> Postgres

    HTTPServer --> VTR
    HTTPServer --> TTW
    HTTPServer --> TGH
    HTTPServer --> TGG

    Developers --> BCRYPT
    Developers --> EXPGO
    Developers --> EXPHTML

    classDef server fill:#D0E8FF,stroke:#000
    classDef db fill:#C6F6D5,stroke:#000
    classDef storage fill:#E2E8F0,stroke:#000
    classDef external fill:#FED7D7,stroke:#000
    classDef cli stroke-dasharray:5 5,stroke:#000
    classDef util fill:#F0F4C3,stroke:#000

    click HTTPServer "https://github.com/tanmaykhot/pixvault/blob/main/main.go"
    click HTTPServer "https://github.com/tanmaykhot/pixvault/tree/main/lenslocked/"
    click CGO "https://github.com/tanmaykhot/pixvault/blob/main/controllers/cookie.go"
    click GGO "https://github.com/tanmaykhot/pixvault/blob/main/controllers/galleries.go"
    click SGO "https://github.com/tanmaykhot/pixvault/blob/main/controllers/static.go"
    click TGO "https://github.com/tanmaykhot/pixvault/blob/main/controllers/templates.go"
    click UGO "https://github.com/tanmaykhot/pixvault/blob/main/controllers/users.go"
    click CUSR "https://github.com/tanmaykhot/pixvault/blob/main/context/users.go"
    click MPG "https://github.com/tanmaykhot/pixvault/blob/main/models/postgres.go"
    click UMG "https://github.com/tanmaykhot/pixvault/blob/main/models/user.go"
    click SSM "https://github.com/tanmaykhot/pixvault/blob/main/models/session.go"
    click PRM "https://github.com/tanmaykhot/pixvault/blob/main/models/password_reset.go"
    click ESM "https://github.com/tanmaykhot/pixvault/blob/main/models/email_signin.go"
    click GMG "https://github.com/tanmaykhot/pixvault/blob/main/models/gallery.go"
    click ELM "https://github.com/tanmaykhot/pixvault/blob/main/models/email.go"
    click ERM "https://github.com/tanmaykhot/pixvault/blob/main/models/errors.go"
    click M01 "https://github.com/tanmaykhot/pixvault/blob/main/migrations/00001_users.sql"
    click M02 "https://github.com/tanmaykhot/pixvault/blob/main/migrations/00002_sessions.sql"
    click M03 "https://github.com/tanmaykhot/pixvault/blob/main/migrations/00003_password_reset.sql"
    click M04 "https://github.com/tanmaykhot/pixvault/blob/main/migrations/00004_email_signin.sql"
    click M05 "https://github.com/tanmaykhot/pixvault/blob/main/migrations/00005_galleries.sql"
    click M06 "https://github.com/tanmaykhot/pixvault/blob/main/migrations/00006_galleries_private.sql"
    click MF "https://github.com/tanmaykhot/pixvault/blob/main/migrations/fs.go"
    click VTR "https://github.com/tanmaykhot/pixvault/blob/main/views/template.go"
    click TTW "https://github.com/tanmaykhot/pixvault/blob/main/templates/tailwind.gohtml"
    click TGH "https://github.com/tanmaykhot/pixvault/tree/main/templates"
    click TGG "https://github.com/tanmaykhot/pixvault/tree/main/templates/galleries"
    click RAND "https://github.com/tanmaykhot/pixvault/blob/main/rand/rand.go"
    click ERPUB "https://github.com/tanmaykhot/pixvault/blob/main/errors/public.go"
    click ERWRAP "https://github.com/tanmaykhot/pixvault/blob/main/errors/wrappers.go"
    click BCRYPT "https://github.com/tanmaykhot/pixvault/blob/main/cmd/bcrypt/bcrypt.go"
    click EXPGO "https://github.com/tanmaykhot/pixvault/blob/main/cmd/exp/exp.go"
    click EXPHTML "https://github.com/tanmaykhot/pixvault/blob/main/cmd/exp/hello.gohtml"
```
