# openprx/fenfa architecture

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

- Interactive diagram: https://gitdiagram.com/openprx/fenfa
- Repository: https://github.com/openprx/fenfa

## Overview

Fenfa is a self-hosted, multi-platform app distribution service. An administrator uploads a build, manages products and variants, and publishes releases; end users visit a product page, select a platform build, and download or follow iOS device-registration flows. The Go server routes public and admin requests to handlers backed by SQLite, with optional S3-compatible storage and Apple Developer integration. The graph includes the documented admin capabilities for analytics, events, exports, devices, and settings. Some handler-to-endpoint wiring is unsampled, so uncertain links are omitted or marked unverified.

Main entry points: [`web/admin/src/router.ts`](https://github.com/openprx/fenfa/blob/main/web/admin/src/router.ts) (Admin page routes), [`web/front/src/main.ts`](https://github.com/openprx/fenfa/blob/main/web/front/src/main.ts) (Public product page), [`internal/server/handlers`](https://github.com/openprx/fenfa/tree/main/internal/server/handlers) (HTTP handlers), [`cmd/server/main.go`](https://github.com/openprx/fenfa/blob/main/cmd/server/main.go) (Server startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_server["Go service"]
  node_server_entry["Server startup<br/>[main.go]"]
  node_config["Configuration<br/>[config.go]"]
  node_router["HTTP router<br/>[router.go]"]
  node_auth["Auth middleware<br/>[auth.go]"]
  node_handlers["HTTP handlers"]
  node_database[("SQLite database<br/>[models.go]")]
end

subgraph group_distribution["App distribution"]
  node_public_site["Public product page<br/>[main.ts]"]
  node_upload["Build upload<br/>[upload.go]"]
  node_metadata["Package metadata parsing<br/>[parse_app.go]"]
  node_product_management["Products and releases<br/>[products_admin.go]"]
  node_public_api["Product API<br/>[products_api.go]"]
  node_device_binding["iOS device binding<br/>[udid.go]"]
  node_events["Usage events<br/>[events.go]"]
end

subgraph group_admin["Admin console"]
  node_admin_app["Admin application<br/>[App.vue]"]
  node_admin_routes["Admin page routes<br/>[router.ts]"]
  node_apps_page["Product management UI<br/>[AppsPage.vue]"]
  node_upload_page["Upload UI<br/>[UploadPage.vue]"]
  node_insights_pages["Stats and events UI<br/>[StatsPage.vue]"]
  node_device_page["Device management UI<br/>[UdidPage.vue]"]
  node_settings_page["Settings UI<br/>[SettingsPage.vue]"]
  node_export_page["Export UI<br/>[ExportPage.vue]"]
  node_product_state["Product data cache<br/>[useProducts.ts]"]
end

subgraph group_integrations["External services"]
  node_s3["S3-compatible storage<br/>[client.go]"]
  node_apple_api["Apple Developer API<br/>[client.go]"]
end

node_admin_user(("Administrator"))
node_end_user(("App recipient"))

node_server_entry -->|"loads"| node_config
node_server_entry -->|"opens and migrates"| node_database
node_server_entry -->|"registers routes"| node_router
node_router -->|"uses middleware"| node_auth
node_router -->|"routes requests"| node_handlers
node_end_user -->|"visits"| node_public_site
node_public_site -->|"fetches product"| node_public_api
node_public_site -->|"checks UDID status"| node_device_binding
node_public_site -->|"reports visits"| node_events
node_public_site -->|"downloads releases"| node_handlers
node_admin_user -->|"manages releases"| node_admin_app
node_admin_app -->|"renders pages"| node_admin_routes
node_admin_routes -->|"routes to"| node_apps_page
node_admin_routes -->|"routes to"| node_upload_page
node_admin_routes -->|"routes to"| node_insights_pages
node_admin_routes -->|"routes to"| node_device_page
node_admin_routes -->|"routes to"| node_settings_page
node_admin_routes -->|"routes to"| node_export_page
node_admin_app -->|"loads products"| node_product_state
node_product_state -.->|"requests admin API"| node_handlers
node_apps_page -.->|"manages products"| node_handlers
node_upload_page -.->|"submits builds"| node_upload
node_upload -.->|"extracts metadata"| node_metadata
node_handlers -.->|"reads and writes"| node_database
node_upload -.->|"stores files"| node_s3
node_device_binding -.->|"registers devices"| node_apple_api

click node_server_entry "https://github.com/openprx/fenfa/blob/main/cmd/server/main.go"
click node_config "https://github.com/openprx/fenfa/blob/main/internal/config/config.go"
click node_router "https://github.com/openprx/fenfa/blob/main/internal/server/router.go"
click node_auth "https://github.com/openprx/fenfa/blob/main/internal/server/middleware/auth.go"
click node_handlers "https://github.com/openprx/fenfa/tree/main/internal/server/handlers"
click node_database "https://github.com/openprx/fenfa/blob/main/internal/store/models.go"
click node_public_site "https://github.com/openprx/fenfa/blob/main/web/front/src/main.ts"
click node_upload "https://github.com/openprx/fenfa/blob/main/internal/server/handlers/upload.go"
click node_metadata "https://github.com/openprx/fenfa/blob/main/internal/server/handlers/parse_app.go"
click node_product_management "https://github.com/openprx/fenfa/blob/main/internal/server/handlers/products_admin.go"
click node_public_api "https://github.com/openprx/fenfa/blob/main/internal/server/handlers/products_api.go"
click node_device_binding "https://github.com/openprx/fenfa/blob/main/internal/server/handlers/udid.go"
click node_events "https://github.com/openprx/fenfa/blob/main/internal/server/handlers/events.go"
click node_admin_app "https://github.com/openprx/fenfa/blob/main/web/admin/src/App.vue"
click node_admin_routes "https://github.com/openprx/fenfa/blob/main/web/admin/src/router.ts"
click node_apps_page "https://github.com/openprx/fenfa/blob/main/web/admin/src/pages/AppsPage.vue"
click node_upload_page "https://github.com/openprx/fenfa/blob/main/web/admin/src/pages/UploadPage.vue"
click node_insights_pages "https://github.com/openprx/fenfa/blob/main/web/admin/src/pages/StatsPage.vue"
click node_device_page "https://github.com/openprx/fenfa/blob/main/web/admin/src/pages/UdidPage.vue"
click node_settings_page "https://github.com/openprx/fenfa/blob/main/web/admin/src/pages/SettingsPage.vue"
click node_export_page "https://github.com/openprx/fenfa/blob/main/web/admin/src/pages/ExportPage.vue"
click node_product_state "https://github.com/openprx/fenfa/blob/main/web/admin/src/composables/useProducts.ts"
click node_s3 "https://github.com/openprx/fenfa/blob/main/internal/s3/client.go"
click node_apple_api "https://github.com/openprx/fenfa/blob/main/internal/apple/client.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_entry,node_config,node_router,node_auth,node_handlers,node_database toneBlue
class node_public_site,node_upload,node_metadata,node_product_management,node_public_api,node_device_binding,node_events toneAmber
class node_admin_app,node_admin_routes,node_apps_page,node_upload_page,node_insights_pages,node_device_page,node_settings_page,node_export_page,node_product_state toneMint
class node_s3,node_apple_api toneRose
class node_admin_user,node_end_user toneIndigo
```

## Components

### Go service

- [Server startup](https://github.com/openprx/fenfa/blob/main/cmd/server/main.go): `cmd/server/main.go`
- [Configuration](https://github.com/openprx/fenfa/blob/main/internal/config/config.go): `internal/config/config.go`
- [HTTP router](https://github.com/openprx/fenfa/blob/main/internal/server/router.go): `internal/server/router.go`
- [Auth middleware](https://github.com/openprx/fenfa/blob/main/internal/server/middleware/auth.go): `internal/server/middleware/auth.go`
- [HTTP handlers](https://github.com/openprx/fenfa/tree/main/internal/server/handlers): `internal/server/handlers`
- [SQLite database](https://github.com/openprx/fenfa/blob/main/internal/store/models.go): `internal/store/models.go`

### App distribution

- [Public product page](https://github.com/openprx/fenfa/blob/main/web/front/src/main.ts): `web/front/src/main.ts`
- [Build upload](https://github.com/openprx/fenfa/blob/main/internal/server/handlers/upload.go): `internal/server/handlers/upload.go`
- [Package metadata parsing](https://github.com/openprx/fenfa/blob/main/internal/server/handlers/parse_app.go): `internal/server/handlers/parse_app.go`
- [Products and releases](https://github.com/openprx/fenfa/blob/main/internal/server/handlers/products_admin.go): `internal/server/handlers/products_admin.go`
- [Product API](https://github.com/openprx/fenfa/blob/main/internal/server/handlers/products_api.go): `internal/server/handlers/products_api.go`
- [iOS device binding](https://github.com/openprx/fenfa/blob/main/internal/server/handlers/udid.go): `internal/server/handlers/udid.go`
- [Usage events](https://github.com/openprx/fenfa/blob/main/internal/server/handlers/events.go): `internal/server/handlers/events.go`

### Admin console

- [Admin application](https://github.com/openprx/fenfa/blob/main/web/admin/src/App.vue): `web/admin/src/App.vue`
- [Admin page routes](https://github.com/openprx/fenfa/blob/main/web/admin/src/router.ts): `web/admin/src/router.ts`
- [Product management UI](https://github.com/openprx/fenfa/blob/main/web/admin/src/pages/AppsPage.vue): `web/admin/src/pages/AppsPage.vue`
- [Upload UI](https://github.com/openprx/fenfa/blob/main/web/admin/src/pages/UploadPage.vue): `web/admin/src/pages/UploadPage.vue`
- [Stats and events UI](https://github.com/openprx/fenfa/blob/main/web/admin/src/pages/StatsPage.vue): `web/admin/src/pages/StatsPage.vue`
- [Device management UI](https://github.com/openprx/fenfa/blob/main/web/admin/src/pages/UdidPage.vue): `web/admin/src/pages/UdidPage.vue`
- [Settings UI](https://github.com/openprx/fenfa/blob/main/web/admin/src/pages/SettingsPage.vue): `web/admin/src/pages/SettingsPage.vue`
- [Export UI](https://github.com/openprx/fenfa/blob/main/web/admin/src/pages/ExportPage.vue): `web/admin/src/pages/ExportPage.vue`
- [Product data cache](https://github.com/openprx/fenfa/blob/main/web/admin/src/composables/useProducts.ts): `web/admin/src/composables/useProducts.ts`

### External services

- [S3-compatible storage](https://github.com/openprx/fenfa/blob/main/internal/s3/client.go): `internal/s3/client.go`
- [Apple Developer API](https://github.com/openprx/fenfa/blob/main/internal/apple/client.go): `internal/apple/client.go`

### Other components

- **Administrator**
- **App recipient**

## Connections

- Server startup → Configuration: loads (evidence: `cmd/server/main.go`)
- Server startup → SQLite database: opens and migrates (evidence: `cmd/server/main.go`)
- Server startup → HTTP router: registers routes (evidence: `cmd/server/main.go`)
- HTTP router → Auth middleware: uses middleware (evidence: `internal/server/router.go`)
- HTTP router → HTTP handlers: routes requests (evidence: `internal/server/router.go`)
- App recipient → Public product page: visits (evidence: `README.md`)
- Public product page → Product API: fetches product (evidence: `web/front/src/main.ts`)
- Public product page → iOS device binding: checks UDID status (evidence: `web/front/src/main.ts`)
- Public product page → Usage events: reports visits (evidence: `web/front/src/main.ts`)
- Public product page → HTTP handlers: downloads releases (evidence: `README.md`)
- Administrator → Admin application: manages releases (evidence: `README.md`)
- Admin application → Admin page routes: renders pages (evidence: `web/admin/src/App.vue`)
- Admin page routes → Product management UI: routes to (evidence: `web/admin/src/router.ts`)
- Admin page routes → Upload UI: routes to (evidence: `web/admin/src/router.ts`)
- Admin page routes → Stats and events UI: routes to (evidence: `web/admin/src/router.ts`)
- Admin page routes → Device management UI: routes to (evidence: `web/admin/src/router.ts`)
- Admin page routes → Settings UI: routes to (evidence: `web/admin/src/router.ts`)
- Admin page routes → Export UI: routes to (evidence: `web/admin/src/router.ts`)
- Admin application → Product data cache: loads products (evidence: `web/admin/src/App.vue`)
- Product data cache → HTTP handlers: requests admin API
- Product management UI → HTTP handlers: manages products
- Upload UI → Build upload: submits builds
- Build upload → Package metadata parsing: extracts metadata
- HTTP handlers → SQLite database: reads and writes
- Build upload → S3-compatible storage: stores files
- iOS device binding → Apple Developer API: registers devices
