Open Source Backend-as-a-Service (BaaS) - PocketBase Alternative
Fieldstone is a lightweight, self-hosted backend platform that provides:
- REST API for CRUD operations
- Real-time subscriptions via WebSockets
- Multi-tenancy support
- Authentication with JWT
- File storage (local/S3)
- Background jobs with retry logic
- Admin dashboard for management
- gRPC support for high-performance operations
# Clone the repository
git clone https://github.com/yourusername/fieldstone.git
cd fieldstone
# Start with Docker Compose
docker-compose up -d
# Access the services:
# API: http://localhost:8090
# Admin UI: http://localhost:8090/admin
# API Documentation: http://localhost:8090/docs# Download latest release
wget https://github.com/yourusername/fieldstone/releases/latest/download/fieldstone-linux-amd64.tar.gz
tar -xzf fieldstone-linux-amd64.tar.gz
# Run migrations
./fieldstone-migrate -dsn "data/fieldstone.db" -direction up
# Start server
./fieldstone# Install
go install github.com/yourusername/fieldstone/cmd/server@latest
# Run
go run cmd/server/main.go- Features
- Architecture
- Installation
- Configuration
- API Documentation
- Development
- Deployment
- Contributing
- License
- β RESTful API - Full CRUD operations for collections and records
- β Real-time - WebSocket subscriptions for live updates
- β Authentication - JWT-based auth with refresh tokens
- β Multi-tenancy - Isolated data per tenant
- β File Storage - Local filesystem or S3-compatible storage
- β Background Jobs - Async job processing with retries
- β Rate Limiting - Configurable rate limits per endpoint
- β Admin Dashboard - React-based management interface
- β Database Support - SQLite (dev) and PostgreSQL (prod)
- β Migrations - Versioned database schema migrations
- β Webhooks - Event-driven HTTP callbacks
- β gRPC - High-performance RPC interface
- π JWT authentication with secure token rotation
- π Row-level security (RLS) with PostgreSQL
- π Password hashing with bcrypt
- π Rate limiting and request throttling
- π CORS configuration
- π Input validation and sanitization
- π οΈ Auto-generated API documentation (OpenAPI/Swagger)
- π οΈ TypeScript SDK for frontend integration
- π οΈ Comprehensive test suite
- π οΈ Hot reload for development
- π οΈ Structured logging with zerolog
- π οΈ Docker support with multi-stage builds
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CLIENTS β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Web App β β Mobile App β β CLI Tool β β
β β (React) β β (iOS/And) β β (Go/TS) β β
β ββββββββ¬ββββββββ ββββββββ¬ββββββββ ββββββββ¬ββββββββ β
βββββββββββΌββββββββββββββββββΌββββββββββββββββββΌβββββββββββββββ
β β β
βββββββββββββββββββΌββββββββββββββββββ
β HTTPS/HTTP2
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FIELDSTONE β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β API Layer β β
β β β’ REST (Chi Router) β’ gRPC β’ WebSocket β β
β ββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββ β
β β Service Layer β β
β β β’ Auth β’ Collections β’ Records β’ Storage β β
β ββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββ β
β β Backend Interface β β
β β ββββββββββββββββ ββββββββββββββββ ββββββββββββ β β
β β β SQLite β β PostgreSQL β β Memory β β β
β β β (dev) β β (prod) β β (test) β β β
β β ββββββββββββββββ ββββββββββββββββ ββββββββββββ β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Go 1.23+ (for building from source)
- Node.js 20+ (for admin dashboard development)
- Docker & Docker Compose (optional, for containerized deployment)
- PostgreSQL 15+ (optional, for production database)
# Pull the image
docker pull ghcr.io/yourusername/fieldstone:latest
# Run with SQLite (simplest)
docker run -d \
--name fieldstone \
-p 8090:8090 \
-v fieldstone_data:/data \
-e DATABASE_URL=sqlite:///data/fieldstone.db \
ghcr.io/yourusername/fieldstone:latest
# Run with PostgreSQL (recommended for production)
docker-compose up -d# Download for your platform
curl -L https://github.com/yourusername/fieldstone/releases/download/v1.0.0/fieldstone-$(uname -s)-$(uname -m).tar.gz | tar xz
# Move to PATH
sudo mv fieldstone /usr/local/bin/
sudo mv fieldstone-migrate /usr/local/bin/
# Verify installation
fieldstone --version# Clone repository
git clone https://github.com/yourusername/fieldstone.git
cd fieldstone
# Install Go dependencies
go mod download
# Build binary
make build
# Or build for production
make build-prod| Variable | Description | Default |
|---|---|---|
DATABASE_URL |
Database connection string | sqlite://data/fieldstone.db |
JWT_SECRET |
Secret key for JWT signing | Required |
JWT_EXPIRY |
JWT token expiry duration | 1h |
SERVER_HOST |
Server bind address | 0.0.0.0 |
SERVER_PORT |
HTTP server port | 8090 |
GRPC_PORT |
gRPC server port | 50051 |
LOG_LEVEL |
Logging level (debug/info/warn/error) | info |
STORAGE_TYPE |
Storage backend (local/s3) | local |
STORAGE_LOCAL_PATH |
Path for local file storage | ./uploads |
RATE_LIMIT_ENABLED |
Enable rate limiting | true |
RATE_LIMIT_REQUESTS |
Requests per window | 100 |
RATE_LIMIT_WINDOW |
Rate limit window (seconds) | 60 |
ENABLE_WEBHOOKS |
Enable webhook processing | true |
ENABLE_PLUGINS |
Enable WASM plugins | true |
ENABLE_REALTIME |
Enable WebSocket realtime | true |
Development (.env):
DATABASE_URL=sqlite://data/fieldstone.db
JWT_SECRET=dev-secret-not-for-production
LOG_LEVEL=debug
SERVER_PORT=8090
STORAGE_TYPE=local
STORAGE_LOCAL_PATH=./uploadsProduction (.env.production):
DATABASE_URL=postgres://user:password@postgres:5432/fieldstone?sslmode=require
JWT_SECRET=your-256-bit-secret-key-here
LOG_LEVEL=warn
SERVER_PORT=8090
STORAGE_TYPE=s3
STORAGE_S3_ENDPOINT=s3.amazonaws.com
STORAGE_S3_BUCKET=fieldstone-files
STORAGE_S3_REGION=us-east-1
RATE_LIMIT_ENABLED=true
RATE_LIMIT_REQUESTS=1000Register a new user:
curl -X POST http://localhost:8090/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "securepassword123"
}'Login:
curl -X POST http://localhost:8090/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "securepassword123"
}'
# Response: {"token": "eyJhbGciOiJIUzI1NiIs...", "record": {...}}Use the token:
curl -H "Authorization: Bearer YOUR_TOKEN" \
http://localhost:8090/api/collectionsCreate a collection:
curl -X POST http://localhost:8090/api/collections \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "products",
"schema": [
{"name": "title", "type": "text", "required": true},
{"name": "price", "type": "number"},
{"name": "inStock", "type": "boolean", "default": true}
]
}'List collections:
curl -H "Authorization: Bearer YOUR_TOKEN" \
http://localhost:8090/api/collectionsCreate a record:
curl -X POST http://localhost:8090/api/collections/PRODUCTS_ID/records \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "Awesome Product",
"price": 99.99,
"inStock": true
}'Query records with pagination:
curl -H "Authorization: Bearer YOUR_TOKEN" \
"http://localhost:8090/api/collections/PRODUCTS_ID/records?page=1&perPage=10&sort=-created"Connect to WebSocket:
const ws = new WebSocket('ws://localhost:8090/ws');
// Subscribe to collection
ws.send(JSON.stringify({
type: 'subscribe',
collectionId: 'PRODUCTS_ID'
}));
// Listen for events
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Change detected:', data);
};# Clone repo
git clone https://github.com/yourusername/fieldstone.git
cd fieldstone
# Install Go dependencies
go mod download
# Install frontend dependencies
cd web/admin && npm install && cd ../..
# Copy environment file
cp .env.example .env
# Edit .env with your settings
# Run database migrations
go run cmd/migrate/main.go -direction up
# Start development server with hot reload
make devfieldstone/
βββ cmd/ # Application entry points
β βββ server/ # Main HTTP server
β βββ migrate/ # Database migration tool
βββ internal/ # Private application code
β βββ api/ # HTTP handlers
β βββ auth/ # Authentication logic
β βββ backend/ # Database implementations
β βββ jobs/ # Background job queue
β βββ migrate/ # Migration framework
β βββ ratelimit/ # Rate limiting
β βββ realtime/ # WebSocket manager
β βββ storage/ # File storage
β βββ webhooks/ # Webhook processing
βββ pkg/ # Public packages
β βββ models/ # Data models
βββ web/ # Frontend applications
β βββ admin/ # React admin dashboard
βββ api/ # API definitions
β βββ proto/ # gRPC protobuf files
βββ docs/ # Documentation
βββ migrations/ # Database migrations
βββ scripts/ # Utility scripts
βββ Dockerfile # Docker build file
βββ docker-compose.yml # Docker Compose config
βββ Makefile # Build automation
βββ README.md # This file
# Run all tests
make test
# Run with coverage
make test-coverage
# Run specific package tests
go test ./internal/api/... -v
# Run benchmarks
go test ./... -bench=.# Create new migration files
# SQLite:
touch internal/migrate/migrations/sqlite/002_add_users_field.up.sql
touch internal/migrate/migrations/sqlite/002_add_users_field.down.sql
# PostgreSQL:
touch internal/migrate/migrations/postgres/002_add_users_field.up.sql
touch internal/migrate/migrations/postgres/002_add_users_field.down.sql
# Write migration SQL, then apply:
go run cmd/migrate/main.go -direction up# Production deployment
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
# View logs
docker-compose logs -f
# Scale API servers
docker-compose up -d --scale fieldstone=3# Apply manifests
kubectl apply -f k8s/
# Check deployment
kubectl get pods -l app=fieldstone
# View logs
kubectl logs -l app=fieldstone -fCreate /etc/systemd/system/fieldstone.service:
[Unit]
Description=Fieldstone BaaS
After=network.target
[Service]
Type=simple
User=fieldstone
WorkingDirectory=/opt/fieldstone
ExecStart=/usr/local/bin/fieldstone
Restart=always
RestartSec=10
Environment="DATABASE_URL=sqlite:///data/fieldstone.db"
Environment="JWT_SECRET=your-secret-key"
[Install]
WantedBy=multi-user.targetEnable and start:
sudo systemctl enable fieldstone
sudo systemctl start fieldstone
sudo systemctl status fieldstoneWe welcome contributions! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow standard Go formatting (
gofmt) - Write comprehensive tests
- Maintain 70%+ code coverage
- Update documentation
- Follow conventional commits
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by PocketBase
- Built with Chi Router
- UI components from shadcn/ui
- Documentation: https://fieldstone-docs.vercel.app
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Discord: Join our community
Made with β€οΈ by the Fieldstone community