Repository navigation
[F0] Scaffold React/Vite web client with auth wired to the API - #26
Merged
Merged
Conversation
added 2 commits
July 14, 2026 21:11
The scaffold is backend-only (JSON API + Postgres + Traefik) with no frontend. MVP is not shippable to a farmer as a bare API, so Phase 1.0 now includes a React/Vite SPA in web/ consuming the JSON API: login, daily-entry capture, stock view, customers, sales order flow, and list/history screens. Adds §6 item 10 and a Sprint UI block in §7.
First frontend: React 19 + Vite 6 + TS SPA in web/, consuming the existing JSON API. No mock — login/refresh/logout hit /api/v1/auth. - Vite dev proxy forwards /api to the backend (VITE_API_TARGET, default :8080), keeping the SPA same-origin so the API needs no CORS for dev. - api/client.ts: typed fetch wrapper, bearer auth, single-flight refresh-and-retry on 401, drops session to /login when refresh fails. - auth/: localStorage token store, AuthContext, useAuth. - routes/: Login (real POST /auth/login), ProtectedRoute guard, AppLayout shell with nav + sign-out, Dashboard, placeholders for the daily-entry/stock/sales screens (#21/#22/#23). Verified: npm run build (tsc -b + vite build) passes clean. End-to-end login needs the seeded admin user from #5 (startup migrate + seed).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #20. First frontend for Cluckwork — the scaffold was backend-only.
What
React 19 + Vite 6 + TypeScript SPA in
web/, consuming the existing JSON API. Auth is wired to the real API (no mock): login/refresh/logout hit/api/v1/auth.vite.config.ts): forwards/api/*to the backend (VITE_API_TARGET, default:8080), so the SPA is same-origin — the API needs no CORS for local dev.api/client.ts: typed fetch wrapper, bearer auth, single-flight refresh-and-retry on 401; drops the session and bounces to/loginwhen refresh fails.auth/: localStorage token store,AuthContext,useAuth.routes/:Login(realPOST /auth/login),ProtectedRouteguard,AppLayoutshell (nav + sign-out),Dashboard, and placeholders for the daily-entry / stock / sales screens ([F1] Daily-entry capture screen (by grade) #21/[F2] Stock-by-grade view #22/[F3] Customers + sales order flow #23).Verification
npm run build(tsc -b+vite build) passes clean — 50 modules, strict TS, 0 errors.Follow-up dependency
End-to-end login needs a user to sign in with. There is no seeded user and migrations are not applied on startup. That scope was folded into #5 (startup migrate + seed default farm/house/admin user). Until #5 lands, log in via Swagger / the integration-test seed path.
Contract used
Migrated from Gitea PR #26 (https://gitea.mforcelabs.com/mforce/cluckwork/pulls/26).