Initial commit: SIBU 2.0 MISSION
This commit is contained in:
116
old/QUICK-START-POSTGRESQL.md
Normal file
116
old/QUICK-START-POSTGRESQL.md
Normal file
@ -0,0 +1,116 @@
|
||||
# Quick Start: PostgreSQL Setup
|
||||
|
||||
## ✅ What's Been Configured
|
||||
|
||||
1. **Backend Database Connection**: Configured to use `postgresql+asyncpg://sibu:sibu@localhost:5432/sibu`
|
||||
2. **Environment File**: Created `backend/.env.development` with database settings
|
||||
3. **API Client**: Created Flutter `ApiClient` service for backend communication
|
||||
4. **Run Scripts**: Created helper scripts for easy execution
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
### 1. Ensure PostgreSQL is Running
|
||||
|
||||
```bash
|
||||
# Check if PostgreSQL is running
|
||||
psql -h localhost -p 5432 -U sibu -d sibu -c "SELECT version();"
|
||||
```
|
||||
|
||||
If it fails, start PostgreSQL:
|
||||
```bash
|
||||
# macOS with Homebrew
|
||||
brew services start postgresql@14 # or your version
|
||||
```
|
||||
|
||||
### 2. Create Database (if needed)
|
||||
|
||||
```bash
|
||||
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:
|
||||
|
||||
```bash
|
||||
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):
|
||||
```bash
|
||||
cd backend
|
||||
uv run alembic upgrade head
|
||||
```
|
||||
|
||||
### 4. Start Backend API
|
||||
|
||||
```bash
|
||||
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:
|
||||
|
||||
```bash
|
||||
cd old
|
||||
./scripts/run-flutter-backend.sh
|
||||
```
|
||||
|
||||
Or manually:
|
||||
```bash
|
||||
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
|
||||
```bash
|
||||
psql -h localhost -p 5432 -U sibu -d sibu -c "\dt" # List tables
|
||||
```
|
||||
|
||||
### Test Backend API
|
||||
```bash
|
||||
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.md` for detailed documentation
|
||||
- Update Flutter services to use `ApiClient` instead of `SupabaseService` (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.development` file 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
|
||||
|
||||
Reference in New Issue
Block a user