# panelenelo/goteximg architecture

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

- Interactive diagram: https://gitdiagram.com/panelenelo/goteximg
- Repository: https://github.com/panelenelo/goteximg

## Overview

1. **Overall shape**
   - This is a Go-based server-rendered web application for working with text and images.
   - The repo is organized around a single HTTP app in `cmd/web`, a persistence layer in `internal/models`, SQL migrations in `cmd/migrations`, and presentation assets in `ui`.

2. **Runtime entrypoint**
   - `cmd/web/main.go` is the application bootstrap.
   - `routes.go`, `handlers.go`, `helpers.go`, and `templates.go` suggest a conventional Go HTTP server that wires routes, request handlers, helper utilities, and HTML template rendering together.

3. **Request/response flow**
   - A browser request enters the web server in `cmd/web`.
   - Handlers process the request, likely load or persist a text/image record, then render a page using templates from `ui/html`.
   - Static assets are served separately from `ui/static` for CSS, JavaScript, and images.

4. **Domain and persistence boundary**
   - `internal/models/teximg.go` indicates the core domain object is a combined text/image entity.
   - This package is the likely boundary between HTTP logic and database access, keeping persistence details out of the route handlers.

5. **Database schema management**
   - `cmd/migrations/000001_init_schema.up.sql` and `.down.sql` define the initial schema and rollback.
   - That makes PostgreSQL part of the architecture, with schema evolution managed explicitly rather than implicitly in code.

6. **Presentation layer**
   - `ui/html/base.html` and the `pages/` and `partials/` subfolders show server-side HTML templating with shared layout components.
   - `home.html`, `createText.html`, `view.html`, and `testpage.html` are the main user-facing views.
   - `nav.html` and `footer.html` are reusable fragments, implying a consistent page shell across the app.

7. **Front-end assets**
   - `ui/static/css`, `ui/static/js`, and `ui/static/img` hold the client-side assets.
   - `base.js` and `testbase.js` suggest lightweight client behavior rather than a separate SPA frontend.

8. **Container and local environment**
   - `Dockerfile` and `compose.yaml` indicate the app is containerized for local development or deployment.
   - `postgres.yaml` and `imgsrv.yaml` imply the repo expects supporting services beyond the web process, most likely PostgreSQL and an image-related service.

9. **Observability and log pipeline**
   - `observability.yaml` and `fluent-bit.yaml` point to a logging/telemetry setup.
   - This suggests logs are collected and forwarded through Fluent Bit into an observability stack, which is architecturally separate from the web request path.

10. **Operational tooling**
   - `Makefile` and `reset.sh` are repo-level automation for building, running, and resetting the environment.
   - These files support the local developer workflow and environment lifecycle rather than application behavior.

11. **Architecture summary for a diagram**
   - The main diagram should show: browser → Go web server (`cmd/web`) → templates/static response, plus web server → model layer (`internal/models`) → PostgreSQL via migrations-defined schema.
   - Side systems to include are container orchestration (`compose.yaml`), an image service (`imgsrv.yaml`), and observability/logging (`fluent-bit.yaml`, `observability.yaml`).

