3.0 KiB
3.0 KiB
Request Lifecycle Flows
1. Auth Sign-In (Admin)
- Browser posts to
/api/auth/sign-in/email. - Route resolves
identifier(email or username) to canonical email. - Better Auth credential sign-in executes.
- Session cookie is set and user is redirected.
Key files:
apps/admin/src/app/login/login-form.tsxapps/admin/src/app/api/auth/[...all]/route.tsapps/admin/src/lib/auth/server.ts
2. Initial Owner Registration
- If no owner exists,
/welcomerenders owner sign-up mode. - Sign-up request goes through auth route handler.
- New user is promoted to owner in transactional guard.
- Owner invariant is re-validated to enforce single owner.
Key files:
apps/admin/src/app/welcome/page.tsxapps/admin/src/app/api/auth/[...all]/route.tsapps/admin/src/lib/auth/server.ts
3. Media Upload
- Admin form posts multipart data to
/api/media/upload. - Metadata is validated and file is stored through selected provider.
- Media asset record is persisted with storage metadata.
- UI redirects back to media list with flash status query.
Key files:
apps/admin/src/components/media/media-upload-form.tsxapps/admin/src/app/api/media/upload/route.tsapps/admin/src/lib/media/storage.tspackages/db/src/media-foundation.ts
4. Page Publish
- Admin submit on
/pagescalls server action. - Page schema validates payload and persists.
publishedstatus sets publication fields.- Public app resolves slug and renders page if published.
Key files:
apps/admin/src/app/pages/page.tsxpackages/db/src/pages-navigation.tsapps/web/src/app/[locale]/[slug]/page.tsx
5. Commission Status Transition
- Admin updates status from commission card form.
- Server action validates transition payload.
- DB update persists new status.
- Kanban view re-renders with updated column placement.
Key files:
apps/admin/src/app/commissions/page.tsxpackages/db/src/commissions.ts
6. Public Commission Request Submission
- Visitor opens
/{locale}/commissionsand submits request form. - Server action validates input through shared schema.
- Existing customer is reused by email (and marked recurring) or a new customer is created.
- A new commission is created in
newstatus and linked to the resolved customer.
Key files:
apps/web/src/app/[locale]/commissions/page.tsxpackages/content/src/commissions.tspackages/db/src/commissions.ts
7. Public Portfolio Rendering
- Visitor opens
/{locale}/portfoliowith optional group filter query. - Public app loads published portfolio groups and filtered published artworks.
- Artwork cards render preferred rendition preview (
card>thumbnail>full). - Image bytes are streamed through web media endpoint using configured storage provider fallback.
Key files:
apps/web/src/app/[locale]/portfolio/page.tsxapps/web/src/app/[locale]/portfolio/[slug]/page.tsxapps/web/src/app/api/media/file/[id]/route.tsapps/web/src/lib/media/storage-read.tspackages/db/src/media-foundation.ts