# pratikshakalbhor/devconv-ps2-swarm-birding-records architecture

> Architecture diagram of the GitHub repository pratikshakalbhor/devconv-ps2-swarm-birding-records, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pratikshakalbhor/devconv-ps2-swarm-birding-records
- Repository: https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records

## Overview

Birding Sightings is a pair of independent React apps demonstrating portable, content-addressed bird records on Swarm: a signed-in writer stores a schema-versioned JSON blob, and a public reader fetches it by reference and renders it. The main paths and major documented capabilities are represented below. The writer App excerpt is partial, so its record-construction details are not expanded; the README documents the gateway and network behavior.

Main entry points: [`apps/writer/src/App.tsx`](https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/apps/writer/src/App.tsx) (Sightings form), [`apps/reader/src/App.tsx`](https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/apps/reader/src/App.tsx) (Reference reader), [`apps/reader/src/read.ts`](https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/apps/reader/src/read.ts) (Fetch and validate), [`apps/writer/src/upload.ts`](https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/apps/writer/src/upload.ts) (Gated upload)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_writer["Writer app"]
  node_writer_ui["Sightings form<br/>[App.tsx]"]
  node_writer_config["Writer config<br/>[config.ts]"]
  node_identity["Identity lifecycle<br/>[useSwarmId.ts]"]
  node_writer_errors["Upload failures<br/>[errors.ts]"]
  node_upload["Gated upload<br/>[upload.ts]"]
end

subgraph group_reader["Reader app"]
  node_reader_ui["Reference reader<br/>[App.tsx]"]
  node_reader_config["Reader config<br/>[config.ts]"]
  node_read["Fetch and validate<br/>[read.ts]"]
  node_reader_errors["Read failures<br/>[errors.ts]"]
  node_record_card["Record display<br/>[RecordCard.tsx]"]
end

subgraph group_contract["Record contract"]
  node_format["Record format<br/>[format.ts]"]
end

subgraph group_swarm["Swarm services"]
  node_swarm_id["Swarm ID"]
  node_gateway["Subsidised gateway"]
  node_network[("Swarm network")]
end

node_observer(("Birding observer"))
node_reader_user(("Record reader"))

node_observer -->|"logs sighting"| node_writer_ui
node_writer_ui -->|"loads config"| node_writer_config
node_writer_ui -->|"uses identity"| node_identity
node_identity -->|"initializes client"| node_swarm_id
node_writer_ui -->|"uploads record"| node_upload
node_upload -->|"serializes record"| node_format
node_upload -->|"posts bytes"| node_gateway
node_gateway -->|"stores bytes"| node_network
node_writer_ui -->|"classifies failures"| node_writer_errors
node_upload -->|"classifies failures"| node_writer_errors
node_reader_user -->|"opens reference"| node_reader_ui
node_reader_ui -->|"loads config"| node_reader_config
node_reader_ui -->|"reads reference"| node_read
node_read -->|"uses gateway config"| node_reader_config
node_read -->|"fetches bytes"| node_gateway
node_gateway -->|"serves bytes"| node_network
node_read -->|"deserializes record"| node_format
node_reader_ui -->|"renders record"| node_record_card
node_reader_ui -->|"classifies failures"| node_reader_errors
node_read -->|"classifies failures"| node_reader_errors

click node_writer_ui "https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/apps/writer/src/App.tsx"
click node_writer_config "https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/apps/writer/src/config.ts"
click node_identity "https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/apps/writer/src/useSwarmId.ts"
click node_writer_errors "https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/apps/writer/src/errors.ts"
click node_upload "https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/apps/writer/src/upload.ts"
click node_reader_ui "https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/apps/reader/src/App.tsx"
click node_reader_config "https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/apps/reader/src/config.ts"
click node_read "https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/apps/reader/src/read.ts"
click node_reader_errors "https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/apps/reader/src/errors.ts"
click node_record_card "https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/apps/reader/src/RecordCard.tsx"
click node_format "https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/shared/format.ts"

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_writer_ui,node_writer_config,node_identity,node_writer_errors,node_upload toneBlue
class node_reader_ui,node_reader_config,node_read,node_reader_errors,node_record_card toneAmber
class node_format,node_observer toneMint
class node_swarm_id,node_gateway,node_network toneRose
class node_reader_user toneIndigo
```

## Components

### Writer app

- [Sightings form](https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/apps/writer/src/App.tsx): `apps/writer/src/App.tsx`
- [Writer config](https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/apps/writer/src/config.ts): `apps/writer/src/config.ts`
- [Identity lifecycle](https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/apps/writer/src/useSwarmId.ts): `apps/writer/src/useSwarmId.ts`
- [Upload failures](https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/apps/writer/src/errors.ts): `apps/writer/src/errors.ts`
- [Gated upload](https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/apps/writer/src/upload.ts): `apps/writer/src/upload.ts`

### Reader app

- [Reference reader](https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/apps/reader/src/App.tsx): `apps/reader/src/App.tsx`
- [Reader config](https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/apps/reader/src/config.ts): `apps/reader/src/config.ts`
- [Fetch and validate](https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/apps/reader/src/read.ts): `apps/reader/src/read.ts`
- [Read failures](https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/apps/reader/src/errors.ts): `apps/reader/src/errors.ts`
- [Record display](https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/apps/reader/src/RecordCard.tsx): `apps/reader/src/RecordCard.tsx`

### Record contract

- [Record format](https://github.com/pratikshakalbhor/devconv-ps2-swarm-birding-records/blob/main/shared/format.ts): `shared/format.ts`

### Swarm services

- **Swarm ID**
- **Subsidised gateway**
- **Swarm network**

### Other components

- **Birding observer**
- **Record reader**

## Connections

- Birding observer → Sightings form: logs sighting (evidence: `README.md`)
- Sightings form → Writer config: loads config (evidence: `apps/writer/src/App.tsx`)
- Sightings form → Identity lifecycle: uses identity (evidence: `apps/writer/src/App.tsx`)
- Identity lifecycle → Swarm ID: initializes client (evidence: `apps/writer/src/useSwarmId.ts`)
- Sightings form → Gated upload: uploads record (evidence: `apps/writer/src/App.tsx`)
- Gated upload → Record format: serializes record (evidence: `apps/writer/src/upload.ts`)
- Gated upload → Subsidised gateway: posts bytes (evidence: `README.md`)
- Subsidised gateway → Swarm network: stores bytes (evidence: `README.md`)
- Sightings form → Upload failures: classifies failures (evidence: `apps/writer/src/App.tsx`)
- Gated upload → Upload failures: classifies failures (evidence: `apps/writer/src/upload.ts`)
- Record reader → Reference reader: opens reference (evidence: `README.md`)
- Reference reader → Reader config: loads config (evidence: `apps/reader/src/App.tsx`)
- Reference reader → Fetch and validate: reads reference (evidence: `apps/reader/src/App.tsx`)
- Fetch and validate → Reader config: uses gateway config (evidence: `apps/reader/src/read.ts`)
- Fetch and validate → Subsidised gateway: fetches bytes (evidence: `README.md`)
- Subsidised gateway → Swarm network: serves bytes (evidence: `README.md`)
- Fetch and validate → Record format: deserializes record (evidence: `apps/reader/src/read.ts`)
- Reference reader → Record display: renders record (evidence: `apps/reader/src/App.tsx`)
- Reference reader → Read failures: classifies failures (evidence: `apps/reader/src/App.tsx`)
- Fetch and validate → Read failures: classifies failures (evidence: `apps/reader/src/read.ts`)
