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:
-
Update
backend/internal/database/schema.go:- Add new table creation or ALTER statements
- Use
IF NOT EXISTSfor idempotency
-
Create Migration File (optional, for tracking):
# Create: backend/migrations/006_your_migration.sql -
Test Schema Initialization:
- Drop and recreate database
- Run backend - schema should auto-create
Adding New API Endpoints
- Define Model in
backend/internal/models/models.go - Create Handler in
backend/internal/handlers/ - Register Route in
backend/cmd/api/main.go - 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
- Create Page in
frontend/app/your-page/page.tsx - Create API Client function in
frontend/lib/api.ts - 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
gofmtfor formatting - Use
golangci-lintfor linting - Follow Go best practices
TypeScript/React
- Use Prettier for formatting
- Use ESLint for linting
- Follow React best practices
Flutter/Dart
- Use
dart formatfor formatting - Follow Flutter best practices
Git Workflow
- Create feature branch:
git checkout -b feature/your-feature - Make changes and commit
- Push to remote:
git push origin feature/your-feature - Create pull request
- 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