| name | fb-frontend |
| description | Frontend development guide for the Family Budget project. Use this skill whenever you're writing, editing, or debugging TypeScript/JavaScript frontend code, Jinja2 templates, or CSS in this project โ adding new features, implementing UI components, fixing bugs in existing pages (facts, plan, dashboard, lists), or wiring up API calls and WebSocket handlers. Trigger on: "add button", "create modal", "implement filter", "fix table", "new page", "update template", "CSS issue", "TypeScript error", "bundle", "window.X is not a function", "onclick not working".
|
| version | 2.0.0 |
| author | Family Budget Team |
| tags | ["frontend","typescript","tailwind","daisyui"] |
| user-invocable | true |
Family Budget โ Frontend Development
Stack
| Layer | Technology |
|---|
| Bundler | Vite 6 โ 41 separate IIFE bundles |
| Language | TypeScript (strict, ES2020) |
| CSS | Tailwind CSS 3 + DaisyUI 4 |
| Templates | Jinja2 (server-side) |
| DB (offline) | Dexie 4 (IndexedDB) |
| Real-time | WebSocket via window.budgetWSClient |
Build Commands
npm run type-check
npm run bundle
npm run build:css
npm run build
FORCE_REBUILD=true npm run bundle
File Map
frontend/web/
โโโ static/
โ โโโ css/
โ โ โโโ tailwind-daisyui.min.css โ generated, don't edit
โ โ โโโ daisyui-overrides.css โ conflict fixes + fb-* classes
โ โ โโโ custom.css โ feature-specific styles
โ โ โโโ [feature].css โ per-feature (plan.css, lists.css)
โ โโโ js/
โ โโโ [feature]/ โ feature bundle (facts/, plan/, etc.)
โ โโโ modules/uiComponents/ โ reusable UI helpers
โ โโโ utils/ โ shared utilities
โ โโโ data/ โ API + Dexie data layer
โโโ templates/
โโโ base.html โ master layout (extend this)
โโโ [page].html โ page templates
โโโ components/ โ Jinja2 macros (modals, forms)
โโโ partials/[feature]/ โ feature-specific fragments
Feature Folder Structure
Every page feature follows this layout. facts/ is the canonical reference:
js/[feature]/
โโโ index.ts โ entry point, init order matters (see references/patterns.md)
โโโ core/
โ โโโ [Feature]State.ts โ state interface + createInitialState()
โ โโโ stateManager.ts โ getState() / updateState()
โโโ operations/ โ business logic, table rendering, CRUD
โโโ integration/
โ โโโ [feature]API.ts โ fetch() calls to /api/v1/...
โ โโโ wsEventHandlers.ts โ WebSocket subscriptions
โโโ adapters/
โ โโโ windowExports.ts โ ALL onclick-callable functions go here
โ โโโ eventDelegation.ts โ data-action routing
โโโ features/ โ complex sub-components (modals, widgets)
โโโ types/
โโโ models.ts
โโโ globals.d.ts โ window.* type declarations
Key Rules (read these first)
- No
console.log โ use debugLog() from utils/logger.ts (pre-commit blocks it)
- All onclick functions must go through
adapters/windowExports.ts โ never inline on window
- IIFE bundles can't share module state โ cross-bundle calls go through
window.*
FORCE_REBUILD=true needed when editing imported (non-entry) modules โ hash cache won't detect transitive changes
- CSS load order is fixed: tailwind-daisyui โ daisyui-overrides โ custom โ feature CSS
Reference Files
Load only what you need:
| Task | Read |
|---|
| Implementing onclick handlers / window exports | references/patterns.md#window-exports |
| Setting up state management | references/patterns.md#state |
| Adding WebSocket handlers | references/patterns.md#websocket |
| Writing API calls | references/patterns.md#api |
| Adding a new page or feature bundle | references/new-feature.md |
| Writing or editing Jinja2 templates / modals | references/templates.md |
| CSS โ DaisyUI, custom classes, responsive | references/css.md |
| Writing unit or E2E tests | references/testing.md |