How dgen-technologies/dgen-ui works
Project Type and Purpose
• DGEN is a full-stack, web-based Bitcoin wallet interface with optional mobile support (via Capacitor/Android).
• It uses SvelteKit for the frontend (SSR + SPA) and serverless API routes, and relies on an external “dgen-server” for Bitcoin/Lightning operations through the Breez SDK.
Main Components
a. Frontend (Browser & Mobile WebView)
• SvelteKit app under src/ (routes, components, lib).
• UI layers: pages in src/routes, reusable components in src/components.
• Local storage, client hooks, and real-time socket events via src/lib/socket.ts.
b. Backend/API (SvelteKit serverless routes)
• Server code in src/routes/api, +server.ts and +page.server.ts handlers.
• Business logic in src/lib/*Service.ts modules: walletService, cryptoService, transactionService, invoice, etc.
• Security modules: sessionManager, rateLimiter, domMonitor under src/lib/security.
c. External Service (“dgen-server”)
• Runs separately; exposes endpoints for on-chain and Lightning operations via the Breez SDK.
• Connects to Bitcoin & Lightning networks.
d. Static Assets & Hosting
• Static files under static/.
• Deployment config: Dockerfiles, docker-compose.yml, Netlify (netlify.toml), Codemagic for CI (codemagic.yaml).
e. Mobile Integration (Android)
• Capacitor plugin under android/ implementing NfcWriterPlugin.
• Bridges web app to native NFC writing capabilities.
Relationships & Data Flows
• User ↔ Browser UI (HTTPS / WebSocket)
• Browser UI ↔ SvelteKit Serverless API (HTTP requests, load hooks)
• Serverless API ↔ dgen-server (HTTP/gRPC)
• dgen-server ↔ Bitcoin & Lightning networks
• Optional: Browser UI ↔ Android native plugin (Capacitor bridge)
Architectural Patterns & Design Principles
• Separation of concerns: UI components vs. page routes vs. service modules.
• Serverless/functions-as-API: each route handler encapsulates data fetching and business logic.
• Layered service modules: cryptoService, cache, walletService, transactionService.
• Security middleware: sessionManager, rateLimiter.
• Real-time updates via WebSocket/socket.io pattern.
• Internationalization: src/locales + guided translation script.