feat: add profile screen and update routing; enhance login validation and logout functionality
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
# Teknisk Beskrivning - Flutter Frontend
|
||||
|
||||
Detta dokument beskriver vad som ar byggt, arkitekturval och teknisk kontext for Flutter-frontenden.
|
||||
Malgrupp: utvecklare och AI-assistent i denna chat.
|
||||
|
||||
Relaterade dokument:
|
||||
- [next_steps_flutter.md](next_steps_flutter.md)
|
||||
- [flutter/README.md](flutter/README.md)
|
||||
|
||||
## Syfte
|
||||
- Isolerad Flutter-baserad frontend i separat Docker-service.
|
||||
- Web forst, men med arkitektur som kan ateranvandas for Android/iOS.
|
||||
- Stegvis migrering av funktioner fran befintlig Next.js-frontend.
|
||||
|
||||
## Vad som ar gjort
|
||||
- Ny compose override: [compose.flutter.yml](compose.flutter.yml).
|
||||
- Ny Flutter-service: `recipe-flutter`.
|
||||
- Service ansluten till natverk:
|
||||
- `recipe-internal` (backend access)
|
||||
- `proxy` (external Caddy reachability)
|
||||
- Flutter-container serverar web build via intern Caddy.
|
||||
- Exponering via extern Caddy med site `test.gynther.se` -> `recipe-flutter:5000`.
|
||||
- API anrop gar same-origin via `/api` och proxas internt till `recipe-api:8080`.
|
||||
|
||||
## Arkitektur
|
||||
### Lager
|
||||
- Presentation: skarmar och widgets i `flutter/lib/features/*/presentation`.
|
||||
- State/Application: Riverpod providers/notifiers i `flutter/lib/features/*/data`.
|
||||
- Data/API: `ApiClient` i `flutter/lib/core/api`.
|
||||
- Platform abstraction: token storage interface i `flutter/lib/core/platform`.
|
||||
|
||||
### Routing
|
||||
- GoRouter i [flutter/lib/core/router/app_router.dart](flutter/lib/core/router/app_router.dart).
|
||||
- Nuvarande routes:
|
||||
- `/login`
|
||||
- `/recipes`
|
||||
- `/profile`
|
||||
|
||||
### Auth
|
||||
- Login endpoint: `POST /api/auth/login`.
|
||||
- Backend kontrakt anvander `username` + `password`.
|
||||
- Token-falt i svar: `accessToken`.
|
||||
- Token lagras via `ITokenStorage` (web implementation med SharedPreferences).
|
||||
|
||||
### Recipes
|
||||
- Recipes endpoint: `GET /api/recipes`.
|
||||
- Flutter model ar hardad for backend-falt (`name` fallback till `title`) och null-safe parsing.
|
||||
|
||||
## Drift och deploy
|
||||
### Build/run
|
||||
- Build argument i compose: `API_BASE_URL=/api`.
|
||||
- Build command:
|
||||
- `docker compose -f compose.yml -f compose.flutter.yml build recipe-flutter`
|
||||
- Run command:
|
||||
- `docker compose -f compose.yml -f compose.flutter.yml up -d --no-deps recipe-flutter`
|
||||
|
||||
### Viktiga verifieringar
|
||||
- Compose merge valid:
|
||||
- `docker compose -f compose.yml -f compose.flutter.yml config`
|
||||
- Container reachable from external Caddy:
|
||||
- `docker exec caddy wget -S -O- http://recipe-flutter:5000`
|
||||
- Public endpoint:
|
||||
- `curl -I https://test.gynther.se`
|
||||
|
||||
## Viktiga beslut
|
||||
- `compose.yml` lamnas orord; Flutter ligger i separat override-fil.
|
||||
- Flutter-web anvander same-origin API (`/api`) for att undvika mixed-content.
|
||||
- Intern Caddy i Flutter-container hanterar static hosting + `/api` proxy.
|
||||
- Feature migration sker stegvis enligt [next_steps_flutter.md](next_steps_flutter.md).
|
||||
|
||||
## Kanda fallgropar
|
||||
- Om `recipe-flutter` inte ar i `proxy` natverket blir det 502 fran extern Caddy.
|
||||
- Om browser visar gammal JS kan gamla API-URL:er leva kvar i cache/service worker.
|
||||
- Login med email fungerar inte om backend forvantar username.
|
||||
|
||||
## Nasta tekniska steg
|
||||
Fortsatt migrering enligt prioritering i [next_steps_flutter.md](next_steps_flutter.md):
|
||||
1. Auth parity (session behavior refinements).
|
||||
2. Recipes parity (list -> detail -> create/edit).
|
||||
3. Inventory and meal plan pages.
|
||||
4. Profile/admin parity.
|
||||
Reference in New Issue
Block a user