Local Development¶
Use this setup when you want fast iteration, debugging, and direct access to backend/frontend processes.
flowchart LR
A[Prepare env] --> B[Run PostgreSQL]
B --> C[Start backend]
C --> D[Start frontend]
D --> E[Run optional agent]
E --> F[Verify login and wake flow]
style A fill:#2563eb,stroke:#1e3a8a,color:#fff
style F fill:#16a34a,stroke:#166534,color:#fff
Prerequisites¶
- Python 3.13+
- Node.js 20+
- PostgreSQL 16+
- Git
Who should use this
Choose Local Development if you are implementing features, debugging routes, or iterating on frontend and backend together.
1. Clone and Configure¶
Create root environment file:
Linux/macOS:
PowerShell:
2. Start PostgreSQL¶
Ensure PostgreSQL is running and create a powerbeacon database with user credentials matching your DB_URL.
Recommended local URL:
3. Run Backend (FastAPI)¶
From repository root:
Alternatively, using pip:
Backend URLs:
- API:
http://localhost:8000 - Swagger:
http://localhost:8000/api/docs - Health:
http://localhost:8000/health
4. Run Frontend (Vite)¶
Open a second terminal from repository root:
Frontend URL:
http://localhost:5173
If needed, configure API base URL in frontend environment to point at http://localhost:8000.
Fast frontend loop
Keep backend and frontend in separate terminals to preserve hot reload on both sides.
5. Agent Development (Optional)¶
From repository root:
Build local binaries:
6. Verification Checklist¶
- Backend health endpoint returns
ok. - Frontend loads without runtime errors.
- Login works.
- Device list API returns data.
- Wake action request is accepted by backend.
Useful Commands¶
Backend formatting and linting:
Frontend lint/build:
Agent tests:
Troubleshooting¶
CORS issues in browser¶
Confirm backend CORS allows http://localhost:5173 or your active frontend origin.
DB connection errors¶
Confirm PostgreSQL is running and DB_URL points to correct host, user, password, and database.
Frontend cannot reach backend¶
- Confirm backend is running on port
8000. - Confirm frontend API base URL is set correctly.
- Check browser network tab for failing requests.
Authentication problems¶
For local mode, verify:
For OIDC, verify issuer/client settings in .env and that provider endpoints are reachable.
Token confusion
If login behavior seems inconsistent, clear localStorage in the browser and retry. Stale JWTs commonly cause misleading UI states.
Next Step¶
Return to Setup Overview or continue to architecture docs.