# Server Setup ## Prerequisites - Docker & Docker Compose (recommended) - OR Dart SDK 3.6+ and PostgreSQL 16+ ## Docker Deployment (Recommended) ### Quick Start ```bash cd Toadist # Start services ./docker-start.sh start # View logs ./docker-start.sh logs # Stop services ./docker-start.sh stop ``` ### docker-start.sh Commands | Command | Description | |---------|-------------| | `start` | Start all containers | | `stop` | Stop all containers | | `restart` | Restart all containers | | `rebuild` | Rebuild and restart server | | `logs` | View server logs | | `status` | Show container status | | `clean` | Remove all containers and volumes | ### Configuration Edit `docker-compose.yml` to customize: ```yaml services: db: environment: POSTGRES_PASSWORD: your_password server: environment: DB_HOST: db DB_PORT: 5432 DB_NAME: toadist DB_USER: postgres DB_PASSWORD: your_password ``` --- ## Manual Setup ### 1. Install PostgreSQL ```bash # Ubuntu sudo apt install postgresql-16 # Create database sudo -u postgres createdb toadist ``` ### 2. Configure Environment ```bash export DB_HOST=localhost export DB_PORT=5432 export DB_NAME=toadist export DB_USER=postgres export DB_PASSWORD=your_password ``` ### 3. Install Dependencies ```bash cd server dart pub get ``` ### 4. Run Server ```bash dart run bin/server.dart --port 8080 --host 0.0.0.0 ``` --- ## Server Options ```bash dart run bin/server.dart --help Options: -p, --port Port to listen on (default: 8080) -h, --host Host to bind to (default: 0.0.0.0) --help Show help ``` --- ## Health Check ```bash curl http://localhost:8082/health # {"status": "healthy", "uptime": 1234567890} ``` --- ## Production Considerations 1. **Use strong JWT secret** - Set via environment variable 2. **Enable HTTPS** - Use reverse proxy (nginx, Caddy) 3. **Database backups** - Regular PostgreSQL dumps 4. **Monitoring** - Health endpoint for uptime checks 5. **Rate limiting** - Add rate limit middleware