Troubleshooting
Common issues and solutions when working with the starter app.
Backend Issues
Database Connection Errors
Problem: Connection refused or database does not exist errors
Solutions:
-
Check if PostgreSQL is running:
docker-compose -p starter-app -f common/docker/docker-compose.yml postgres ps -
Restart the database:
docker-compose -p starter-app -f common/docker/docker-compose.yml down postgresdocker-compose -p starter-app -f common/docker/docker-compose.yml up postgres -d -
Verify environment variables:
DB_TYPE=remoteDB_USER=xxxDB_NAME=xxxDB_HOST=xxxDB_PORT=xxxDB_PASSWORD=xxx
Migration Errors
Problem: Target database is not up to date or migration conflicts
Solutions:
-
Check current migration state:
cd commonuv run alembic currentuv run alembic history -
Reset migrations (development only):
# WARNING: This will delete all datacd commonuv run alembic downgrade baseuv run alembic upgrade head -
Fix merge conflicts in migrations:
# Delete conflicting migration filesrm common/alembic/versions/conflicting_migration.py# Generate a new clean migrationuvx invoke create-migration "Merge migration conflicts"uvx invoke update-db
API Endpoint Not Found
Problem: 404 errors when calling API endpoints
Solutions:
-
Verify router is registered:
# In apps/backend/src/main.py, ensure your router is included:from routers import your_routerapp.include_router(your_router.router) -
Check endpoint URL:
# Visit http://localhost:8000/docs to see all available endpoints
Frontend Issues
Type Generation Errors
Problem: TypeScript errors about missing API types
Solutions:
-
Regenerate API types:
# Make sure backend is running firstcd apps/frontendnpm run codegen -
Check backend is accessible:
curl http://localhost:8000/openapi.json
State Management Issues
Problem: Zustand store not updating or state not persisting
Solutions:
-
Check store subscription:
// Make sure you're using the store correctlyconst { data, setData } = useMyStore() // ✅ Subscribes to changesconst store = useMyStore.getState() // ❌ Doesn't subscribe -
Verify store updates:
// Store updates must be immutableset((state) => ({items: [...state.items, newItem] // ✅ Creates new array}))set((state) => {state.items.push(newItem) // ❌ Mutates existing arrayreturn state}) -
Check DevTools:
// Make sure devtools middleware is enabledexport const useMyStore = create<State>()(devtools((set) => ({ /* ... */ })))
Development Environment Issues
Port Already in Use
Problem: EADDRINUSE: address already in use :::8000
Solutions:
- Find and kill the process:
# Find what's using the portlsof -i :8000# Kill the processkill -9 <PID>
Performance Issues
Slow API Responses
Problem: Backend responses are taking too long
Solutions:
-
Check database queries:
# Add database query logging in development and check the execution plan in PG (EXPLAIN ANALYSE [your query])# In common/src/common/services/database_service.pyself._engine = create_async_engine(self._get_database_url(async_url=True), echo=True)# ...Or log a particular queryquery = select(...)print(query)# Look for N+1 queries and missing indexes -
Add database indexes:
# In your models, add indexes to frequently queried fieldsclass Task(TaskBase, table=True):user_id: UUID = Field(foreign_key="user.id", index=True)status: str = Field(index=True) # If you filter by status often -
Use database query optimization:
# Use joinedload for related data to eager load relationsresult = await db.exec(select(Task).options(joinedload(Task.user)))