# sapi69/cabal-server architecture

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

- Interactive diagram: https://gitdiagram.com/sapi69/cabal-server
- Repository: https://github.com/sapi69/cabal-server

## Overview

hackage-server hosts Haskell packages, with user registration and uploads as its primary user workflow. The README also documents secure repository metadata and a separate hackage-mirror client that synchronizes packages between servers. The tree exposes package, documentation, search, and user subsystems, but no source excerpts were provided; their internal call paths and storage relationships therefore cannot be verified here.

Main entry points: [`Distribution/Client/Mirror/CmdLine.hs`](https://github.com/sapi69/cabal-server/blob/master/Distribution/Client/Mirror/CmdLine.hs) (Mirror client), [`Distribution/Server.hs`](https://github.com/sapi69/cabal-server/blob/master/Distribution/Server.hs) (HTTP server), [`Distribution/Server/Framework/MemState.hs`](https://github.com/sapi69/cabal-server/blob/master/Distribution/Server/Framework/MemState.hs) (Persistent state), [`Distribution/Server/Features/Upload.hs`](https://github.com/sapi69/cabal-server/blob/master/Distribution/Server/Features/Upload.hs) (Package upload)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_server["Repository server"]
  node_server_app["HTTP server<br/>[Server.hs]"]
  node_framework["Server framework"]
  node_state[("Persistent state<br/>[MemState.hs]")]
end

subgraph group_package["Package services"]
  node_upload["Package upload<br/>[Upload.hs]"]
  node_package_index[("Package index<br/>[PackageIndex.hs]")]
  node_package_pages["Package pages<br/>[Package.hs]"]
  node_documentation["Documentation<br/>[Documentation.hs]"]
  node_search["Package search<br/>[Search.hs]"]
  node_security["TUF security<br/>[Security.hs]"]
end

subgraph group_accounts["Users and administration"]
  node_users["User accounts<br/>[Users.hs]"]
  node_signup["User signup<br/>[UserSignup.hs]"]
  node_admin["Admin frontend<br/>[AdminFrontend.hs]"]
end

subgraph group_mirror["Mirroring client"]
  node_mirror_client["Mirror client<br/>[CmdLine.hs]"]
  node_mirror_session["Mirror session<br/>[Session.hs]"]
  node_mirror_source["Mirror source adapters"]
  node_mirror_target["Mirror target adapters"]
end

node_user(("Package user"))
node_source_server(("Source server"))
node_target_server(("Target server"))

node_user -->|"uses"| node_server_app
node_user -->|"uploads packages"| node_upload
node_user -->|"registers"| node_signup
node_mirror_client -->|"syncs from"| node_source_server
node_mirror_client -->|"uploads to"| node_target_server
node_server_app -->|"resumes state"| node_state

click node_server_app "https://github.com/sapi69/cabal-server/blob/master/Distribution/Server.hs"
click node_framework "https://github.com/sapi69/cabal-server/tree/master/Distribution/Server/Framework"
click node_upload "https://github.com/sapi69/cabal-server/blob/master/Distribution/Server/Features/Upload.hs"
click node_package_index "https://github.com/sapi69/cabal-server/blob/master/Distribution/Server/Packages/PackageIndex.hs"
click node_package_pages "https://github.com/sapi69/cabal-server/blob/master/Distribution/Server/Pages/Package.hs"
click node_documentation "https://github.com/sapi69/cabal-server/blob/master/Distribution/Server/Features/Documentation.hs"
click node_search "https://github.com/sapi69/cabal-server/blob/master/Distribution/Server/Features/Search.hs"
click node_security "https://github.com/sapi69/cabal-server/blob/master/Distribution/Server/Features/Security.hs"
click node_users "https://github.com/sapi69/cabal-server/blob/master/Distribution/Server/Features/Users.hs"
click node_signup "https://github.com/sapi69/cabal-server/blob/master/Distribution/Server/Features/UserSignup.hs"
click node_admin "https://github.com/sapi69/cabal-server/blob/master/Distribution/Server/Features/AdminFrontend.hs"
click node_mirror_client "https://github.com/sapi69/cabal-server/blob/master/Distribution/Client/Mirror/CmdLine.hs"
click node_mirror_session "https://github.com/sapi69/cabal-server/blob/master/Distribution/Client/Mirror/Session.hs"
click node_mirror_source "https://github.com/sapi69/cabal-server/tree/master/Distribution/Client/Mirror/Repo"
click node_mirror_target "https://github.com/sapi69/cabal-server/tree/master/Distribution/Client/Mirror/Repo"
click node_state "https://github.com/sapi69/cabal-server/blob/master/Distribution/Server/Framework/MemState.hs"

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_app,node_framework,node_state,node_user toneBlue
class node_upload,node_package_index,node_package_pages,node_documentation,node_search,node_security toneAmber
class node_users,node_signup,node_admin,node_source_server,node_target_server toneMint
class node_mirror_client,node_mirror_session,node_mirror_source,node_mirror_target toneRose
```

## Components

### Repository server

- [HTTP server](https://github.com/sapi69/cabal-server/blob/master/Distribution/Server.hs): `Distribution/Server.hs`
- [Server framework](https://github.com/sapi69/cabal-server/tree/master/Distribution/Server/Framework): `Distribution/Server/Framework`
- [Persistent state](https://github.com/sapi69/cabal-server/blob/master/Distribution/Server/Framework/MemState.hs): `Distribution/Server/Framework/MemState.hs`

### Package services

- [Package upload](https://github.com/sapi69/cabal-server/blob/master/Distribution/Server/Features/Upload.hs): `Distribution/Server/Features/Upload.hs`
- [Package index](https://github.com/sapi69/cabal-server/blob/master/Distribution/Server/Packages/PackageIndex.hs): `Distribution/Server/Packages/PackageIndex.hs`
- [Package pages](https://github.com/sapi69/cabal-server/blob/master/Distribution/Server/Pages/Package.hs): `Distribution/Server/Pages/Package.hs`
- [Documentation](https://github.com/sapi69/cabal-server/blob/master/Distribution/Server/Features/Documentation.hs): `Distribution/Server/Features/Documentation.hs`
- [Package search](https://github.com/sapi69/cabal-server/blob/master/Distribution/Server/Features/Search.hs): `Distribution/Server/Features/Search.hs`
- [TUF security](https://github.com/sapi69/cabal-server/blob/master/Distribution/Server/Features/Security.hs): `Distribution/Server/Features/Security.hs`

### Users and administration

- [User accounts](https://github.com/sapi69/cabal-server/blob/master/Distribution/Server/Features/Users.hs): `Distribution/Server/Features/Users.hs`
- [User signup](https://github.com/sapi69/cabal-server/blob/master/Distribution/Server/Features/UserSignup.hs): `Distribution/Server/Features/UserSignup.hs`
- [Admin frontend](https://github.com/sapi69/cabal-server/blob/master/Distribution/Server/Features/AdminFrontend.hs): `Distribution/Server/Features/AdminFrontend.hs`

### Mirroring client

- [Mirror client](https://github.com/sapi69/cabal-server/blob/master/Distribution/Client/Mirror/CmdLine.hs): `Distribution/Client/Mirror/CmdLine.hs`
- [Mirror session](https://github.com/sapi69/cabal-server/blob/master/Distribution/Client/Mirror/Session.hs): `Distribution/Client/Mirror/Session.hs`
- [Mirror source adapters](https://github.com/sapi69/cabal-server/tree/master/Distribution/Client/Mirror/Repo): `Distribution/Client/Mirror/Repo`
- [Mirror target adapters](https://github.com/sapi69/cabal-server/tree/master/Distribution/Client/Mirror/Repo): `Distribution/Client/Mirror/Repo`

### Other components

- **Package user**
- **Source server**
- **Target server**

## Connections

- Package user → HTTP server: uses (evidence: `README.md`)
- Package user → Package upload: uploads packages (evidence: `README.md`)
- Package user → User signup: registers (evidence: `README.md`)
- Mirror client → Source server: syncs from (evidence: `README.md`)
- Mirror client → Target server: uploads to (evidence: `README.md`)
- HTTP server → Persistent state: resumes state (evidence: `README.md`)