Main entry points: [`cmd/web/handlers.go`](https://github.com/panelenelo/goteximg/blob/main/cmd/web/handlers.go) (Handlers), [`cmd/web/main.go`](https://github.com/panelenelo/goteximg/blob/main/cmd/web/main.go) (Main), [`cmd/web/templates.go`](https://github.com/panelenelo/goteximg/blob/main/cmd/web/templates.go) (Templates), [`compose.yaml`](https://github.com/panelenelo/goteximg/blob/main/compose.yaml) (Compose)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Web runtime"]
  node_webmain["Main<br/>entrypoint<br/>[main.go]"]
  node_routes["Routes<br/>http routing<br/>[routes.go]"]
  node_handlers["Handlers<br/>[handlers.go]"]
  node_helpers["Helpers<br/>[helpers.go]"]
  node_templates["Templates<br/>rendering<br/>[templates.go]"]
end

subgraph group_domain["Domain & data"]
  node_teximg[("TexImg<br/>domain model<br/>[teximg.go]")]
  node_migrations["Migrations<br/>schema"]
end

subgraph group_presentation["UI layer"]
  node_basehtml["Base layout<br/>template<br/>[base.html]"]
  node_pages["Pages<br/>templates<br/>[home.html]"]
  node_partials["Partials<br/>fragments<br/>[nav.html]"]
  node_css["Styles<br/>static css<br/>[main.css]"]
  node_js["Client JS<br/>static js<br/>[base.js]"]
  node_img["Images<br/>static media"]
end

subgraph group_ops["Operations"]
  node_compose["Compose<br/>orchestration<br/>[compose.yaml]"]
  node_imgsrv["Image svc<br/>service spec<br/>[imgsrv.yaml]"]
  node_fluentbit["Fluent Bit<br/>logging pipeline<br/>[fluent-bit.yaml]"]
  node_observability["Observability<br/>telemetry stack<br/>[observability.yaml]"]
end

subgraph group_external["External systems"]
  node_browser(("Browser<br/>client"))
  node_postgres[("PostgreSQL<br/>database")]
end

node_browser -->|"HTTP requests"| node_webmain
node_webmain -->|"wires"| node_routes
node_webmain -->|"starts"| node_handlers
node_webmain -->|"loads"| node_templates
node_webmain -.->|"uses"| node_helpers
node_routes -->|"dispatches"| node_handlers
node_handlers -->|"reads/writes"| node_teximg
node_handlers -->|"renders"| node_templates
node_handlers -.->|"calls"| node_helpers
node_teximg -.->|"schema"| node_migrations
node_migrations -->|"applies to"| node_postgres
node_templates -->|"includes"| node_basehtml
node_templates -->|"loads"| node_pages
node_templates -->|"includes"| node_partials
node_handlers -.->|"serves"| node_css
node_handlers -.->|"serves"| node_js
node_handlers -.->|"references"| node_img
node_compose -->|"runs"| node_webmain
node_compose -->|"provisions"| node_postgres
node_compose -->|"provisions"| node_imgsrv
node_compose -.->|"includes"| node_observability
node_observability -->|"uses"| node_fluentbit

click node_webmain "https://github.com/panelenelo/goteximg/blob/main/cmd/web/main.go"
click node_routes "https://github.com/panelenelo/goteximg/blob/main/cmd/web/routes.go"
click node_handlers "https://github.com/panelenelo/goteximg/blob/main/cmd/web/handlers.go"
click node_helpers "https://github.com/panelenelo/goteximg/blob/main/cmd/web/helpers.go"
click node_templates "https://github.com/panelenelo/goteximg/blob/main/cmd/web/templates.go"
click node_teximg "https://github.com/panelenelo/goteximg/blob/main/internal/models/teximg.go"
click node_migrations "https://github.com/panelenelo/goteximg/blob/main/cmd/migrations/000001_init_schema.up.sql"
click node_basehtml "https://github.com/panelenelo/goteximg/blob/main/ui/html/base.html"
click node_pages "https://github.com/panelenelo/goteximg/blob/main/ui/html/pages/home.html"
click node_partials "https://github.com/panelenelo/goteximg/blob/main/ui/html/partials/nav.html"
click node_css "https://github.com/panelenelo/goteximg/blob/main/ui/static/css/main.css"
click node_js "https://github.com/panelenelo/goteximg/blob/main/ui/static/js/base.js"
click node_img "https://github.com/panelenelo/goteximg/tree/main/ui/static/img"
click node_compose "https://github.com/panelenelo/goteximg/blob/main/compose.yaml"
click node_imgsrv "https://github.com/panelenelo/goteximg/blob/main/imgsrv.yaml"
click node_fluentbit "https://github.com/panelenelo/goteximg/blob/main/fluent-bit.yaml"
click node_observability "https://github.com/panelenelo/goteximg/blob/main/observability.yaml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_webmain,node_routes,node_handlers,node_helpers,node_templates toneBlue
class node_teximg,node_migrations toneAmber
class node_basehtml,node_pages,node_partials,node_css,node_js,node_img toneMint
class node_compose,node_imgsrv,node_fluentbit,node_observability toneRose
class node_browser,node_postgres toneIndigo
```

## Components

### Web runtime

Go HTTP application entrypoint and request handling

- [Main](https://github.com/panelenelo/goteximg/blob/main/cmd/web/main.go): entrypoint · Application bootstrap · `cmd/web/main.go`
- [Routes](https://github.com/panelenelo/goteximg/blob/main/cmd/web/routes.go): http routing · URL and handler wiring · `cmd/web/routes.go`
- [Handlers](https://github.com/panelenelo/goteximg/blob/main/cmd/web/handlers.go): http handlers · Request processing and response orchestration · `cmd/web/handlers.go`
- [Helpers](https://github.com/panelenelo/goteximg/blob/main/cmd/web/helpers.go): web helpers · Shared request and rendering utilities · `cmd/web/helpers.go`
- [Templates](https://github.com/panelenelo/goteximg/blob/main/cmd/web/templates.go): rendering · Template loading and page assembly · `cmd/web/templates.go`

### Domain & data

Core text/image model and schema evolution

- [TexImg](https://github.com/panelenelo/goteximg/blob/main/internal/models/teximg.go): domain model · Core text/image entity and persistence boundary · `internal/models/teximg.go`
- [Migrations](https://github.com/panelenelo/goteximg/blob/main/cmd/migrations/000001_init_schema.up.sql): schema · Initial database schema definition and rollback · `cmd/migrations/000001_init_schema.up.sql`

### UI layer

Server-rendered templates and static client assets

- [Base layout](https://github.com/panelenelo/goteximg/blob/main/ui/html/base.html): template · Shared HTML shell · `ui/html/base.html`
- [Pages](https://github.com/panelenelo/goteximg/blob/main/ui/html/pages/home.html): templates · Primary server-rendered views · `ui/html/pages/home.html`
- [Partials](https://github.com/panelenelo/goteximg/blob/main/ui/html/partials/nav.html): fragments · Reusable page fragments · `ui/html/partials/nav.html`
- [Styles](https://github.com/panelenelo/goteximg/blob/main/ui/static/css/main.css): static css · Application stylesheets · `ui/static/css/main.css`
- [Client JS](https://github.com/panelenelo/goteximg/blob/main/ui/static/js/base.js): static js · Lightweight browser behavior · `ui/static/js/base.js`
- [Images](https://github.com/panelenelo/goteximg/tree/main/ui/static/img): static media · Static image assets · `ui/static/img`

### Operations

Container, deployment, and local workflow assets

- [Compose](https://github.com/panelenelo/goteximg/blob/main/compose.yaml): orchestration · Local multi-service environment · `compose.yaml`
- [Image svc](https://github.com/panelenelo/goteximg/blob/main/imgsrv.yaml): service spec · Supporting image-related service · `imgsrv.yaml`
- [Fluent Bit](https://github.com/panelenelo/goteximg/blob/main/fluent-bit.yaml): logging pipeline · Log collection and forwarding config · `fluent-bit.yaml`
- [Observability](https://github.com/panelenelo/goteximg/blob/main/observability.yaml): telemetry stack · Logging and monitoring environment config · `observability.yaml`

### External systems

Runtime dependencies outside the repository

- **Browser**: client · User-facing HTTP client
- **PostgreSQL**: database · Persistent data store

## Connections

- Browser → Main: HTTP requests · Browser traffic enters the Go app
- Main → Routes: wires · Bootstraps route registration
- Main → Handlers: starts · Initializes request handlers
- Main → Templates: loads · Initializes template rendering
- Main → Helpers: uses · Shares runtime utilities
- Routes → Handlers: dispatches · Maps endpoints to handler functions
- Handlers → TexImg: reads/writes · Loads and persists domain records
- Handlers → Templates: renders · Produces HTML responses
- Handlers → Helpers: calls · Uses common request and response helpers
- TexImg → Migrations: schema · Data shape is defined by migrations
- Migrations → PostgreSQL: applies to · Creates and evolves database schema
- Templates → Base layout: includes · Shared layout composition
- Templates → Pages: loads · Main user-facing views
- Templates → Partials: includes · Reusable fragments and page chrome
- Handlers → Styles: serves · Page styling is delivered with responses
- Handlers → Client JS: serves · Client-side behavior is delivered with responses
- Handlers → Images: references · Pages can embed static images
- Compose → Main: runs · Defines the application service
- Compose → PostgreSQL: provisions · Brings up the database dependency
- Compose → Image svc: provisions · Brings up image-related support service
- Compose → Observability: includes · Deploys telemetry and logging setup
- Observability → Fluent Bit: uses · Fluent Bit is the log pipeline component
