# forceu/gokapi architecture

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

- Interactive diagram: https://gitdiagram.com/forceu/gokapi
- Repository: https://github.com/forceu/gokapi

## Overview

Gokapi is a self-hosted file-sharing service. Its principal workflow accepts uploads through the web/API surface, stores file content and metadata, and serves expiring shares for download; administrators configure the service and manage users and shares. The repository also documents file requests, deduplication, encryption, REST automation, S3-compatible storage, OIDC, and UI customization. The sampled excerpts do not show the full server routing or upload implementation, so uncertain internal call links are omitted; documented capabilities are represented without claiming their detailed wiring.

Main entry points: [`internal/webserver/Webserver.go`](https://github.com/forceu/gokapi/blob/master/internal/webserver/Webserver.go) (HTTP server), [`internal/configuration/database/Database.go`](https://github.com/forceu/gokapi/blob/master/internal/configuration/database/Database.go) (Database access), [`internal/webserver/fileupload/FileUpload.go`](https://github.com/forceu/gokapi/blob/master/internal/webserver/fileupload/FileUpload.go) (Upload handling), [`internal/webserver/api/Api.go`](https://github.com/forceu/gokapi/blob/master/internal/webserver/api/Api.go) (REST API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_service["Service entry"]
  node_main["Gokapi startup<br/>[Main.go]"]
end

subgraph group_access["Web and access"]
  node_webserver["HTTP server<br/>[Webserver.go]"]
  node_api["REST API<br/>[Api.go]"]
  node_auth["Authentication<br/>[Authentication.go]"]
  node_sessions["Session management<br/>[SessionManager.go]"]
  node_adminui["Web interface"]
end

subgraph group_sharing["File sharing"]
  node_upload["Upload handling<br/>[FileUpload.go]"]
  node_requests["File requests<br/>[Filerequest.go]"]
  node_encryption["Encryption<br/>[Encryption.go]"]
  node_e2e["End-to-end encryption<br/>[End2End.go]"]
  node_serving["File serving<br/>[FileServing.go]"]
end

subgraph group_persistence["Persistence"]
  node_filesystem["Storage selection<br/>[FileSystem.go]"]
  node_local["Local storage<br/>[Localstorage.go]"]
  node_s3storage["S3 storage<br/>[S3filesystem.go]"]
  node_database["Database access<br/>[Database.go]"]
  node_dbproviders["SQLite or Redis<br/>[DbAbstraction.go]"]
end

subgraph group_setup["Configuration"]
  node_config["Runtime configuration<br/>[Configuration.go]"]
  node_setupwizard["Setup wizard<br/>[Setup.go]"]
end

node_browser(("Browser user"))
node_apiuser(("API or CLI client"))
node_idp(("OIDC provider"))
node_s3[("S3-compatible store")]

node_browser -->|"uses HTTP"| node_webserver
node_apiuser -->|"calls REST"| node_api
node_browser -->|"uses interface"| node_adminui
node_adminui -->|"requests pages"| node_webserver
node_main -->|"loads settings"| node_config
node_main -->|"connects database"| node_database
node_main -->|"starts server"| node_webserver
node_webserver -->|"serves API"| node_api
node_webserver -->|"authenticates requests"| node_auth
node_auth -->|"validates sessions"| node_sessions
node_sessions -->|"reads and writes sessions"| node_database
node_api -->|"dispatches uploads"| node_upload
node_api -->|"dispatches downloads"| node_serving
node_upload -->|"encrypts content"| node_encryption
node_upload -->|"stores content"| node_filesystem
node_upload -->|"stores metadata"| node_database
node_requests -->|"stores request state"| node_database
node_serving -->|"reads content"| node_filesystem
node_serving -->|"reads share metadata"| node_database
node_filesystem -->|"selects local driver"| node_local
node_filesystem -.->|"selects cloud driver"| node_s3storage
node_s3storage -.->|"stores objects"| node_s3
node_database -->|"uses database abstraction"| node_dbproviders
node_dbproviders -.-> node_local
node_browser -->|"configures service"| node_setupwizard
node_webserver -->|"supports file requests"| node_requests
node_browser -->|"encrypts or decrypts"| node_e2e
node_idp -.->|"provides identity"| node_auth

click node_main "https://github.com/forceu/gokapi/blob/master/cmd/gokapi/Main.go"
click node_webserver "https://github.com/forceu/gokapi/blob/master/internal/webserver/Webserver.go"
click node_api "https://github.com/forceu/gokapi/blob/master/internal/webserver/api/Api.go"
click node_auth "https://github.com/forceu/gokapi/blob/master/internal/webserver/authentication/Authentication.go"
click node_sessions "https://github.com/forceu/gokapi/blob/master/internal/webserver/authentication/sessionmanager/SessionManager.go"
click node_adminui "https://github.com/forceu/gokapi/blob/master/internal/webserver/web/static/js/admin_ui_allPages.js"
click node_upload "https://github.com/forceu/gokapi/blob/master/internal/webserver/fileupload/FileUpload.go"
click node_requests "https://github.com/forceu/gokapi/blob/master/internal/storage/filerequest/Filerequest.go"
click node_encryption "https://github.com/forceu/gokapi/blob/master/internal/encryption/Encryption.go"
click node_e2e "https://github.com/forceu/gokapi/blob/master/internal/encryption/end2end/End2End.go"
click node_serving "https://github.com/forceu/gokapi/blob/master/internal/storage/FileServing.go"
click node_filesystem "https://github.com/forceu/gokapi/blob/master/internal/storage/filesystem/FileSystem.go"
click node_local "https://github.com/forceu/gokapi/blob/master/internal/storage/filesystem/localstorage/Localstorage.go"
click node_s3storage "https://github.com/forceu/gokapi/blob/master/internal/storage/filesystem/s3filesystem/S3filesystem.go"
click node_database "https://github.com/forceu/gokapi/blob/master/internal/configuration/database/Database.go"
click node_dbproviders "https://github.com/forceu/gokapi/blob/master/internal/configuration/database/dbabstraction/DbAbstraction.go"
click node_config "https://github.com/forceu/gokapi/blob/master/internal/configuration/Configuration.go"
click node_setupwizard "https://github.com/forceu/gokapi/blob/master/internal/configuration/setup/Setup.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_main,node_browser,node_apiuser toneBlue
class node_webserver,node_api,node_auth,node_sessions,node_adminui,node_s3 toneAmber
class node_upload,node_requests,node_encryption,node_e2e,node_serving toneMint
class node_filesystem,node_local,node_s3storage,node_database,node_dbproviders toneRose
class node_config,node_setupwizard,node_idp toneIndigo
```

## Components

### Service entry

- [Gokapi startup](https://github.com/forceu/gokapi/blob/master/cmd/gokapi/Main.go): `cmd/gokapi/Main.go`

### Web and access

- [HTTP server](https://github.com/forceu/gokapi/blob/master/internal/webserver/Webserver.go): `internal/webserver/Webserver.go`
- [REST API](https://github.com/forceu/gokapi/blob/master/internal/webserver/api/Api.go): `internal/webserver/api/Api.go`
- [Authentication](https://github.com/forceu/gokapi/blob/master/internal/webserver/authentication/Authentication.go): `internal/webserver/authentication/Authentication.go`
- [Session management](https://github.com/forceu/gokapi/blob/master/internal/webserver/authentication/sessionmanager/SessionManager.go): `internal/webserver/authentication/sessionmanager/SessionManager.go`
- [Web interface](https://github.com/forceu/gokapi/blob/master/internal/webserver/web/static/js/admin_ui_allPages.js): `internal/webserver/web/static/js/admin_ui_allPages.js`

### File sharing

- [Upload handling](https://github.com/forceu/gokapi/blob/master/internal/webserver/fileupload/FileUpload.go): `internal/webserver/fileupload/FileUpload.go`
- [File requests](https://github.com/forceu/gokapi/blob/master/internal/storage/filerequest/Filerequest.go): `internal/storage/filerequest/Filerequest.go`
- [Encryption](https://github.com/forceu/gokapi/blob/master/internal/encryption/Encryption.go): `internal/encryption/Encryption.go`
- [End-to-end encryption](https://github.com/forceu/gokapi/blob/master/internal/encryption/end2end/End2End.go): `internal/encryption/end2end/End2End.go`
- [File serving](https://github.com/forceu/gokapi/blob/master/internal/storage/FileServing.go): `internal/storage/FileServing.go`

### Persistence

- [Storage selection](https://github.com/forceu/gokapi/blob/master/internal/storage/filesystem/FileSystem.go): `internal/storage/filesystem/FileSystem.go`
- [Local storage](https://github.com/forceu/gokapi/blob/master/internal/storage/filesystem/localstorage/Localstorage.go): `internal/storage/filesystem/localstorage/Localstorage.go`
- [S3 storage](https://github.com/forceu/gokapi/blob/master/internal/storage/filesystem/s3filesystem/S3filesystem.go): `internal/storage/filesystem/s3filesystem/S3filesystem.go`
- [Database access](https://github.com/forceu/gokapi/blob/master/internal/configuration/database/Database.go): `internal/configuration/database/Database.go`
- [SQLite or Redis](https://github.com/forceu/gokapi/blob/master/internal/configuration/database/dbabstraction/DbAbstraction.go): `internal/configuration/database/dbabstraction/DbAbstraction.go`

### Configuration

- [Runtime configuration](https://github.com/forceu/gokapi/blob/master/internal/configuration/Configuration.go): `internal/configuration/Configuration.go`
- [Setup wizard](https://github.com/forceu/gokapi/blob/master/internal/configuration/setup/Setup.go): `internal/configuration/setup/Setup.go`

### Other components

- **Browser user**
- **API or CLI client**
- **OIDC provider**
- **S3-compatible store**

## Connections

- Browser user → HTTP server: uses HTTP
- API or CLI client → REST API: calls REST
- Browser user → Web interface: uses interface
- Web interface → HTTP server: requests pages
- Gokapi startup → Runtime configuration: loads settings
- Gokapi startup → Database access: connects database
- Gokapi startup → HTTP server: starts server
- HTTP server → REST API: serves API
- HTTP server → Authentication: authenticates requests
- Authentication → Session management: validates sessions
- Session management → Database access: reads and writes sessions
- REST API → Upload handling: dispatches uploads
- REST API → File serving: dispatches downloads
- Upload handling → Encryption: encrypts content
- Upload handling → Storage selection: stores content
- Upload handling → Database access: stores metadata
- File requests → Database access: stores request state
- File serving → Storage selection: reads content
- File serving → Database access: reads share metadata
- Storage selection → Local storage: selects local driver
- Storage selection → S3 storage: selects cloud driver
- S3 storage → S3-compatible store: stores objects
- Database access → SQLite or Redis: uses database abstraction
- SQLite or Redis → Local storage
- Browser user → Setup wizard: configures service
- HTTP server → File requests: supports file requests
- Browser user → End-to-end encryption: encrypts or decrypts
- OIDC provider → Authentication: provides identity
