# nxrmqlly/arcfile architecture

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

- Interactive diagram: https://gitdiagram.com/nxrmqlly/arcfile
- Repository: https://github.com/nxrmqlly/arcfile

## Overview

Arcfile is a temporary file-sharing service: users upload a file with an email address, receive an identifier, and can look up or download the file before it expires. Downloads and scheduled expiry cleanup remove stored files and metadata. The graph follows the shown route registration and handler calls; database initialization and rate-limit setup are visible at startup, but their internal implementations are not sampled.

Main entry points: [`cmd/api/main.go`](https://github.com/nxrmqlly/arcfile/blob/master/cmd/api/main.go) (HTTP server and routes), [`handlers/upload.go`](https://github.com/nxrmqlly/arcfile/blob/master/handlers/upload.go) (Upload handler), [`handlers/download.go`](https://github.com/nxrmqlly/arcfile/blob/master/handlers/download.go) (Download handler), [`storage/get.go`](https://github.com/nxrmqlly/arcfile/blob/master/storage/get.go) (Look up metadata)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_webapp["Upload and download UI<br/>[app.js]"]
  node_assets["Static pages<br/>[public.go]"]
end

subgraph group_api["HTTP API"]
  node_server["HTTP server and routes<br/>[main.go]"]
  node_upload["Upload handler<br/>[upload.go]"]
  node_info["File info handler<br/>[info.go]"]
  node_download["Download handler<br/>[download.go]"]
  node_handlerrepo["Handler repository binding<br/>[types.go]"]
end

subgraph group_storage["File lifecycle"]
  node_model["File metadata model<br/>[file.go]"]
  node_create["Create metadata<br/>[create.go]"]
  node_lookup["Look up metadata<br/>[get.go]"]
  node_cleanup["Expiry cleanup<br/>[cleanup.go]"]
  node_repository["Repository and database setup<br/>[repository.go]"]
  node_disk["Uploaded file storage"]
end

subgraph group_platform["Runtime services"]
  node_database[("PostgreSQL")]
  node_limits["Rate limit setup<br/>[ratelimits.go]"]
end

node_user(("User"))

node_user -->|"uses"| node_webapp
node_webapp -->|"sends upload and download requests"| node_server
node_server -->|"serves pages"| node_assets
node_server -->|"routes uploads"| node_upload
node_server -->|"routes file lookups"| node_info
node_server -->|"routes downloads"| node_download
node_server -->|"configures route limits"| node_limits
node_server -->|"initializes database and repository"| node_repository
node_server -->|"starts expiry routine"| node_cleanup
node_upload -.->|"uses repository binding"| node_handlerrepo
node_info -->|"fetches metadata"| node_lookup
node_download -->|"fetches metadata"| node_lookup
node_upload -->|"creates metadata"| node_create
node_upload -->|"saves uploaded file"| node_disk
node_create -->|"stores file metadata"| node_model
node_lookup -->|"returns file metadata"| node_model
node_create -->|"inserts metadata"| node_database
node_lookup -->|"queries metadata"| node_database
node_download -->|"serves then deletes file"| node_disk
node_download -->|"deletes metadata"| node_cleanup
node_cleanup -->|"queries and deletes expired metadata"| node_database
node_cleanup -->|"removes expired files"| node_disk
node_repository -->|"holds database pool"| node_database

click node_webapp "https://github.com/nxrmqlly/arcfile/blob/master/public/js/app.js"
click node_assets "https://github.com/nxrmqlly/arcfile/blob/master/public/public.go"
click node_server "https://github.com/nxrmqlly/arcfile/blob/master/cmd/api/main.go"
click node_upload "https://github.com/nxrmqlly/arcfile/blob/master/handlers/upload.go"
click node_info "https://github.com/nxrmqlly/arcfile/blob/master/handlers/info.go"
click node_download "https://github.com/nxrmqlly/arcfile/blob/master/handlers/download.go"
click node_handlerrepo "https://github.com/nxrmqlly/arcfile/blob/master/handlers/types.go"
click node_model "https://github.com/nxrmqlly/arcfile/blob/master/structures/file.go"
click node_create "https://github.com/nxrmqlly/arcfile/blob/master/storage/create.go"
click node_lookup "https://github.com/nxrmqlly/arcfile/blob/master/storage/get.go"
click node_cleanup "https://github.com/nxrmqlly/arcfile/blob/master/storage/cleanup.go"
click node_repository "https://github.com/nxrmqlly/arcfile/blob/master/storage/repository.go"
click node_limits "https://github.com/nxrmqlly/arcfile/blob/master/ratelimits/ratelimits.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_webapp,node_assets,node_user toneBlue
class node_server,node_upload,node_info,node_download,node_handlerrepo toneAmber
class node_model,node_create,node_lookup,node_cleanup,node_repository,node_disk toneMint
class node_database,node_limits toneRose
```

## Components

### Web interface

- [Upload and download UI](https://github.com/nxrmqlly/arcfile/blob/master/public/js/app.js): `public/js/app.js`
- [Static pages](https://github.com/nxrmqlly/arcfile/blob/master/public/public.go): `public/public.go`

### HTTP API

- [HTTP server and routes](https://github.com/nxrmqlly/arcfile/blob/master/cmd/api/main.go): `cmd/api/main.go`
- [Upload handler](https://github.com/nxrmqlly/arcfile/blob/master/handlers/upload.go): `handlers/upload.go`
- [File info handler](https://github.com/nxrmqlly/arcfile/blob/master/handlers/info.go): `handlers/info.go`
- [Download handler](https://github.com/nxrmqlly/arcfile/blob/master/handlers/download.go): `handlers/download.go`
- [Handler repository binding](https://github.com/nxrmqlly/arcfile/blob/master/handlers/types.go): `handlers/types.go`

### File lifecycle

- [File metadata model](https://github.com/nxrmqlly/arcfile/blob/master/structures/file.go): `structures/file.go`
- [Create metadata](https://github.com/nxrmqlly/arcfile/blob/master/storage/create.go): `storage/create.go`
- [Look up metadata](https://github.com/nxrmqlly/arcfile/blob/master/storage/get.go): `storage/get.go`
- [Expiry cleanup](https://github.com/nxrmqlly/arcfile/blob/master/storage/cleanup.go): `storage/cleanup.go`
- [Repository and database setup](https://github.com/nxrmqlly/arcfile/blob/master/storage/repository.go): `storage/repository.go`
- **Uploaded file storage**

### Runtime services

- **PostgreSQL**
- [Rate limit setup](https://github.com/nxrmqlly/arcfile/blob/master/ratelimits/ratelimits.go): `ratelimits/ratelimits.go`

### Other components

- **User**

## Connections

- User → Upload and download UI: uses (evidence: `public/js/app.js`)
- Upload and download UI → HTTP server and routes: sends upload and download requests (evidence: `public/js/app.js`)
- HTTP server and routes → Static pages: serves pages (evidence: `cmd/api/main.go`)
- HTTP server and routes → Upload handler: routes uploads (evidence: `cmd/api/main.go`)
- HTTP server and routes → File info handler: routes file lookups (evidence: `cmd/api/main.go`)
- HTTP server and routes → Download handler: routes downloads (evidence: `cmd/api/main.go`)
- HTTP server and routes → Rate limit setup: configures route limits (evidence: `cmd/api/main.go`)
- HTTP server and routes → Repository and database setup: initializes database and repository (evidence: `cmd/api/main.go`)
- HTTP server and routes → Expiry cleanup: starts expiry routine (evidence: `cmd/api/main.go`)
- Upload handler → Handler repository binding: uses repository binding
- File info handler → Look up metadata: fetches metadata (evidence: `handlers/info.go`)
- Download handler → Look up metadata: fetches metadata (evidence: `handlers/download.go`)
- Upload handler → Create metadata: creates metadata (evidence: `handlers/upload.go`)
- Upload handler → Uploaded file storage: saves uploaded file (evidence: `handlers/upload.go`)
- Create metadata → File metadata model: stores file metadata (evidence: `storage/create.go`)
- Look up metadata → File metadata model: returns file metadata (evidence: `storage/get.go`)
- Create metadata → PostgreSQL: inserts metadata (evidence: `storage/create.go`)
- Look up metadata → PostgreSQL: queries metadata (evidence: `storage/get.go`)
- Download handler → Uploaded file storage: serves then deletes file (evidence: `handlers/download.go`)
- Download handler → Expiry cleanup: deletes metadata (evidence: `handlers/download.go`)
- Expiry cleanup → PostgreSQL: queries and deletes expired metadata (evidence: `storage/cleanup.go`)
- Expiry cleanup → Uploaded file storage: removes expired files (evidence: `storage/cleanup.go`)
- Repository and database setup → PostgreSQL: holds database pool (evidence: `storage/repository.go`)
