# lkorsman/nonce-app architecture

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

- Interactive diagram: https://gitdiagram.com/lkorsman/nonce-app
- Repository: https://github.com/lkorsman/nonce-app

## Overview

This is a small Go HTTP service for issuing and consuming single-use nonces. A client posts to the issue endpoint to receive a nonce and TTL, then posts that nonce to consume it; the service reports validity and distinguishes missing, expired, and reused tokens. The in-memory store also purges old entries on a ticker. The graph is based on the sampled source; no README was provided, and optional middleware such as request content-type enforcement is not shown as active.

Main entry points: [`server/main.go`](https://github.com/lkorsman/nonce-app/blob/main/server/main.go) (Server bootstrap), [`server/middleware.go`](https://github.com/lkorsman/nonce-app/blob/main/server/middleware.go) (HTTP middleware), [`server/handlers.go`](https://github.com/lkorsman/nonce-app/blob/main/server/handlers.go) (Issue endpoint), [`server/store.go`](https://github.com/lkorsman/nonce-app/blob/main/server/store.go) (Nonce store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["HTTP runtime"]
  node_app["Server bootstrap<br/>[main.go]"]
  node_middleware["HTTP middleware<br/>[middleware.go]"]
end

subgraph group_api["Nonce API"]
  node_issue["Issue endpoint<br/>[handlers.go]"]
  node_consume["Consume endpoint<br/>[handlers.go]"]
end

subgraph group_state["Nonce state"]
  node_store[("Nonce store<br/>[store.go]")]
end

node_client(("HTTP client"))

node_client -->|"sends HTTP"| node_app
node_app -->|"registers routes"| node_middleware
node_app -->|"routes issue"| node_issue
node_app -->|"routes consume"| node_consume
node_issue -->|"issues nonce"| node_store
node_consume -->|"consumes nonce"| node_store
node_app -->|"purges periodically"| node_store
node_middleware -->|"wraps handler"| node_issue
node_middleware -->|"wraps handler"| node_consume

click node_app "https://github.com/lkorsman/nonce-app/blob/main/server/main.go"
click node_middleware "https://github.com/lkorsman/nonce-app/blob/main/server/middleware.go"
click node_issue "https://github.com/lkorsman/nonce-app/blob/main/server/handlers.go"
click node_consume "https://github.com/lkorsman/nonce-app/blob/main/server/handlers.go"
click node_store "https://github.com/lkorsman/nonce-app/blob/main/server/store.go"

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_app,node_middleware,node_client toneBlue
class node_issue,node_consume toneAmber
class node_store toneMint
```

## Components

### HTTP runtime

- [Server bootstrap](https://github.com/lkorsman/nonce-app/blob/main/server/main.go): `server/main.go`
- [HTTP middleware](https://github.com/lkorsman/nonce-app/blob/main/server/middleware.go): `server/middleware.go`

### Nonce API

- [Issue endpoint](https://github.com/lkorsman/nonce-app/blob/main/server/handlers.go): `server/handlers.go`
- [Consume endpoint](https://github.com/lkorsman/nonce-app/blob/main/server/handlers.go): `server/handlers.go`

### Nonce state

- [Nonce store](https://github.com/lkorsman/nonce-app/blob/main/server/store.go): `server/store.go`

### Other components

- **HTTP client**

## Connections

- HTTP client → Server bootstrap: sends HTTP (evidence: `server/main.go`)
- Server bootstrap → HTTP middleware: registers routes (evidence: `server/main.go`)
- Server bootstrap → Issue endpoint: routes issue (evidence: `server/main.go`)
- Server bootstrap → Consume endpoint: routes consume (evidence: `server/main.go`)
- Issue endpoint → Nonce store: issues nonce (evidence: `server/handlers.go`)
- Consume endpoint → Nonce store: consumes nonce (evidence: `server/handlers.go`)
- Server bootstrap → Nonce store: purges periodically (evidence: `server/main.go`)
- HTTP middleware → Issue endpoint: wraps handler
- HTTP middleware → Consume endpoint: wraps handler
