Skip to main content

Development Workflow

Starting Development

# Terminal 1: Backend
cd backend
go run cmd/api/main.go

# Terminal 2: Frontend
cd frontend
npm run dev

# Terminal 3: Admin Frontend (if needed)
cd admin_frontend
npm run dev

Database Changes

When modifying database schema:

  1. Update backend/internal/database/schema.go:

    • Add new table creation or ALTER statements
    • Use IF NOT EXISTS for idempotency
  2. Create Migration File (optional, for tracking):

    # Create: backend/migrations/006_your_migration.sql
  3. Test Schema Initialization:

    • Drop and recreate database
    • Run backend - schema should auto-create

Adding New API Endpoints

  1. Define Model in backend/internal/models/models.go
  2. Create Handler in backend/internal/handlers/
  3. Register Route in backend/cmd/api/main.go
  4. Add Middleware if needed (auth, admin, etc.)

Example

// In handlers/example.go
func ExampleHandler(w http.ResponseWriter, r *http.Request) {
// Handler logic
}

// In cmd/api/main.go
r.Get("/example", handlers.ExampleHandler)

Frontend Development

  1. Create Page in frontend/app/your-page/page.tsx
  2. Create API Client function in frontend/lib/api.ts
  3. Add Components in frontend/components/

Testing

Backend Testing

cd backend
go test ./...

Frontend Testing

cd frontend
npm test

Building for Production

Backend

cd backend
go build -o backend.exe cmd/api/main.go # Windows
go build -o backend cmd/api/main.go # Linux/Mac

Frontend

cd frontend
npm run build
npm start # Production server

Mobile Apps

# Android
flutter build apk --release

# iOS
flutter build ios --release

Code Quality

Go

  • Use gofmt for formatting
  • Use golangci-lint for linting
  • Follow Go best practices

TypeScript/React

  • Use Prettier for formatting
  • Use ESLint for linting
  • Follow React best practices

Flutter/Dart

  • Use dart format for formatting
  • Follow Flutter best practices

Git Workflow

  1. Create feature branch: git checkout -b feature/your-feature
  2. Make changes and commit
  3. Push to remote: git push origin feature/your-feature
  4. Create pull request
  5. Code review and merge

Debugging

Backend

  • Check logs in console output
  • Use debugger in IDE
  • Check database directly

Frontend

  • Use browser DevTools
  • Check Network tab for API calls
  • Check Console for errors

Mobile Apps

  • Use Flutter DevTools
  • Check device logs
  • Use debug mode