# alejoheu/blogg-prosjekt architecture

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

- Interactive diagram: https://gitdiagram.com/alejoheu/blogg-prosjekt
- Repository: https://github.com/alejoheu/blogg-prosjekt

## Overview

This is a small Go blog: visitors browse recent articles, open an article, or submit a new one; article data is read from and written to PostgreSQL, and submitted content is sanitized. The server also exposes a post form, a rudimentary login handler, and static files. The README is empty, and the source excerpt is limited; notably, the login handler requests a template not present in the tree, and POST /login is only a stub.

Main entry points: [`main.go`](https://github.com/alejoheu/blogg-prosjekt/blob/main/main.go) (HTTP server and routes), [`auth.go`](https://github.com/alejoheu/blogg-prosjekt/blob/main/auth.go) (Login handler), [`templates`](https://github.com/alejoheu/blogg-prosjekt/tree/main/templates) (HTML templates), [`vars.go`](https://github.com/alejoheu/blogg-prosjekt/blob/main/vars.go) (Article data types)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_server["HTTP server and routes<br/>[main.go]"]
  node_login["Login handler<br/>[auth.go]"]
end

subgraph group_content["Article content"]
  node_article_model["Article data types<br/>[vars.go]"]
  node_sanitizer["HTML sanitizer<br/>[main.go]"]
end

subgraph group_assets["Views and assets"]
  node_templates["HTML templates"]
  node_static["Static files"]
end

node_visitor(("Visitor"))
node_postgres[("PostgreSQL")]

node_visitor -->|"sends requests"| node_server
node_server -->|"queries articles"| node_postgres
node_postgres -->|"returns rows"| node_server
node_server -->|"maps article data"| node_article_model
node_server -->|"renders pages"| node_templates
node_server -->|"sanitizes submissions"| node_sanitizer
node_server -->|"inserts articles"| node_postgres
node_server -->|"redirects after submit"| node_visitor
node_server -->|"dispatches login"| node_login
node_login -->|"renders login page"| node_templates
node_server -->|"serves files"| node_static

click node_server "https://github.com/alejoheu/blogg-prosjekt/blob/main/main.go"
click node_login "https://github.com/alejoheu/blogg-prosjekt/blob/main/auth.go"
click node_article_model "https://github.com/alejoheu/blogg-prosjekt/blob/main/vars.go"
click node_sanitizer "https://github.com/alejoheu/blogg-prosjekt/blob/main/main.go"
click node_templates "https://github.com/alejoheu/blogg-prosjekt/tree/main/templates"
click node_static "https://github.com/alejoheu/blogg-prosjekt/tree/main/static"

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_server,node_login toneBlue
class node_article_model,node_sanitizer,node_postgres toneAmber
class node_templates,node_static toneMint
class node_visitor toneIndigo
```

## Components

### Web application

- [HTTP server and routes](https://github.com/alejoheu/blogg-prosjekt/blob/main/main.go): `main.go`
- [Login handler](https://github.com/alejoheu/blogg-prosjekt/blob/main/auth.go): `auth.go`

### Article content

- [Article data types](https://github.com/alejoheu/blogg-prosjekt/blob/main/vars.go): `vars.go`
- [HTML sanitizer](https://github.com/alejoheu/blogg-prosjekt/blob/main/main.go): `main.go`

### Views and assets

- [HTML templates](https://github.com/alejoheu/blogg-prosjekt/tree/main/templates): `templates`
- [Static files](https://github.com/alejoheu/blogg-prosjekt/tree/main/static): `static`

### Other components

- **Visitor**
- **PostgreSQL**

## Connections

- Visitor → HTTP server and routes: sends requests
- HTTP server and routes → PostgreSQL: queries articles
- PostgreSQL → HTTP server and routes: returns rows
- HTTP server and routes → Article data types: maps article data
- HTTP server and routes → HTML templates: renders pages
- HTTP server and routes → HTML sanitizer: sanitizes submissions
- HTTP server and routes → PostgreSQL: inserts articles
- HTTP server and routes → Visitor: redirects after submit
- HTTP server and routes → Login handler: dispatches login
- Login handler → HTML templates: renders login page
- HTTP server and routes → Static files: serves files
