Frontend Project Structure¶
The Next.js frontend (apps/web/src) follows a feature-based folder structure, combined with Next.js App Router conventions.
Directory Layout¶
Component Organization¶
We strictly separate "UI Components" from "Feature Components".
1. UI Components (src/components/ui/)¶
These are "dumb", highly reusable components like Button, Input, Dialog, mostly generated by shadcn/ui. They have no business logic and do not fetch data.
2. Feature Components (src/components/[domain]/)¶
These are complex, domain-specific components like CreateInvoiceForm or KanbanBoard. - They may contain business logic. - They may fetch data or use custom hooks to interact with the backend API. - They compose multiple UI components together.
3. Layout Components (src/components/layout/)¶
Components that define the structure of the page, such as the global Sidebar, Topbar, or AppShell.
The lib Directory¶
The lib folder contains pure TypeScript logic: - api-client.ts: Configures the global fetch or axios instance, setting the base URL (NEXT_PUBLIC_API_URL) and automatically attaching authentication headers or handling token refreshes. - auth.ts: Wrapper functions around the Better Auth client SDK. - Domain API wrappers: e.g., projects.ts or finance.ts which contain functions like getProjects() or createInvoice() to keep data-fetching logic out of component files.