2.6 KiB
2.6 KiB
Project Structure
Top-level layout
client/: frontend applicationserver/: backend applicationshared/: shared TypeScript contracts, permissions, and utility typesDockerfile: production container builddocker-entrypoint.sh: migration-aware startup script
Frontend rules
- Organize code by domain under
src/modules. - Keep app-shell concerns in
src/app. - Keep reusable UI primitives in
src/components. - Theme state and brand tokens belong in
src/theme. - PDF screen components must remain separate from API-rendered document templates.
- Treat
src/modules/dashboardas a long-lived operational module. New high-level KPI, alert, queue, and shortcut surfaces should compose into it rather than spawning disconnected landing pages. - Any non-filter lookup UI must be implemented as a searchable picker or autocomplete; do not use long static dropdowns for operational datasets such as items, customers, vendors, or document-linked records.
- Inventory items expose both cost and sell price. Downstream sales document entry should default from the item price field rather than requiring duplicate price maintenance.
- Future vendor-facing purchasing flows should follow the same searchable-lookup rule and shared document/totals model already used by sales.
- Purchase-order item pickers must only surface inventory items flagged as purchasable.
- Shipping, sales, and future purchasing PDFs should be rendered through the backend documents module and shared Puppeteer pipeline rather than ad hoc frontend-only exports.
- Preserve the current dense operations UI style on active module pages: compact controls, tighter card padding, and shorter empty states unless a screen has a clear reason to be more spacious.
Backend rules
- Organize domain modules under
src/modules/<domain>. - Keep HTTP routers thin; place business logic in services.
- Centralize Prisma access, auth middleware, and file storage utilities in
src/lib. - Store persistence-related constants under
src/config. - Serve the built frontend from the API layer in production.
Shared package rules
- Place cross-app DTOs, permission keys, enums, and document interfaces in
shared/src. - Keep shared code free of runtime framework dependencies.
Adding a new domain
- Add backend routes, service, and repository/module files under
server/src/modules/<domain>. - Add Prisma models and a migration if the module needs persistence.
- Add permission keys in
shared/src/auth. - Add frontend route/module under
client/src/modules/<domain>. - Register navigation and route guards through the app shell without refactoring existing modules.