Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Architecture

Technical architecture of the Postbase platform.

System Overview

┌─────────────────────────────────────────────────────────────────────────────┐
│                              POSTBASE PLATFORM                               │
├─────────────────────────────────┬───────────────────────────────────────────┤
│      LOCAL DEVELOPMENT          │            CLOUD PLATFORM                 │
│                                 │                                           │
│  ┌─────────────────────────┐   │   ┌─────────────────────────────────────┐│
│  │       @postbase/cli     │   │   │         @postbase/cloud              ││
│  │  • Database commands    │   │   │    Cloudflare Worker at Edge         ││
│  │  • Migration engine     │   │   │                                      ││
│  │  • Type generation      │───┼──▶│  • GitHub OAuth                      ││
│  │  • Cloud operations     │   │   │  • Project management                ││
│  └───────────┬─────────────┘   │   │  • Database provisioning             ││
│              │                 │   │  • Backup orchestration              ││
│  ┌───────────▼─────────────┐   │   └──────────────┬──────────────────────┘│
│  │     @postbase/daemon    │   │                  │                        │
│  │   Hono API on :9432     │   │   ┌──────────────▼──────────────────────┐│
│  │                         │   │   │         Infrastructure              ││
│  │  • Docker management    │   │   │                                      ││
│  │  • PostgreSQL control   │   │   │  ┌────────────┐  ┌────────────────┐ ││
│  │  • Migration execution  │   │   │  │  Railway   │  │  Cloudflare    │ ││
│  │  • Query proxy          │   │   │  │ PostgreSQL │  │  D1 + R2 + KV  │ ││
│  └───────────┬─────────────┘   │   │  └────────────┘  └────────────────┘ ││
│              │                 │   │                                      ││
│  ┌───────────▼─────────────┐   │   │  ┌────────────────────────────────┐ ││
│  │      PostgreSQL         │   │   │  │    @postbase/backup-service    │ ││
│  │   Docker Container      │   │   │  │    Railway Docker Container    │ ││
│  │                         │   │   │  │                                │ ││
│  │  • supabase/postgres    │   │   │  │  • pg_dump / pg_restore        │ ││
│  │  • Multiple databases   │   │   │  │  • pg_receivewal (PITR)        │ ││
│  │  • Pre-installed exts   │   │   │  │  • R2 streaming upload         │ ││
│  └─────────────────────────┘   │   │  └────────────────────────────────┘ ││
│                                 │   └─────────────────────────────────────┘│
│  ┌─────────────────────────┐   │                                           │
│  │      @postbase/ui       │   │                                           │
│  │   React Admin Panel     │   │                                           │
│  │                         │   │                                           │
│  │  • Schema browser       │   │                                           │
│  │  • Data viewer/editor   │   │                                           │
│  │  • SQL editor           │   │                                           │
│  │  • Migration manager    │   │                                           │
│  └─────────────────────────┘   │                                           │
└─────────────────────────────────┴───────────────────────────────────────────┘

Package Structure

postbase/
├── packages/
│   ├── cli/              # Command-line interface
│   ├── daemon/           # Local API server
│   ├── cloud/            # Cloudflare Worker API
│   ├── backup-service/   # Backup Docker container
│   ├── postgres-image/   # Custom PostgreSQL image
│   ├── sdk/              # TypeScript client SDK
│   ├── shared/           # Shared types and schemas
│   ├── ui/               # React admin interface
│   ├── cdn/              # Static asset hosting
│   └── docs/             # Documentation (Vocs)
├── docs/                 # Architecture documents
└── package.json          # pnpm monorepo root

Technology Stack

Frontend

PackageTechnologies
@postbase/uiReact 18, Vite, TanStack Query/Table, Monaco Editor, shadcn/ui, Tailwind CSS
@postbase/docsVocs, MDX, React

Backend

PackageTechnologies
@postbase/daemonHono, TypeScript, tsx, dockerode, pg
@postbase/cloudHono, Cloudflare Workers, D1, KV, R2
@postbase/backup-serviceHono, Docker, pg_dump, pg_receivewal, AWS SDK

CLI & SDK

