# named666/nostrogotho architecture

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

- Interactive diagram: https://gitdiagram.com/named666/nostrogotho
- Repository: https://github.com/named666/nostrogotho

## Overview

nostrogotho is a C99 Nostr relay: clients send WebSocket protocol messages, the relay validates and applies protocol policy, persists or queries events, then returns protocol responses. The documented NIP modules extend event handling with capabilities such as deletion, authentication, counts, and expiration. Main initializes crypto and SQLite before configuring the server. Source excerpts show the server and storage interfaces, but not all handler wiring; edges for unsampled NIP behavior follow README descriptions and are limited to documented dispatch and capability relationships.

Main entry points: [`src/nips/nip_plugin.c`](https://github.com/named666/nostrogotho/blob/main/src/nips/nip_plugin.c) (Plugin dispatch), [`src/server.c`](https://github.com/named666/nostrogotho/blob/main/src/server.c) (Message dispatch), [`src/nips/nip01.c`](https://github.com/named666/nostrogotho/blob/main/src/nips/nip01.c) (Core event flow), [`src/storage.h`](https://github.com/named666/nostrogotho/blob/main/src/storage.h) (Storage interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and transport"]
  node_main["Process setup<br/>[main.c]"]
  node_server["Relay server<br/>[server.c]"]
  node_wire["WebSocket and HTTP<br/>[server.c]"]
  node_dispatch["Message dispatch<br/>[server.c]"]
  node_responses["Protocol responses<br/>[server.c]"]
end

subgraph group_protocol["Protocol processing"]
  node_nip01["Core event flow<br/>[nip01.c]"]
  node_eventdata["Event and filters<br/>[nostrogotho.c]"]
  node_plugin["Plugin dispatch<br/>[nip_plugin.c]"]
end

subgraph group_extensions["NIP capabilities"]
  node_nip09["Deletion<br/>[nip09.c]"]
  node_nip11["Relay information<br/>[nip11.c]"]
  node_nip13["Proof of work<br/>[nip13.c]"]
  node_nip17["Private messages<br/>[nip17.c]"]
  node_nip26["Delegated signing<br/>[nip26.c]"]
  node_nip40["Event expiration<br/>[nip40.c]"]
  node_nip42["Client authentication<br/>[nip42.c]"]
  node_nip45["Event counts<br/>[nip45.c]"]
  node_nip62["Request to vanish<br/>[nip62.c]"]
  node_nip67["EOSE completeness<br/>[nip67.c]"]
end

subgraph group_persistence["Persistence and crypto"]
  node_crypto["Signature checks<br/>[crypto.c]"]
  node_storage["Storage interface<br/>[storage.h]"]
  node_sqlite[("SQLite event store<br/>[storage.c]")]
  node_sqlite_impl[("SQLite engine<br/>[sqlite3.c]")]
end

node_clients(("Nostr clients"))

node_clients -->|"send messages"| node_wire
node_main -->|"configure and run"| node_server
node_server -->|"runs transport"| node_wire
node_wire -->|"frames messages"| node_dispatch
node_dispatch -->|"dispatches events"| node_nip01
node_dispatch -->|"dispatches messages"| node_plugin
node_nip01 -->|"validates signatures"| node_crypto
node_nip01 -->|"processes events"| node_eventdata
node_nip01 -->|"dispatches handlers"| node_plugin
node_nip01 -->|"stores events"| node_storage
node_dispatch -->|"queries events"| node_storage
node_storage -->|"reads and writes"| node_sqlite
node_sqlite -->|"uses engine"| node_sqlite_impl
node_plugin -->|"dispatches NIP"| node_nip09
node_plugin -->|"dispatches HTTP info"| node_nip11
node_plugin -->|"dispatches NIP"| node_nip13
node_plugin -->|"dispatches NIP"| node_nip17
node_plugin -->|"dispatches NIP"| node_nip26
node_plugin -->|"dispatches NIP"| node_nip40
node_plugin -->|"dispatches NIP"| node_nip42
node_plugin -->|"dispatches NIP"| node_nip45
node_plugin -->|"dispatches NIP"| node_nip62
node_plugin -->|"dispatches NIP"| node_nip67
node_dispatch -->|"sends responses"| node_responses
node_responses -->|"returns messages"| node_clients

click node_main "https://github.com/named666/nostrogotho/blob/main/src/main.c"
click node_server "https://github.com/named666/nostrogotho/blob/main/src/server.c"
click node_wire "https://github.com/named666/nostrogotho/blob/main/src/server.c"
click node_dispatch "https://github.com/named666/nostrogotho/blob/main/src/server.c"
click node_nip01 "https://github.com/named666/nostrogotho/blob/main/src/nips/nip01.c"
click node_eventdata "https://github.com/named666/nostrogotho/blob/main/src/nostrogotho.c"
click node_crypto "https://github.com/named666/nostrogotho/blob/main/src/crypto.c"
click node_plugin "https://github.com/named666/nostrogotho/blob/main/src/nips/nip_plugin.c"
click node_nip09 "https://github.com/named666/nostrogotho/blob/main/src/nips/nip09.c"
click node_nip11 "https://github.com/named666/nostrogotho/blob/main/src/nips/nip11.c"
click node_nip13 "https://github.com/named666/nostrogotho/blob/main/src/nips/nip13.c"
click node_nip17 "https://github.com/named666/nostrogotho/blob/main/src/nips/nip17.c"
click node_nip26 "https://github.com/named666/nostrogotho/blob/main/src/nips/nip26.c"
click node_nip40 "https://github.com/named666/nostrogotho/blob/main/src/nips/nip40.c"
click node_nip42 "https://github.com/named666/nostrogotho/blob/main/src/nips/nip42.c"
click node_nip45 "https://github.com/named666/nostrogotho/blob/main/src/nips/nip45.c"
click node_nip62 "https://github.com/named666/nostrogotho/blob/main/src/nips/nip62.c"
click node_nip67 "https://github.com/named666/nostrogotho/blob/main/src/nips/nip67.c"
click node_storage "https://github.com/named666/nostrogotho/blob/main/src/storage.h"
click node_sqlite "https://github.com/named666/nostrogotho/blob/main/src/storage.c"
click node_sqlite_impl "https://github.com/named666/nostrogotho/blob/main/thirdparty/sqlite3.c"
click node_responses "https://github.com/named666/nostrogotho/blob/main/src/server.c"

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_main,node_server,node_wire,node_dispatch,node_responses,node_clients toneBlue
class node_nip01,node_eventdata,node_plugin toneAmber
class node_nip09,node_nip11,node_nip13,node_nip17,node_nip26,node_nip40,node_nip42,node_nip45,node_nip62,node_nip67 toneMint
class node_crypto,node_storage,node_sqlite,node_sqlite_impl toneRose
```

## Components

### Runtime and transport

- [Process setup](https://github.com/named666/nostrogotho/blob/main/src/main.c): `src/main.c`
- [Relay server](https://github.com/named666/nostrogotho/blob/main/src/server.c): `src/server.c`
- [WebSocket and HTTP](https://github.com/named666/nostrogotho/blob/main/src/server.c): `src/server.c`
- [Message dispatch](https://github.com/named666/nostrogotho/blob/main/src/server.c): `src/server.c`
- [Protocol responses](https://github.com/named666/nostrogotho/blob/main/src/server.c): `src/server.c`

### Protocol processing

- [Core event flow](https://github.com/named666/nostrogotho/blob/main/src/nips/nip01.c): `src/nips/nip01.c`
- [Event and filters](https://github.com/named666/nostrogotho/blob/main/src/nostrogotho.c): `src/nostrogotho.c`
- [Plugin dispatch](https://github.com/named666/nostrogotho/blob/main/src/nips/nip_plugin.c): `src/nips/nip_plugin.c`

### NIP capabilities

- [Deletion](https://github.com/named666/nostrogotho/blob/main/src/nips/nip09.c): `src/nips/nip09.c`
- [Relay information](https://github.com/named666/nostrogotho/blob/main/src/nips/nip11.c): `src/nips/nip11.c`
- [Proof of work](https://github.com/named666/nostrogotho/blob/main/src/nips/nip13.c): `src/nips/nip13.c`
- [Private messages](https://github.com/named666/nostrogotho/blob/main/src/nips/nip17.c): `src/nips/nip17.c`
- [Delegated signing](https://github.com/named666/nostrogotho/blob/main/src/nips/nip26.c): `src/nips/nip26.c`
- [Event expiration](https://github.com/named666/nostrogotho/blob/main/src/nips/nip40.c): `src/nips/nip40.c`
- [Client authentication](https://github.com/named666/nostrogotho/blob/main/src/nips/nip42.c): `src/nips/nip42.c`
- [Event counts](https://github.com/named666/nostrogotho/blob/main/src/nips/nip45.c): `src/nips/nip45.c`
- [Request to vanish](https://github.com/named666/nostrogotho/blob/main/src/nips/nip62.c): `src/nips/nip62.c`
- [EOSE completeness](https://github.com/named666/nostrogotho/blob/main/src/nips/nip67.c): `src/nips/nip67.c`

### Persistence and crypto

- [Signature checks](https://github.com/named666/nostrogotho/blob/main/src/crypto.c): `src/crypto.c`
- [Storage interface](https://github.com/named666/nostrogotho/blob/main/src/storage.h): `src/storage.h`
- [SQLite event store](https://github.com/named666/nostrogotho/blob/main/src/storage.c): `src/storage.c`
- [SQLite engine](https://github.com/named666/nostrogotho/blob/main/thirdparty/sqlite3.c): `thirdparty/sqlite3.c`

### Other components

- **Nostr clients**

## Connections

- Nostr clients → WebSocket and HTTP: send messages
- Process setup → Relay server: configure and run
- Relay server → WebSocket and HTTP: runs transport
- WebSocket and HTTP → Message dispatch: frames messages
- Message dispatch → Core event flow: dispatches events
- Message dispatch → Plugin dispatch: dispatches messages
- Core event flow → Signature checks: validates signatures
- Core event flow → Event and filters: processes events
- Core event flow → Plugin dispatch: dispatches handlers
- Core event flow → Storage interface: stores events
- Message dispatch → Storage interface: queries events
- Storage interface → SQLite event store: reads and writes
- SQLite event store → SQLite engine: uses engine
- Plugin dispatch → Deletion: dispatches NIP
- Plugin dispatch → Relay information: dispatches HTTP info
- Plugin dispatch → Proof of work: dispatches NIP
- Plugin dispatch → Private messages: dispatches NIP
- Plugin dispatch → Delegated signing: dispatches NIP
- Plugin dispatch → Event expiration: dispatches NIP
- Plugin dispatch → Client authentication: dispatches NIP
- Plugin dispatch → Event counts: dispatches NIP
- Plugin dispatch → Request to vanish: dispatches NIP
- Plugin dispatch → EOSE completeness: dispatches NIP
- Message dispatch → Protocol responses: sends responses
- Protocol responses → Nostr clients: returns messages
