Production-ready starter template with Go Fiber v2 + GORM backend and SvelteKit + Svelte 5 frontend.
Clone the repo and start building your project in minutes.
git clone https://github.com/simvol2030/fiber-sveltekit.git my-project
cd my-project
# Point to your own repository
git remote set-url origin https://github.com/YOUR_USER/YOUR_REPO.git
| What | Where | Change to |
|---|---|---|
| JWT_SECRET | ecosystem.config.js or .env |
New random string 32+ chars. Generate: openssl rand -base64 32 |
| Domain | ecosystem.config.js → CORS_ORIGINS, FRONTEND_URL, ORIGIN |
Your domain (e.g. https://my-app.com) |
| App name | frontend-sveltekit/package.json → name |
Your project name |
| App title | frontend-sveltekit/src/app.html → <title> |
Your app title |
| Footer | frontend-sveltekit/src/routes/+layout.svelte |
Your company/project name |
| Admin email | Database seed or first register | Your admin email |
# Delete existing database
rm -f data/db/sqlite/app.db
# Start backend — GORM auto-creates tables on first run
# Register your admin user at /register, then set role in DB:
sqlite3 data/db/sqlite/app.db "UPDATE users SET role='admin' WHERE email='[email protected]';"
Option A: PM2 (lightweight, recommended for VPS)
# Copy PM2 config template and fill in your values
cp ecosystem.config.js.example ecosystem.config.js
# Edit ecosystem.config.js — change JWT_SECRET, domain, paths
# Build
cd backend-go-fiber && go build -o server cmd/server/main.go
cd ../frontend-sveltekit && npm install && npm run build
# Start
pm2 start ecosystem.config.js
pm2 save
Option B: Docker
cp .env.example .env
# Edit .env — change JWT_SECRET, domain
docker-compose up --build -d
# Create nginx config (replace YOUR_DOMAIN)
sudo nano /etc/nginx/sites-available/YOUR_DOMAIN
# Template:
# server {
# server_name YOUR_DOMAIN;
# location / { proxy_pass http://127.0.0.1:3000; ... }
# location /api/ { proxy_pass http://127.0.0.1:3001; ... }
# location /health { proxy_pass http://127.0.0.1:3001; }
# location /uploads/ { proxy_pass http://127.0.0.1:3001; }
# client_max_body_size 10M;
# }
sudo ln -s /etc/nginx/sites-available/YOUR_DOMAIN /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
# SSL
sudo certbot --nginx -d YOUR_DOMAIN
/admin — users CRUD, file browser with upload, app settings/dashboard — profile, name edit, password change/health, /readyYour models → backend-go-fiber/internal/models/
Your handlers → backend-go-fiber/internal/handlers/
Your services → backend-go-fiber/internal/services/
Your pages → frontend-sveltekit/src/routes/
Your components → frontend-sveltekit/src/lib/components/
/robots.txt/sitemap.xmlHeadMeta.svelte component for OG/Twitter cardsSchemaOrg.svelte for structured data (JSON-LD)* in production)make seed# Copy environment template
cp .env.example .env
# Generate a secure JWT secret
make generate-secret
# Copy the output to JWT_SECRET in .env
Option A: Docker (recommended)
make docker
# or manually:
docker-compose up --build
Option B: Local Development
# Install dependencies
make install
# Terminal 1: Start backend
make dev-backend
# Terminal 2: Start frontend
make dev-frontend
| Service | URL |
|---|---|
| Frontend | http://localhost:3000 |
| Backend API | http://localhost:3001 |
| Health Check | http://localhost:3001/health |
make help # Show all commands
# Development
make install # Install all dependencies
make dev-backend # Start Go backend
make dev-frontend # Start SvelteKit frontend
# Build
make build # Build for production
make build-backend # Build Go binary
make build-frontend # Build SvelteKit
# Testing
make test # Run all tests
make test-backend # Run Go tests
make test-backend-coverage # Run with coverage report
# Docker
make docker # Build and start containers
make docker-down # Stop containers
make docker-logs # View logs
make docker-postgres # Start with PostgreSQL
# Database
make seed # Seed with test data
make db-reset # Reset SQLite database
make db-fresh # Reset + seed
# Utilities
make lint # Lint all code
make format # Format all code
make clean # Clean build artifacts
make generate-secret # Generate JWT secret
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| POST | /api/auth/register |
- | Register new user |
| POST | /api/auth/login |
- | Login, get tokens |
| POST | /api/auth/refresh |
Cookie | Refresh access token |
| POST | /api/auth/logout |
Cookie | Logout, clear tokens |
| GET | /api/auth/me |
Bearer | Get current user |
| POST | /api/auth/forgot-password |
- | Request password reset |
| POST | /api/auth/validate-reset-token |
- | Validate reset token |
| POST | /api/auth/reset-password |
- | Reset password with token |
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| POST | /api/upload |
Bearer | Upload single file |
| POST | /api/upload/multiple |
Bearer | Upload multiple files (max 10) |
| DELETE | /api/upload/* |
Bearer | Delete file by key |
| GET | /uploads/* |
- | Serve uploaded files (local only) |
| Method | Endpoint | Description |
|---|---|---|
| GET | /health |
Basic health check |
| GET | /ready |
Readiness (DB check) |
// Success Response
{
"success": true,
"data": { ... },
"meta": {
"timestamp": "2025-01-18T12:00:00Z",
"requestId": "uuid"
}
}
// Error Response
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Email is required",
"details": [{"field": "email", "message": "..."}]
},
"meta": { ... }
}
| Variable | Default | Description |
|---|---|---|
NODE_ENV |
development | Environment mode |
PORT |
3001 | Backend port |
DATABASE_URL |
sqlite:./data/... | Database connection |
JWT_SECRET |
- | Required in production (32+ chars) |
JWT_EXPIRES_IN |
15m | Access token TTL |
REFRESH_TOKEN_EXPIRES_DAYS |
7 | Refresh token TTL |
CORS_ORIGINS |
http://localhost:3000 | Allowed origins |
LOG_LEVEL |
info | debug/info/warn/error |
SMTP_HOST |
- | SMTP server for emails (production) |
S3_BUCKET |
- | S3 bucket for file storage |
FRONTEND_URL |
http://localhost:3000 | For password reset links |
See .env.example for complete list.
make deploy-check # Show checklist
NODE_ENV=production in .envJWT_SECRET is 32+ random charactersCORS_ORIGINS set to production domain(s)DATABASE_URL points to production database# 1. Build production images
docker-compose build
# 2. Start containers
docker-compose up -d
# 3. Check health
curl http://localhost:3001/health
deploy/nginx.conf to /etc/nginx/sites-available/your-app.confserver_name and SSL certificate pathsln -s /etc/nginx/sites-available/your-app.conf /etc/nginx/sites-enabled/nginx -t && systemctl reload nginx# Install certbot
apt install certbot python3-certbot-nginx
# Get certificate
certbot --nginx -d your-domain.com
# Auto-renewal (cron)
0 0 * * * /usr/bin/certbot renew --quiet
# Start with PostgreSQL
docker-compose --profile postgres up -d
# Update .env
DATABASE_URL=postgresql://app:secret@localhost:5432/app
# 1. Create database
createdb -U postgres app
# 2. Update .env
DATABASE_URL=postgresql://user:password@host:5432/app?sslmode=require
# 3. Run migrations (GORM auto-migrates on startup)
project-box-go-fiber-sveltekit/
├── backend-go-fiber/
│ ├── cmd/server/main.go # Entry point
│ ├── internal/
│ │ ├── handlers/ # HTTP handlers
│ │ ├── middleware/ # Auth, CORS, Security
│ │ ├── models/ # GORM models
│ │ ├── services/ # Business logic
│ │ └── utils/ # JWT, validation, helpers
│ ├── go.mod
│ └── Dockerfile
│
├── frontend-sveltekit/
│ ├── src/
│ │ ├── routes/ # Pages
│ │ └── lib/
│ │ ├── api/client.ts # API client
│ │ └── stores/ # Auth store (Svelte 5 runes)
│ ├── package.json
│ └── Dockerfile
│
├── deploy/
│ └── nginx.conf # Nginx reverse proxy config
│
├── data/ # Persistent data (gitignored)
│ ├── db/sqlite/
│ ├── db/postgres/
│ └── logs/
│
├── docker-compose.yml
├── Makefile
├── .env.example
└── README.md
# Run all tests
make test-backend
# Run with coverage
make test-backend-coverage
# Open backend-go-fiber/coverage.html
# Run specific test
cd backend-go-fiber && go test -v ./internal/services/...
# Type check
make test-frontend
# Lint
cd frontend-sveltekit && npm run lint
# Format check
cd frontend-sveltekit && npm run format:check
# Create .env file
cp .env.example .env
# Edit .env and set JWT_SECRET
# Ensure data directory exists
mkdir -p data/db/sqlite
# Check permissions
chmod 755 data/db/sqlite
# Clear cache and reinstall
rm -rf frontend-sveltekit/node_modules frontend-sveltekit/.svelte-kit
cd frontend-sveltekit && npm install
MIT
Built with Box-App templates v2.0