PackageTechnologies
@postbase/cliCommander.js, chalk, ora, pg, tsx
@postbase/sdkKysely, pg, TypeScript
@postbase/sharedZod, TypeScript

Data Flow

Local Development

┌──────────┐     HTTP      ┌──────────┐    postgres    ┌────────────┐
│   CLI    │──────────────▶│  Daemon  │───────────────▶│ PostgreSQL │
│          │               │  :9432   │                │   :5432    │
└──────────┘               └──────────┘                └────────────┘

┌──────────┐     HTTP           │
│    UI    │────────────────────┘
│  :3000   │
└──────────┘

Cloud Platform

┌──────────┐     HTTPS     ┌──────────┐    Railway    ┌────────────┐
│   CLI    │──────────────▶│  Cloud   │──────API─────▶│ PostgreSQL │
│          │               │   API    │               │  Railway   │
└──────────┘               └──────────┘               └────────────┘

                           D1 / KV / R2

                     ┌──────────▼──────────┐
                     │   Backup Service    │
                     │     (Railway)       │
                     └─────────────────────┘

Backup Flow

                            ┌────────────────┐
                            │  Cloud API     │
                            │  (Cloudflare)  │
                            └───────┬────────┘

                           POST /backup

                            ┌───────▼────────┐
                            │ Backup Service │
                            │   (Railway)    │
                            └───────┬────────┘

                    ┌───────────────┼───────────────┐
                    │               │               │
            ┌───────▼───────┐       │       ┌───────▼───────┐
            │  PostgreSQL   │──pg_dump──────│      R2       │
            │   (Railway)   │               │  (Cloudflare) │
            └───────────────┘               └───────────────┘

                                callback

                            ┌───────▼────────┐
                            │  Cloud API     │
                            │ Update D1 meta │
                            └────────────────┘

PITR Flow

                                         Continuous
┌───────────────────┐                    WAL Streaming
│    PostgreSQL     │──────pg_receivewal────────────┐
│     (Railway)     │                               │
└───────────────────┘                               │
                                            ┌───────▼───────┐
                                            │Backup Service │
                                            └───────┬───────┘

                                              Upload WAL

                                            ┌───────▼───────┐
                                            │      R2       │
                                            │  WAL Storage  │
                                            └───────────────┘
 
Recovery:
┌──────────┐                    ┌───────────────┐
│ Cloud API│──POST /pitr-restore│Backup Service │
└──────────┘                    └───────┬───────┘

                        ┌───────────────┼───────────────┐
                        │               │               │
                ┌───────▼───────┐       │       ┌───────▼───────┐
                │      R2       │───download────│  temp restore │
                │ base + WAL    │               │    folder     │
                └───────────────┘               └───────┬───────┘

                                                pg_restore +
                                                WAL replay

                                                ┌───────▼───────┐
                                                │  PostgreSQL   │
                                                └───────────────┘

Cloud Services

Cloudflare

ServicePurpose
WorkersCloud API at api.postbase.sh
D1Relational metadata (users, projects, databases, backups)
KVSession storage, device codes
R2Backup storage, WAL archives

Railway

ServicePurpose
PostgreSQLCloud database instances
DockerBackup service container

GitHub

FeaturePurpose
OAuthUser authentication
Container RegistryCustom PostgreSQL images

Security

Authentication

  1. Local: No authentication (trusted local environment)
  2. Cloud: GitHub OAuth with device flow
  3. Backup Service: Shared secret token

Data Protection

  1. Passwords: 32-character cryptographically random
  2. Backups: Encrypted at rest in R2
  3. Transit: HTTPS for all cloud communication
  4. Credentials: Stored in ~/.postbase/, never in version control

Network

  1. Railway: Private networking, SSL optional
  2. Cloudflare: Edge TLS termination
  3. Backup Service: Internal Railway network

Scalability

Current Limits

ResourceLimit
Databases per project10
Backup size10 GB
WAL retention7 days
API rate limit60 req/min (free)

Future Scaling

  1. Read Replicas: Railway regional deployment
  2. Connection Pooling: PgBouncer integration
  3. Multi-region: Edge routing with Cloudflare
  4. High Availability: Primary-replica failover