This document is the working guide for future coding agents on the Lonc frontend.
## Project purpose
Lonc is a lightweight PWA frontend for household kitchen stock and labeling workflows.
The frontend:
- talks to a separate Tryton backend
- uses Tryton user application keys for auth
- is optimized for phone and desktop use
- prefers practical, high-frequency operational UX over generic CRUD
## Core stack
- Vite
- Alpine.js
- Bootstrap 5
- plain `fetch()` API modules
- static PWA assets in `public/`
## General operating procedure
When changing this project, follow this order:
1. Find the existing feature module instead of adding parallel logic.
2. Prefer updating shared API helpers before patching individual pages.
3. Preserve the existing UX language and interaction patterns.
4. Verify with `npm run build`.
For larger behavior changes:
1. Check the relevant API module in `src/api/`
2. Check the page module in `src/features/`
3. Check supporting shared state in `src/app/`
4. Check matching CSS in `src/styles/app.css`
## Key architecture rules
### API usage
- All HTTP requests should go through `src/api/client.js`
- Do not build ad hoc URLs in feature components
- Use `getPath()` and shared API modules in `src/api/`
- Prefer same-origin requests when `baseUrl` is empty
- Keep custom headers minimal
### Auth model
Lonc does not use Tryton JSON-RPC session login.
It uses Tryton user application keys for the `kitchen` application:
1.`POST /{database}/user/application/`
2. store returned key locally
3. user validates key in Tryton preferences
4. frontend verifies with authenticated kitchen request
Relevant session states:
-`not_connected`
-`pending_validation`
-`connected`
-`invalid_key`
If authenticated requests start failing after a key had previously worked, the app should move toward invalid-key handling instead of repeatedly hitting the backend.
### Service worker
- In development, service workers should not stay registered
- In production, avoid sticky caching for JS/CSS
- Be careful when debugging frontend/API mismatches because stale cached bundles have already caused confusion in this project
## Current backend conventions
These are current project assumptions and should not be casually changed.