innercontext/frontend/README.md
Piotr Oleszczyk e29d62f949 feat(frontend): auto-generate TypeScript types from backend OpenAPI schema
Replace manually maintained types in src/lib/types.ts with auto-generated
types from FastAPI's OpenAPI schema using @hey-api/openapi-ts. The bridge
file re-exports generated types with renames, Require<> augmentations for
fields that are optional in the schema but always present in responses, and
manually added relationship fields excluded from OpenAPI.

- Add openapi-ts.config.ts and generate:api npm script
- Generate types into src/lib/api/generated/types.gen.ts
- Rewrite src/lib/types.ts as bridge with re-exports and augmentations
- Fix null vs undefined mismatches in consumer components
- Remove unused manual type definitions from api.ts
- Update AGENTS.md docs with type generation workflow
2026-03-12 09:17:40 +01:00

2.2 KiB

innercontext — frontend

SvelteKit web UI for innercontext. Provides a browser interface for managing skincare products, routines, health data, and skin condition snapshots.

Stack

  • Framework: SvelteKit 2, Svelte 5 (Runes)
  • Language: TypeScript
  • Styles: Tailwind CSS v4
  • Components: shadcn-svelte (bits-ui)
  • Adapter: @sveltejs/adapter-node (required — uses +page.server.ts form actions)

Development

# Install dependencies
pnpm install

# Start dev server (API proxied to localhost:8000)
pnpm dev

The backend must be running at http://localhost:8000. See ../backend/ for setup instructions.

Environment variables

Variable Description Default
PUBLIC_API_BASE Base URL of the FastAPI backend http://localhost:8000

Set PUBLIC_API_BASE at build time for production:

PUBLIC_API_BASE=http://innercontext.lan/api pnpm build

Building for production

pnpm build
# Output: build/

Run the production server:

node build/index.js

Or use the provided systemd service: ../systemd/innercontext-node.service.

Routes

Route Description
/ Dashboard
/products Product list
/products/new Add product
/products/[id] Product detail / edit
/routines Routine list
/routines/new Create routine
/routines/[id] Routine detail
/health/medications Medications
/health/lab-results Lab results
/skin Skin condition snapshots

Key files

File Purpose
src/lib/api.ts API client (typed fetch wrappers)
src/lib/types.ts Type bridge (re-exports from generated OpenAPI types)
src/app.css Tailwind v4 theme + global styles
svelte.config.js SvelteKit config (adapter-node)