title: Database Schema Documentation description: Technical documentation of Charon's SQLite database schema. Entity relationships and table definitions for developers.

Database Schema Documentation

Charon uses SQLite with GORM ORM for data persistence. This document describes the database schema and relationships.

Overview

The database consists of 8 main tables:

Entity Relationship Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   ProxyHost     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ UUID            │◄──┐
β”‚ Domain          β”‚   β”‚
β”‚ ForwardScheme   β”‚   β”‚
β”‚ ForwardHost     β”‚   β”‚
β”‚ ForwardPort     β”‚   β”‚
β”‚ SSLForced       β”‚   β”‚
β”‚ WebSocketSupportβ”‚   β”‚
β”‚ Enabled         β”‚   β”‚
β”‚ RemoteServerID  β”‚β”€β”€β”€β”˜ (optional)
β”‚ CreatedAt       β”‚
β”‚ UpdatedAt       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β”‚ 1:1
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  CaddyConfig    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ UUID            β”‚
β”‚ ProxyHostID     β”‚
β”‚ RawConfig       β”‚
β”‚ GeneratedAt     β”‚
β”‚ CreatedAt       β”‚
β”‚ UpdatedAt       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ RemoteServer    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ UUID            β”‚
β”‚ Name            β”‚
β”‚ Provider        β”‚
β”‚ Host            β”‚
β”‚ Port            β”‚
β”‚ Reachable       β”‚
β”‚ LastChecked     β”‚
β”‚ Enabled         β”‚
β”‚ CreatedAt       β”‚
β”‚ UpdatedAt       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ SSLCertificate  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ UUID            β”‚
β”‚ Name            β”‚
β”‚ DomainNames     β”‚
β”‚ CertPEM         β”‚
β”‚ KeyPEM          β”‚
β”‚ ExpiresAt       β”‚
β”‚ CreatedAt       β”‚
β”‚ UpdatedAt       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  AccessList     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ UUID            β”‚
β”‚ Name            β”‚
β”‚ Addresses       β”‚
β”‚ CreatedAt       β”‚
β”‚ UpdatedAt       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚      User       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ UUID            β”‚
β”‚ Email           β”‚
β”‚ PasswordHash    β”‚
β”‚ IsActive        β”‚
β”‚ IsAdmin         β”‚
β”‚ CreatedAt       β”‚
β”‚ UpdatedAt       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    Setting      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ UUID            β”‚
β”‚ Key             β”‚ (unique)
β”‚ Value           β”‚
β”‚ CreatedAt       β”‚
β”‚ UpdatedAt       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ ImportSession   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ UUID            β”‚
β”‚ Filename        β”‚
β”‚ State           β”‚
β”‚ CreatedAt       β”‚
β”‚ UpdatedAt       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Table Details

ProxyHost

Stores reverse proxy host configurations.

Column Type Description
uuid UUID Primary key
domain TEXT Domain names (comma-separated)
forward_scheme TEXT http or https
forward_host TEXT Target server hostname/IP
forward_port INTEGER Target server port
ssl_forced BOOLEAN Force HTTPS redirect
http2_support BOOLEAN Enable HTTP/2
hsts_enabled BOOLEAN Enable HSTS header
hsts_subdomains BOOLEAN Include subdomains in HSTS
block_exploits BOOLEAN Block common exploits
websocket_support BOOLEAN Enable WebSocket proxying
enabled BOOLEAN Proxy is active
remote_server_id UUID Foreign key to RemoteServer (nullable)
created_at TIMESTAMP Creation timestamp
updated_at TIMESTAMP Last update timestamp

Indexes:

Relationships:

RemoteServer

Stores remote Caddy server connection information.

Column Type Description
uuid UUID Primary key
name TEXT Friendly name
provider TEXT generic, docker, kubernetes, aws, gcp, azure
host TEXT Hostname or IP address
port INTEGER Port number (default 2019)
reachable BOOLEAN Connection test result
last_checked TIMESTAMP Last connection test time
enabled BOOLEAN Server is active
created_at TIMESTAMP Creation timestamp
updated_at TIMESTAMP Last update timestamp

Indexes:

CaddyConfig

Stores generated Caddyfile configurations for each proxy host.

Column Type Description
uuid UUID Primary key
proxy_host_id UUID Foreign key to ProxyHost
raw_config TEXT Generated Caddyfile content
generated_at TIMESTAMP When config was generated
created_at TIMESTAMP Creation timestamp
updated_at TIMESTAMP Last update timestamp

Indexes:

SSLCertificate

Stores SSL/TLS certificates (future enhancement).

Column Type Description
uuid UUID Primary key
name TEXT Certificate name
domain_names TEXT Domains covered (comma-separated)
cert_pem TEXT Certificate in PEM format
key_pem TEXT Private key in PEM format
expires_at TIMESTAMP Certificate expiration
created_at TIMESTAMP Creation timestamp
updated_at TIMESTAMP Last update timestamp

AccessList

Stores IP-based access control lists (future enhancement).

Column Type Description
uuid UUID Primary key
name TEXT List name
addresses TEXT IP addresses (comma-separated)
created_at TIMESTAMP Creation timestamp
updated_at TIMESTAMP Last update timestamp

User

Stores user authentication information (future enhancement).

Column Type Description
uuid UUID Primary key
email TEXT Email address (unique)
password_hash TEXT Bcrypt password hash
is_active BOOLEAN Account is active
is_admin BOOLEAN Admin privileges
created_at TIMESTAMP Creation timestamp
updated_at TIMESTAMP Last update timestamp

Indexes:

Setting

Stores application-wide settings as key-value pairs.

Column Type Description
uuid UUID Primary key
key TEXT Setting key (unique)
value TEXT Setting value (JSON string)
created_at TIMESTAMP Creation timestamp
updated_at TIMESTAMP Last update timestamp

Indexes:

Default Settings:

ImportSession

Tracks Caddyfile import sessions.

Column Type Description
uuid UUID Primary key
filename TEXT Uploaded filename (optional)
state TEXT parsing, reviewing, completed, failed
created_at TIMESTAMP Creation timestamp
updated_at TIMESTAMP Last update timestamp

States:

Database Initialization

The database is automatically created and migrated when the application starts. Use the seed script to populate with sample data:

cd backend
go run ./cmd/seed/main.go

Sample Seed Data

The seed script creates:

Migration Strategy

GORM AutoMigrate is used for schema migrations:

db.AutoMigrate(
    &models.ProxyHost{},
    &models.RemoteServer{},
    &models.CaddyConfig{},
    &models.SSLCertificate{},
    &models.AccessList{},
    &models.User{},
    &models.Setting{},
    &models.ImportSession{},
)

This ensures the database schema stays in sync with model definitions.

Backup and Restore

Backup

# Backup default DB (charon.db). cpm.db will still be recognized for compatibility.
cp backend/data/charon.db backend/data/charon.db.backup

Restore

# Restore default DB (charon.db). cpm.db backup will still be recognized for compatibility.
cp backend/data/charon.db.backup backend/data/charon.db

Performance Considerations

Future Enhancements