A self-hostable openpilot data backend built with Bun, TypeScript, and SQLite.
Database & Models:
- SQLite database with
bun:sqlite(native, fast, no ORM needed) UserandDevicemodels with static methods for database operations- WAL mode enabled for better performance
API Endpoints:
GET /v1/me- Returns authenticated user infoGET /v1/me/devices- Returns user's devicesGET /v1.1/devices/:dongleId- Returns specific device infoGET /auth/login/:provider- OAuth login (Google/GitHub redirects)GET /auth/callback/:provider- OAuth callback handler
Features:
- Bearer token authentication (user ID as token for now)
- Proper error handling (401, 404, 400 responses)
- TypeScript with full type safety
- Comprehensive test suite (8 tests, all passing)
- Hot reload development server
To install dependencies:
bun installSet up environment variables:
cp .env.example .envUpdate .env with your OAuth client IDs:
GOOGLE_CLIENT_ID: Your Google OAuth client IDGITHUB_CLIENT_ID: Your GitHub OAuth client ID
To run:
bun --hot index.ts # Start server
./test.sh # Run full test suiteStatus: Backend is ready for web app integration. OAuth still needs actual token exchange implementation, and you'll need to add proper JWT tokens and device registration endpoints when ready to connect openpilot devices.