cbb14e69fb5111303a855a828c461d2efebefb93
Job-Info-Prod
Production-ready job information management system for field workers.
Features
- Dual-Token Authentication: PocketBase + Microsoft Graph tokens
- Always-Warm Cache: Background refresh loop keeps tokens fresh
- Offline-First: Works without internet using cached data
- Zero Re-Auth: Users never need to login again after initial auth
Tech Stack
- Runtime: Bun
- Backend: Hono
- Auth: PocketBase + Microsoft OAuth
- Cache: Redis/Valkey via ioredis
- Frontend: TypeScript + Tailwind CSS
Quick Start
# Install dependencies
bun install
# Copy environment file
cp .env.example .env
# Edit .env with your configuration
nano .env
# Start development server
bun run dev
Environment Variables
See .env.example for all required variables:
PORT- Server port (default: 3000)POCKETBASE_URL- PocketBase instance URLMS_CLIENT_ID- Microsoft OAuth client IDMS_CLIENT_SECRET- Microsoft OAuth client secretMS_TENANT_ID- Microsoft tenant IDREDIS_HOST- Redis/Valkey hostREDIS_PORT- Redis/Valkey port
Architecture
┌─────────────────┐ ┌──────────────────┐
│ Frontend │────▶│ Hono Backend │
│ (TypeScript) │◀────│ │
└─────────────────┘ └────────┬─────────┘
│
┌────────────────────────┼────────────────────────┐
▼ ▼ ▼
┌───────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ PocketBase │ │ Redis/Valkey │ │ Microsoft Graph │
│ (Auth+Data) │ │ (Token Cache) │ │ (SharePoint) │
└───────────────┘ └─────────────────┘ └─────────────────┘
Token Refresh Flow
- User completes OAuth flow → tokens stored in localStorage + cache
- Backend starts 30-min refresh loop per user
- Frontend checks backend for fresh tokens every 25 min
- If backend unreachable, frontend uses localStorage cache
- Stale tokens returned as fallback (field workers can't wait)
Scripts
bun run dev- Start development server with watchbun run start- Start production serverbun run build:css- Build Tailwind CSSbun run typecheck- Run TypeScript type checkingbun run test- Run tests
Folder Structure
Job-Info-Prod/
├── backend/
│ └── src/
│ ├── config/ # Environment and constants
│ ├── middleware/ # Auth, logging, error handling
│ ├── routes/ # API route handlers
│ ├── services/ # Business logic
│ └── index.ts # Server entry point
├── frontend/
│ ├── public/ # Static HTML files
│ └── src/
│ ├── auth/ # Auth client
│ ├── components/ # UI components
│ ├── services/ # API clients
│ ├── styles/ # Tailwind CSS
│ └── app.ts # Main app entry
└── shared/
├── constants/ # Shared constants
└── types/ # TypeScript types
License
MIT
Description
Languages
HTML
72.9%
TypeScript
19.4%
JavaScript
7.6%
CSS
0.1%