How pandoks/homelab-template works
• Client / Frontend: Represent the Svelte components and routes (found in “src/app.html”, “src/routes”, and “src/lib/components”) that form the user interface. This layer handles rendering the UI and routing between pages (login, signup, 2FA, etc.).
• Server / Backend: Represent the SvelteKit server-side code (such as the “+page.server.ts” and “+server.ts” files under various routes) that processes requests, handles authentication logic, orchestrates server-side rendering, and communicates with the database.
• Authentication & Authorization Modules: Highlight the “src/lib/auth” tree that includes various concerns:
• Passkey authentication (with server and utility modules)
• Email verification, password resets, and 2FA facilities
• Postgres integration (found in “src/lib/db/postgres” and its schema definitions)
• Redis integration (likely for caching or sessions, in “src/lib/db/redis”)
• Auxiliary Utilities: Include rate limiting (src/lib/rate-limit) and typical utility functions (src/lib/utils.ts, src/lib/zod.ts for validation) that support the core features.
• External Dependencies & Configuration: Optionally add references to the development tooling and configuration (e.g., Vite, Tailwind, Playwright for tests, Prettier, etc.) which affect the build and development cycle.
Relationships and Interactions
• Within the Server, illustrate how authentication modules are invoked in response to specific routes (login, signup, 2FA routes). Show how these modules interact with both the databases (Postgres for persistent data, and Redis for sessions or caching) and any utility libraries (for rate limiting, validation).
• If applicable, add data flow lines between the server-side modules and external services (e.g., email service for verifications).
Architectural Patterns & Technologies
• That this project follows a modular full‑stack design, with separation between frontend UI (Svelte components/routes) and backend processing (server endpoints and business logic).
• That the SvelteKit router and its “+page” and “+server” files follow a pattern similar to MVC: views (UI components) triggering model operations (database queries and auth logic) through controller-like endpoints.
• Mention that stateful elements such as authentication sessions may be managed with external services (Postgres and Redis) and that various security checks (e.g., password resets, 2FA) are handled via discrete modules.