# atomreforge/daizy-night-server architecture

> Architecture diagram of the GitHub repository atomreforge/daizy-night-server, 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/atomreforge/daizy-night-server
- Repository: https://github.com/atomreforge/daizy-night-server

## Overview

Daizy Night is an HTTP account and authentication backend. Its main workflow is registration with a signed, one-use registercode, credential login and token issuance, then authenticated profile/calendar access and refresh or revocation of tokens. The graph includes the documented authorization, rate-limiting, health-check, and reserved OAuth capabilities. Wiring is based on the sampled server assembly and router; service details and several feature implementations were not sampled, so uncertain calls are omitted.

Main entry points: [`internal/service`](https://github.com/atomreforge/daizy-night-server/tree/main/internal/service) (Business services), [`cmd/main.go`](https://github.com/atomreforge/daizy-night-server/blob/main/cmd/main.go) (Server assembly), [`internal/dbware/db.go`](https://github.com/atomreforge/daizy-night-server/blob/main/internal/dbware/db.go) (Database provider), [`internal/router/router.go`](https://github.com/atomreforge/daizy-night-server/blob/main/internal/router/router.go) (Echo routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP access"]
  node_server["Server assembly<br/>[main.go]"]
  node_router["Echo routes<br/>[router.go]"]
  node_handler["HTTP handlers"]
end

subgraph group_identity["Identity workflows"]
  node_services["Business services"]
  node_models["Domain models"]
  node_oauth["GitHub OAuth &#40;reserved&#41;<br/>[register_way.go]"]
end

subgraph group_security["Security"]
  node_middleware["Auth and limits"]
  node_crypto["Token and code crypto"]
  node_config["Configuration"]
end

subgraph group_persistence["Persistence"]
  node_dbprovider[("Database provider<br/>[db.go]")]
  node_users["User repository<br/>[repo_user.go]"]
  node_tokens["Token repository<br/>[repo_token.go]"]
  node_registercodes["Registercode repository"]
  node_calendar["Calendar repository<br/>[repo_calendar.go]"]
end

node_client(("API client"))
node_sqlite[("SQLite database")]

node_client -->|"sends requests"| node_router
node_router -->|"applies middleware"| node_middleware
node_router -->|"dispatches routes"| node_handler
node_handler -->|"calls services"| node_services
node_services -->|"user operations"| node_users
node_services -->|"token operations"| node_tokens
node_services -->|"code operations"| node_registercodes
node_services -->|"calendar operations"| node_calendar
node_services -->|"signs and verifies"| node_crypto
node_middleware -->|"verifies access tokens"| node_crypto
node_users -->|"queries"| node_dbprovider
node_tokens -->|"queries and updates"| node_dbprovider
node_registercodes -->|"claims records"| node_dbprovider
node_calendar -->|"queries and updates"| node_dbprovider
node_dbprovider -->|"persists data"| node_sqlite
node_server -->|"loads settings"| node_config
node_server -->|"initializes provider"| node_crypto
node_server -->|"initializes provider"| node_dbprovider
node_server -->|"assembles services"| node_services
node_server -->|"assembles handlers"| node_handler
node_server -->|"creates router"| node_router

click node_server "https://github.com/atomreforge/daizy-night-server/blob/main/cmd/main.go"
click node_router "https://github.com/atomreforge/daizy-night-server/blob/main/internal/router/router.go"
click node_middleware "https://github.com/atomreforge/daizy-night-server/tree/main/internal/middleware"
click node_handler "https://github.com/atomreforge/daizy-night-server/tree/main/internal/handler"
click node_services "https://github.com/atomreforge/daizy-night-server/tree/main/internal/service"
click node_crypto "https://github.com/atomreforge/daizy-night-server/tree/main/internal/crypto"
click node_config "https://github.com/atomreforge/daizy-night-server/tree/main/internal/config"
click node_dbprovider "https://github.com/atomreforge/daizy-night-server/blob/main/internal/dbware/db.go"
click node_users "https://github.com/atomreforge/daizy-night-server/blob/main/internal/dbware/repo_user.go"
click node_tokens "https://github.com/atomreforge/daizy-night-server/blob/main/internal/dbware/repo_token.go"
click node_registercodes "https://github.com/atomreforge/daizy-night-server/blob/main/internal/dbware/repo_registercode.go"
click node_calendar "https://github.com/atomreforge/daizy-night-server/blob/main/internal/dbware/repo_calendar.go"
click node_models "https://github.com/atomreforge/daizy-night-server/tree/main/internal/model"
click node_oauth "https://github.com/atomreforge/daizy-night-server/blob/main/internal/consts/register_way.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_server,node_router,node_handler,node_client toneBlue
class node_services,node_models,node_oauth,node_sqlite toneAmber
class node_middleware,node_crypto,node_config toneMint
class node_dbprovider,node_users,node_tokens,node_registercodes,node_calendar toneRose
```

## Components

### HTTP access

- [Server assembly](https://github.com/atomreforge/daizy-night-server/blob/main/cmd/main.go): `cmd/main.go`
- [Echo routes](https://github.com/atomreforge/daizy-night-server/blob/main/internal/router/router.go): `internal/router/router.go`
- [HTTP handlers](https://github.com/atomreforge/daizy-night-server/tree/main/internal/handler): `internal/handler`

### Identity workflows

- [Business services](https://github.com/atomreforge/daizy-night-server/tree/main/internal/service): `internal/service`
- [Domain models](https://github.com/atomreforge/daizy-night-server/tree/main/internal/model): `internal/model`
- [GitHub OAuth (reserved)](https://github.com/atomreforge/daizy-night-server/blob/main/internal/consts/register_way.go): `internal/consts/register_way.go`

### Security

- [Auth and limits](https://github.com/atomreforge/daizy-night-server/tree/main/internal/middleware): `internal/middleware`
- [Token and code crypto](https://github.com/atomreforge/daizy-night-server/tree/main/internal/crypto): `internal/crypto`
- [Configuration](https://github.com/atomreforge/daizy-night-server/tree/main/internal/config): `internal/config`

### Persistence

- [Database provider](https://github.com/atomreforge/daizy-night-server/blob/main/internal/dbware/db.go): `internal/dbware/db.go`
- [User repository](https://github.com/atomreforge/daizy-night-server/blob/main/internal/dbware/repo_user.go): `internal/dbware/repo_user.go`
- [Token repository](https://github.com/atomreforge/daizy-night-server/blob/main/internal/dbware/repo_token.go): `internal/dbware/repo_token.go`
- [Registercode repository](https://github.com/atomreforge/daizy-night-server/blob/main/internal/dbware/repo_registercode.go): `internal/dbware/repo_registercode.go`
- [Calendar repository](https://github.com/atomreforge/daizy-night-server/blob/main/internal/dbware/repo_calendar.go): `internal/dbware/repo_calendar.go`

### Other components

- **API client**
- **SQLite database**

## Connections

- API client → Echo routes: sends requests
- Echo routes → Auth and limits: applies middleware
- Echo routes → HTTP handlers: dispatches routes
- HTTP handlers → Business services: calls services
- Business services → User repository: user operations
- Business services → Token repository: token operations
- Business services → Registercode repository: code operations
- Business services → Calendar repository: calendar operations
- Business services → Token and code crypto: signs and verifies
- Auth and limits → Token and code crypto: verifies access tokens
- User repository → Database provider: queries
- Token repository → Database provider: queries and updates
- Registercode repository → Database provider: claims records
- Calendar repository → Database provider: queries and updates
- Database provider → SQLite database: persists data
- Server assembly → Configuration: loads settings
- Server assembly → Token and code crypto: initializes provider
- Server assembly → Database provider: initializes provider
- Server assembly → Business services: assembles services
- Server assembly → HTTP handlers: assembles handlers
- Server assembly → Echo routes: creates router
