2.8 KiB
2.8 KiB
Quick Start: PostgreSQL Setup
✅ What's Been Configured
- Backend Database Connection: Configured to use
postgresql+asyncpg://sibu:sibu@localhost:5432/sibu - Environment File: Created
backend/.env.developmentwith database settings - API Client: Created Flutter
ApiClientservice for backend communication - Run Scripts: Created helper scripts for easy execution
🚀 Quick Start
1. Ensure PostgreSQL is Running
# Check if PostgreSQL is running
psql -h localhost -p 5432 -U sibu -d sibu -c "SELECT version();"
If it fails, start PostgreSQL:
# macOS with Homebrew
brew services start postgresql@14 # or your version
2. Create Database (if needed)
psql -h localhost -p 5432 -U postgres -c "CREATE DATABASE sibu;"
psql -h localhost -p 5432 -U postgres -c "CREATE USER sibu WITH PASSWORD 'sibu';"
psql -h localhost -p 5432 -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE sibu TO sibu;"
3. Apply Database Schema
You have migrations in supabase/migrations/. Apply them:
cd old
# Apply all migrations
for migration in supabase/migrations/*.sql; do
psql -h localhost -p 5432 -U sibu -d sibu -f "$migration"
done
Or use Alembic (if backend models match):
cd backend
uv run alembic upgrade head
4. Start Backend API
cd backend
uv run fastapi dev app/main.py
Backend will be available at: http://localhost:8000
5. Run Flutter App
In a new terminal:
cd old
./scripts/run-flutter-backend.sh
Or manually:
flutter run -d chrome --dart-define=API_BASE_URL=http://localhost:8000
📋 Configuration Summary
| Component | Configuration |
|---|---|
| Database | sibu:sibu@localhost:5432/sibu |
| Backend API | http://localhost:8000 |
| Flutter API Client | Configured via --dart-define=API_BASE_URL |
🔍 Verify Setup
Test Database Connection
psql -h localhost -p 5432 -U sibu -d sibu -c "\dt" # List tables
Test Backend API
curl http://localhost:8000/health
curl http://localhost:8000/api/routes
Test Flutter Connection
The app will automatically try to connect to the backend API on startup.
📚 Next Steps
- See
README-POSTGRESQL-SETUP.mdfor detailed documentation - Update Flutter services to use
ApiClientinstead ofSupabaseService(currently still using Supabase) - Add authentication if needed
- Configure CORS properly for production
🐛 Troubleshooting
Backend can't connect:
- Check PostgreSQL is running:
lsof -i :5432 - Verify credentials:
psql -h localhost -p 5432 -U sibu -d sibu - Check
.env.developmentfile exists
Flutter can't connect:
- Verify backend is running:
curl http://localhost:8000/health - Check API_BASE_URL is set correctly
- Check browser console for CORS errors