How lazyjerry/pro-dig-studio works
Project Type and Purpose
• This is a full-stack, serverless edge application built on Cloudflare Workers using Hono as the routing framework.
• Purpose: Provide authenticated CRUD services for worklogs, quotes, meetings, labor reports, notebooks, and external link management; render HTML/PDF templates; and serve a static frontend.
File Structure
• Top level:
• public/ – Static assets (HTML, CSS, JS) served to the browser
• src/ – All TypeScript code for the Workers runtime
• sql/init.sql – D1 database schema migrations
• wrangler.jsonc/package.json/tsconfig.json – Configuration, dependencies, build
• Inside src/:
• index.ts – Hono application entry point, environment bindings (D1, KV, Secrets)
• libs/ – Reusable modules (JWT issuance/verification, config loader, common middleware)
• routes/ – Route handlers and auth middleware (authRequired.ts, data.ts, worklogs.ts)
• templates/ – Dynamic HTML/PDF templates (e.g. labor.html+labor.ts)
Extract Key Architecture from the README
• Edge platform: Cloudflare Workers
• Database: D1 (SQLite-compatible)
• Cache/kv: Cloudflare KV Namespace for sessions or speed caching
• Secrets: JWT_SECRET for signing tokens
• Framework: Hono for routing and middleware
• Frontend: Static JSON import/export, PDF download, WebAuthn authentication
Components & Interactions (
a. Main Components:
• Browser/Client: Initiates HTTP(S) requests (static pages, API calls, WebAuthn flows)
• Cloudflare Workers (Hono App)
• Static file handler (serves public/*)
• Route handlers: /, /auth*, /data*, /worklogs*, /cache*
• Middleware layer: JWT + Cookie auth (authRequired.ts)
• D1 Database: Persistent SQL storage for items, worklogs, users
• KV Namespace: Fast key–value store for session or temporary data
• Secrets: JWT_SECRET binding for token operations
• External Systems (implicit): WebAuthn authenticators in browser, PDF renderer built via HTML templates
b. Relationships & Data Flows:
1. Browser → Worker
• GET /dashboard.html, /labor/index.html → Static assets served from public/
• POST /webauthn/register or /webauthn/login → Hono route → KV & D1
• API calls (/data, /worklogs) → Hono route → D1 writes/reads
2. Worker (Hono) → D1
• CRUD statements prepared in data.ts and worklogs.ts
3. Worker → KV
• Session data or WebAuthn challenge storage
4. Worker Middleware
• authRequired.ts inspects cookies, JWT_SECRET, KV to allow/block
5. Worker → Browser
• JSON responses, HTML views via templates/*.ts, PDF streams
c. Architectural Patterns & Principles:
• Serverless at the edge: single Hono app handles both static and dynamic routes
• Middleware for cross-cutting concerns (authentication, JSON parsing)
• Layered structure: Controllers (routes) → Services (libs) → Data layer (D1/KV) → Templates
• Environment binding for resources: all I/O abstracted behind c.env.DB, c.env.KV, c.env.JWT_SECRET
d. Key Technologies & Libraries:
• Cloudflare Workers + Wrangler (deployment)
• Hono framework (TypeScript)
• D1 (SQLite) & KV Namespaces
• JSON Web Tokens + WebAuthn (no-password auth)
• Static assets in public/ (TailwindCSS, vanilla JS)