Simple todo application with Go backend, Svelte frontend, and PostgreSQL database.
- Go 1.21+
- Node.js 18+
- PostgreSQL 12+
Create a PostgreSQL database:
createdb todosOr using psql:
psql -U postgres -c "CREATE DATABASE todos;"cd backend
go mod download
go run main.goThe backend runs on port 8080 by default. Set environment variables if needed:
DB_HOST(default: localhost)DB_PORT(default: 5432)DB_USER(default: postgres)DB_PASSWORD(default: postgres)DB_NAME(default: todos)PORT(default: 8080)
cd frontend
npm install
npm run devThe frontend runs on port 5173 by default.
Build the frontend:
cd frontend
npm run buildThe backend serves the built frontend from / and API endpoints from /api/*.
- Create a new project on Railway
- Connect your GitHub repository
- Add a PostgreSQL service
- Railway automatically provides
DATABASE_URLenvironment variable - no manual configuration needed - Deploy - Railway will build and deploy using the Dockerfile
Alternatively, you can set individual database variables:
DB_HOST,DB_PORT,DB_USER,DB_PASSWORD,DB_NAME
The Dockerfile builds both frontend and backend into a single container.