# ryll/skordedagbok architecture

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

- Interactive diagram: https://gitdiagram.com/ryll/skordedagbok
- Repository: https://github.com/ryll/skordedagbok

## Overview

Skördedagbok is a public Swedish harvest journal with a shared, administrator-managed record set. Visitors browse dashboard statistics and filtered harvest history; administrators sign in to create or manage harvests, goals, and catalog entries, with server actions persisting changes. Supabase provides the database and cookie-based authentication. The README also documents a separate historical-workbook import and PWA metadata/icon caching. Edges reflect excerpts, the source index, or README statements; unsampled implementations are represented only where documented.

Main entry points: [`app/actions.ts`](https://github.com/ryll/skordedagbok/blob/main/app/actions.ts) (Server actions), [`app/page.tsx`](https://github.com/ryll/skordedagbok/blob/main/app/page.tsx) (Harvest dashboard), [`app/admin/page.tsx`](https://github.com/ryll/skordedagbok/blob/main/app/admin/page.tsx) (Admin pages), [`lib/data.ts`](https://github.com/ryll/skordedagbok/blob/main/lib/data.ts) (Journal data access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public journal"]
  node_dashboard["Harvest dashboard<br/>[page.tsx]"]
  node_dashboard_controls["Dashboard filters and charts"]
  node_goal_card["Goal progress cards<br/>[crop-goal-card.tsx]"]
  node_harvest_history["Harvest history<br/>[page.tsx]"]
  node_harvest_detail["Harvest details<br/>[page.tsx]"]
end

subgraph group_admin["Administration"]
  node_login["Sign-in form<br/>[login-form.tsx]"]
  node_admin_routes["Admin pages<br/>[page.tsx]"]
  node_harvest_form["Harvest editor<br/>[harvest-form.tsx]"]
  node_catalog_manager["Catalog manager"]
  node_goal_manager["Annual goal manager"]
end

subgraph group_backend["Application services"]
  node_dashboard_stats["Dashboard aggregation<br/>[dashboard.ts]"]
  node_actions["Server actions<br/>[actions.ts]"]
  node_validation["Input validation<br/>[validation.ts]"]
  node_data_access["Journal data access<br/>[data.ts]"]
end

subgraph group_platform["Persistence and access"]
  node_supabase_server["Cookie-aware client<br/>[server.ts]"]
  node_database[("Supabase database")]
  node_session_proxy["Session refresh and admin guard<br/>[proxy.ts]"]
end

subgraph group_import["Historical import and PWA"]
  node_importer["Workbook importer<br/>[import-harvests.ts]"]
  node_workbook_parser["Workbook parsing<br/>[workbook.ts]"]
  node_normalizer["Import normalization<br/>[normalize.ts]"]
  node_pwa["PWA registration and cache"]
  node_service_worker["Service worker<br/>[sw.js]"]
end

node_visitor(("Journal visitor"))
node_admin_user(("Administrator"))
node_workbook["Historical workbook"]

node_visitor -->|"views"| node_dashboard
node_dashboard -->|"loads records"| node_data_access
node_dashboard -->|"aggregates"| node_dashboard_stats
node_dashboard -->|"renders filters"| node_dashboard_controls
node_dashboard -->|"renders goals"| node_goal_card
node_visitor -->|"browses"| node_harvest_history
node_harvest_history -->|"loads filtered history"| node_data_access
node_harvest_history -->|"opens record"| node_harvest_detail
node_harvest_detail -->|"loads record"| node_data_access
node_harvest_detail -->|"deletes record"| node_actions
node_admin_user -->|"signs in"| node_login
node_login -->|"submits credentials"| node_actions
node_admin_user -->|"manages journal"| node_admin_routes
node_admin_routes -->|"renders editor"| node_harvest_form
node_admin_routes -->|"renders catalog tools"| node_catalog_manager
node_admin_routes -->|"renders goal editor"| node_goal_manager
node_harvest_form -->|"saves harvest"| node_actions
node_catalog_manager -->|"manages catalogs"| node_actions
node_goal_manager -->|"saves goals"| node_actions
node_actions -->|"validates input"| node_validation
node_actions -->|"creates client"| node_supabase_server
node_data_access -->|"creates client"| node_supabase_server
node_supabase_server -->|"queries and writes"| node_database
node_session_proxy -.->|"refreshes session"| node_database
node_workbook -->|"provides source data"| node_importer
node_importer -->|"parses sheets"| node_workbook_parser
node_workbook_parser -->|"normalizes rows"| node_normalizer
node_importer -->|"applies transactionally"| node_database
node_pwa -->|"registers"| node_service_worker

click node_dashboard "https://github.com/ryll/skordedagbok/blob/main/app/page.tsx"
click node_dashboard_stats "https://github.com/ryll/skordedagbok/blob/main/lib/dashboard.ts"
click node_dashboard_controls "https://github.com/ryll/skordedagbok/blob/main/components/dashboard-period-filters.tsx"
click node_goal_card "https://github.com/ryll/skordedagbok/blob/main/components/crop-goal-card.tsx"
click node_harvest_history "https://github.com/ryll/skordedagbok/blob/main/app/skordar/page.tsx"
click node_harvest_detail "https://github.com/ryll/skordedagbok/blob/main/app/skordar/%5Bid%5D/page.tsx"
click node_login "https://github.com/ryll/skordedagbok/blob/main/components/login-form.tsx"
click node_admin_routes "https://github.com/ryll/skordedagbok/blob/main/app/admin/page.tsx"
click node_harvest_form "https://github.com/ryll/skordedagbok/blob/main/components/harvest-form.tsx"
click node_catalog_manager "https://github.com/ryll/skordedagbok/blob/main/components/catalog-manager.tsx"
click node_goal_manager "https://github.com/ryll/skordedagbok/blob/main/components/crop-goal-manager.tsx"
click node_actions "https://github.com/ryll/skordedagbok/blob/main/app/actions.ts"
click node_validation "https://github.com/ryll/skordedagbok/blob/main/lib/validation.ts"
click node_data_access "https://github.com/ryll/skordedagbok/blob/main/lib/data.ts"
click node_supabase_server "https://github.com/ryll/skordedagbok/blob/main/lib/supabase/server.ts"
click node_session_proxy "https://github.com/ryll/skordedagbok/blob/main/proxy.ts"
click node_importer "https://github.com/ryll/skordedagbok/blob/main/scripts/import-harvests.ts"
click node_workbook_parser "https://github.com/ryll/skordedagbok/blob/main/lib/import/workbook.ts"
click node_normalizer "https://github.com/ryll/skordedagbok/blob/main/lib/import/normalize.ts"
click node_pwa "https://github.com/ryll/skordedagbok/blob/main/components/service-worker-registration.tsx"
click node_service_worker "https://github.com/ryll/skordedagbok/blob/main/public/sw.js"

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_dashboard,node_dashboard_controls,node_goal_card,node_harvest_history,node_harvest_detail toneBlue
class node_login,node_admin_routes,node_harvest_form,node_catalog_manager,node_goal_manager toneAmber
class node_dashboard_stats,node_actions,node_validation,node_data_access toneMint
class node_supabase_server,node_database,node_session_proxy toneRose
class node_importer,node_workbook_parser,node_normalizer,node_pwa,node_service_worker,node_visitor,node_admin_user,node_workbook toneIndigo
```

## Components

### Public journal

- [Harvest dashboard](https://github.com/ryll/skordedagbok/blob/main/app/page.tsx): `app/page.tsx`
- [Dashboard filters and charts](https://github.com/ryll/skordedagbok/blob/main/components/dashboard-period-filters.tsx): `components/dashboard-period-filters.tsx`
- [Goal progress cards](https://github.com/ryll/skordedagbok/blob/main/components/crop-goal-card.tsx): `components/crop-goal-card.tsx`
- [Harvest history](https://github.com/ryll/skordedagbok/blob/main/app/skordar/page.tsx): `app/skordar/page.tsx`
- [Harvest details](https://github.com/ryll/skordedagbok/blob/main/app/skordar/%5Bid%5D/page.tsx): `app/skordar/[id]/page.tsx`

### Administration

- [Sign-in form](https://github.com/ryll/skordedagbok/blob/main/components/login-form.tsx): `components/login-form.tsx`
- [Admin pages](https://github.com/ryll/skordedagbok/blob/main/app/admin/page.tsx): `app/admin/page.tsx`
- [Harvest editor](https://github.com/ryll/skordedagbok/blob/main/components/harvest-form.tsx): `components/harvest-form.tsx`
- [Catalog manager](https://github.com/ryll/skordedagbok/blob/main/components/catalog-manager.tsx): `components/catalog-manager.tsx`
- [Annual goal manager](https://github.com/ryll/skordedagbok/blob/main/components/crop-goal-manager.tsx): `components/crop-goal-manager.tsx`

### Application services

- [Dashboard aggregation](https://github.com/ryll/skordedagbok/blob/main/lib/dashboard.ts): `lib/dashboard.ts`
- [Server actions](https://github.com/ryll/skordedagbok/blob/main/app/actions.ts): `app/actions.ts`
- [Input validation](https://github.com/ryll/skordedagbok/blob/main/lib/validation.ts): `lib/validation.ts`
- [Journal data access](https://github.com/ryll/skordedagbok/blob/main/lib/data.ts): `lib/data.ts`

### Persistence and access

- [Cookie-aware client](https://github.com/ryll/skordedagbok/blob/main/lib/supabase/server.ts): `lib/supabase/server.ts`
- **Supabase database**
- [Session refresh and admin guard](https://github.com/ryll/skordedagbok/blob/main/proxy.ts): `proxy.ts`

### Historical import and PWA

- [Workbook importer](https://github.com/ryll/skordedagbok/blob/main/scripts/import-harvests.ts): `scripts/import-harvests.ts`
- [Workbook parsing](https://github.com/ryll/skordedagbok/blob/main/lib/import/workbook.ts): `lib/import/workbook.ts`
- [Import normalization](https://github.com/ryll/skordedagbok/blob/main/lib/import/normalize.ts): `lib/import/normalize.ts`
- [PWA registration and cache](https://github.com/ryll/skordedagbok/blob/main/components/service-worker-registration.tsx): `components/service-worker-registration.tsx`
- [Service worker](https://github.com/ryll/skordedagbok/blob/main/public/sw.js): `public/sw.js`

### Other components

- **Journal visitor**
- **Administrator**
- **Historical workbook**

## Connections

- Journal visitor → Harvest dashboard: views
- Harvest dashboard → Journal data access: loads records (evidence: `app/page.tsx`)
- Harvest dashboard → Dashboard aggregation: aggregates (evidence: `app/page.tsx`)
- Harvest dashboard → Dashboard filters and charts: renders filters (evidence: `app/page.tsx`)
- Harvest dashboard → Goal progress cards: renders goals (evidence: `app/page.tsx`)
- Journal visitor → Harvest history: browses
- Harvest history → Journal data access: loads filtered history (evidence: `app/skordar/page.tsx`)
- Harvest history → Harvest details: opens record (evidence: `app/skordar/page.tsx`)
- Harvest details → Journal data access: loads record (evidence: `app/skordar/[id]/page.tsx`)
- Harvest details → Server actions: deletes record (evidence: `app/skordar/[id]/page.tsx`)
- Administrator → Sign-in form: signs in
- Sign-in form → Server actions: submits credentials (evidence: `components/login-form.tsx`)
- Administrator → Admin pages: manages journal
- Admin pages → Harvest editor: renders editor
- Admin pages → Catalog manager: renders catalog tools
- Admin pages → Annual goal manager: renders goal editor
- Harvest editor → Server actions: saves harvest (evidence: `components/harvest-form.tsx`)
- Catalog manager → Server actions: manages catalogs (evidence: `components/catalog-manager.tsx`)
- Annual goal manager → Server actions: saves goals (evidence: `components/crop-goal-manager.tsx`)
- Server actions → Input validation: validates input (evidence: `app/actions.ts`)
- Server actions → Cookie-aware client: creates client (evidence: `app/actions.ts`)
- Journal data access → Cookie-aware client: creates client (evidence: `lib/data.ts`)
- Cookie-aware client → Supabase database: queries and writes
- Session refresh and admin guard → Supabase database: refreshes session
- Historical workbook → Workbook importer: provides source data
- Workbook importer → Workbook parsing: parses sheets (evidence: `lib/import/workbook.ts`)
- Workbook parsing → Import normalization: normalizes rows (evidence: `lib/import/workbook.ts`)
- Workbook importer → Supabase database: applies transactionally
- PWA registration and cache → Service worker: registers (evidence: `components/service-worker-registration.tsx`)
