app/, components/, and lib/.
Overview
App Router directory
Theapp/ directory contains all routes, layouts, and API endpoints following Next.js 16 App Router conventions.
Key features
- Role-based routing: Separate dashboards for employees and admins
- Nested layouts: Dashboard uses nested layout for consistent sidebar/navigation
- API routes: Better Auth endpoint at
/api/auth/* - Public pages: Landing pages for companies, about, salaries, and job listings
Components directory
Components are organized by feature and context, following a hierarchical structure from common to specific.Organization principles
Feature-based grouping
Feature-based grouping
Components are grouped by the feature or page they belong to (
landing/home/, dashboard/employee/), making it easy to find related components.Reusable UI layer
Reusable UI layer
The
ui/ directory contains base components from Radix UI and shadcn, providing accessible, composable primitives.Common components
Common components
Shared components like
Header, Footer, and LogoutButton live in common/ and are used across multiple pages.Library directory
Thelib/ directory contains core configuration, utilities, and type definitions.
Key files
Authentication (auth.ts, auth-client.ts)
Authentication (auth.ts, auth-client.ts)
auth.ts: Server-side Better Auth configuration with database pool, rate limiting, and session settingsauth-client.ts: Client-side auth client with typed hooks (useSession,signIn,signOut)
Database (db/)
Database (db/)
index.ts: Shared PostgreSQL connection pool with connection limits and timeout configurationmigrations/: SQL migration files for schema management- Query modules for specific features (e.g.,
waitlist.ts)
Static data (data/)
Static data (data/)
JSON-like data files for jobs, categories, and filters used throughout the app.
Type definitions (types/)
Type definitions (types/)
TypeScript interfaces and types organized by feature, ensuring type safety across the codebase.
Utilities (utils.ts)
Utilities (utils.ts)
Helper functions for common operations like currency formatting (CLP), date handling, and badge color generation.
Configuration files
Best practices
- Feature-based organization: Group related files by feature rather than file type
- Shared utilities in lib/: Keep configuration and utilities centralized in
lib/ - Type safety: Define TypeScript types in
lib/types/for all data structures - Component hierarchy: Follow the pattern
common/→ui/→landing/→dashboard/ - Migrations: Store all database schema changes in
lib/db/migrations/