Move business logic out of App Router into module packages, add boundary validation scripts, and keep all routes as thin re-exports without changing URLs or API behavior. Co-authored-by: Cursor <cursoragent@cursor.com>
3.0 KiB
3.0 KiB
frontend/shared/
Status: Scaffold — code not migrated yet
Phase: Migration Phase 1 (shared architecture creation)
Purpose
Central platform layer for cross-module UI, utilities, and infrastructure. All business modules (Accounting, Beauty, Healthcare, future CRM/Delivery) consume code from here — never the reverse.
Relationship to legacy paths
Existing shared code remains in place until incremental migration (Phase 2+):
| Shared area | Legacy location today | Target |
|---|---|---|
| UI primitives | components/ds/, components/ui/ |
shared/ui/, shared/design-system/ |
| Forms | components/ds/FormControls.tsx |
shared/forms/ |
| Layouts | Portal shells in components/{module}/ |
shared/layouts/ |
| Tables | components/ds/Page.tsx (DataTable) |
shared/tables/ |
| Charts | (not implemented; recharts installed) |
shared/charts/ |
| Calendar | components/ds/DatePicker.tsx |
shared/calendar/ |
| Hooks | hooks/ |
shared/hooks/ |
| Utils | lib/utils.ts |
shared/utils/ |
| API core | lib/auth.ts, fetch patterns in lib/*-api.ts |
shared/api/ |
| Theme | lib/theme.ts, styles/globals.css |
shared/theme/ |
| Providers | components/providers/, ThemeProvider.tsx |
shared/providers/ |
| Icons | lucide-react direct imports |
shared/icons/ |
| Types | scattered | shared/types/ |
| Constants | lib/apps-catalog.ts, env |
shared/constants/ |
| Design system | components/ds/ |
shared/design-system/ |
Subdirectories
| Directory | Documentation |
|---|---|
| ui/ | Low-level UI atoms |
| forms/ | Form primitives and RHF helpers |
| layouts/ | Shells, portal chrome, page scaffolding |
| tables/ | Data tables and toolbars |
| charts/ | Chart wrappers |
| calendar/ | Jalali/Gregorian date pickers |
| hooks/ | Cross-module React hooks |
| utils/ | Pure utilities |
| api/ | Shared fetch client and auth |
| theme/ | White-label theming |
| providers/ | React context providers |
| icons/ | Icon re-exports and mappings |
| types/ | Shared TypeScript types |
| constants/ | App-wide constants |
| design-system/ | Tokens, patterns, composition rules |
Import rules
app/ and modules/ → shared/* ✅
shared/* → modules/* ❌
shared/* → components/{accounting,beauty,healthcare}/* ❌
Phase 1 does not change existing @/components/ds imports. New code may optionally use @/shared/* once migration begins.
Path alias (optional, Phase 1)
"@/shared/*": ["./shared/*"]
Configured in tsconfig.json for future use; legacy @/* imports remain valid.