# santoshniroula/go-template architecture

> Architecture diagram of the GitHub repository santoshniroula/go-template, 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/santoshniroula/go-template
- Repository: https://github.com/santoshniroula/go-template

## Overview

This small Go web app serves two HTML pages: the root page and a todo list. The todo handler fetches JSON from JSONPlaceholder, builds page data, and renders the todo template; both handlers use the shared template-rendering function. The source shows these runtime relationships, but the README gives little further detail about product capabilities.

Main entry points: [`cmd/web/main.go`](https://github.com/santoshniroula/go-template/blob/main/cmd/web/main.go) (Template renderer), [`templates/index.html`](https://github.com/santoshniroula/go-template/blob/main/templates/index.html) (Index template), [`templates/todo-list.html`](https://github.com/santoshniroula/go-template/blob/main/templates/todo-list.html) (Todo list template)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_user(("Browser"))
node_server["HTTP server<br/>[main.go]"]
node_root["Root handler<br/>[main.go]"]
node_todos["Todo handler<br/>[main.go]"]
node_fetch["Todo fetch<br/>[main.go]"]
node_renderer["Template renderer<br/>[main.go]"]
node_index["Index template<br/>[index.html]"]
node_todo_template["Todo list template<br/>[todo-list.html]"]
node_api["JSONPlaceholder todos"]

node_user -->|"sends request"| node_server
node_server -->|"dispatches /"| node_root
node_server -->|"dispatches /todos/"| node_todos
node_root -->|"renders page"| node_renderer
node_todos -->|"fetches todos"| node_fetch
node_fetch -->|"requests JSON"| node_api
node_fetch -->|"returns todos"| node_todos
node_todos -->|"renders data"| node_renderer
node_renderer -->|"parses template"| node_index
node_renderer -->|"parses template"| node_todo_template
node_renderer -->|"writes HTML"| node_user

click node_server "https://github.com/santoshniroula/go-template/blob/main/cmd/web/main.go"
click node_root "https://github.com/santoshniroula/go-template/blob/main/cmd/web/main.go"
click node_todos "https://github.com/santoshniroula/go-template/blob/main/cmd/web/main.go"
click node_fetch "https://github.com/santoshniroula/go-template/blob/main/cmd/web/main.go"
click node_renderer "https://github.com/santoshniroula/go-template/blob/main/cmd/web/main.go"
click node_index "https://github.com/santoshniroula/go-template/blob/main/templates/index.html"
click node_todo_template "https://github.com/santoshniroula/go-template/blob/main/templates/todo-list.html"

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_user toneBlue
class node_server,node_root,node_todos toneMint
class node_fetch,node_renderer,node_index,node_todo_template toneTeal
class node_api toneIndigo
```

## Components

### Other components

- **Browser**
- [HTTP server](https://github.com/santoshniroula/go-template/blob/main/cmd/web/main.go): `cmd/web/main.go`
- [Root handler](https://github.com/santoshniroula/go-template/blob/main/cmd/web/main.go): `cmd/web/main.go`
- [Todo handler](https://github.com/santoshniroula/go-template/blob/main/cmd/web/main.go): `cmd/web/main.go`
- [Todo fetch](https://github.com/santoshniroula/go-template/blob/main/cmd/web/main.go): `cmd/web/main.go`
- [Template renderer](https://github.com/santoshniroula/go-template/blob/main/cmd/web/main.go): `cmd/web/main.go`
- [Index template](https://github.com/santoshniroula/go-template/blob/main/templates/index.html): `templates/index.html`
- [Todo list template](https://github.com/santoshniroula/go-template/blob/main/templates/todo-list.html): `templates/todo-list.html`
- **JSONPlaceholder todos**

## Connections

- Browser → HTTP server: sends request
- HTTP server → Root handler: dispatches /
- HTTP server → Todo handler: dispatches /todos/
- Root handler → Template renderer: renders page
- Todo handler → Todo fetch: fetches todos
- Todo fetch → JSONPlaceholder todos: requests JSON
- Todo fetch → Todo handler: returns todos
- Todo handler → Template renderer: renders data
- Template renderer → Index template: parses template
- Template renderer → Todo list template: parses template
- Template renderer → Browser: writes HTML
