lib/schemas.ts are the
single source of truth and export inferred types.| Folder | Responsibility |
| — | — |
| app/ | Routes, layouts, route handlers, SEO metadata. The only place Next.js file conventions live. |
| app/(app)/ | Route group for authenticated screens; shares AppShell + error boundary. |
| app/api/ | Edge/Node route handlers. Validate, rate-limit, return typed JSON. |
| components/atoms | Stateless primitives (Button, Input, Badge, Logo, Skeleton, Spinner). |
| components/molecules | Small compositions (StatCard, FormField, OfferRow, NavLink). |
| components/organisms | Feature blocks (Navbar, Footer, Hero, OrderBook, ToastRegion). |
| components/templates | Page skeletons (MarketingLayout, AppShell). |
| components/providers | Client context providers (React Query, Theme). |
| hooks/ | Reusable client hooks; React Query wrappers live here. |
| lib/ | Cross-cutting infra: env, axios client, query client, rate limit, schemas, logger, constants. |
| services/ | Data-access functions. The only layer that talks to lib/api. |
| store/ | Zustand stores for UI/session/toast state. |
| utils/ | Pure, framework-agnostic helpers. Fully unit-tested. |
| types/ | Shared domain + API types. |
| styles/ | CSS variable design tokens consumed by Tailwind. |
OrderBook (organism) calls useCreateTrade().services/trades.service.ts.lib/api.ts).app/api/trades/route.ts rate-limits, validates with createTradeSchema,
and returns a typed Trade.output: 'standalone' for small Docker images.optimizePackageImports for lucide-react and framer-motion.next/font self-hosts Jost/Inter/JetBrains Mono (no layout shift).loading.tsx + Skeleton for perceived performance.staleTime 60s) avoids refetch storms.X-Frame-Options, X-Content-Type-Options, Referrer-Policy,
Permissions-Policy set globally in next.config.js.dangerouslySetInnerHTML.