How sampath0411/cdas-project works
Purpose and Entry Points
This is a Next.js App Router application for recording, managing, analyzing, and exporting equipment-delay data. The root route and layouts establish application-wide rendering; route groups separate authentication from the protected dashboard.
• src/app/page.tsx
• src/app/layout.tsx
• src/app/(auth)/login/page.tsx
Authentication and Access Boundary
Supabase-backed authentication is integrated at client, server, middleware, and admin contexts. Request middleware is the primary route-protection/session-refresh boundary; authenticated application content is organized beneath the dashboard route group. Client-side guards and an auth provider support UI session state.
• middleware.ts
• src/lib/supabase/middleware.ts
• src/lib/supabase/server.ts
• src/components/auth/auth-guard.tsx
• src/providers/auth-provider.tsx
Dashboard Shell and Analytics
The authenticated dashboard layout provides navigation and shared dashboard chrome. Its landing page composes KPI, trend, distribution, recent-entry, and delayed-equipment views, making it the primary reporting/operational overview surface.
• src/app/(dashboard)/layout.tsx
• src/app/(dashboard)/dashboard/page.tsx
• src/components/dashboard/kpi-cards-grid.tsx
• src/components/dashboard/monthly-trends-chart.tsx
• src/components/layout/sidebar.tsx
Delay Recording and Reporting Flow
Users submit delay records through the delay-entry route and its server actions. Delay-report pages render filtering, tabular data, and multiple chart visualizations. Validation defines the input boundary before persistence; delay data can also cross an HTTP export boundary as an API response.
• src/app/(dashboard)/delay-entry/actions.ts
• src/components/delays/delay-entry-form.tsx
• src/app/(dashboard)/delay-reports/page.tsx
• src/components/delays/delay-filters.tsx
• src/app/api/export/delays/route.ts
• src/lib/validations/delay.ts
Equipment Master Data
Equipment management is a separate domain workflow covering equipment, sub-equipment, and shops. The page-level server actions form the mutation boundary, while dialogs and lists supply CRUD-oriented UI for the hierarchy used by delay entry and analysis.
• src/app/(dashboard)/equipment/page.tsx
• src/app/(dashboard)/equipment/actions.ts
• src/components/equipment/equipment-tabs.tsx
• src/components/equipment/sub-equipment-form-dialog.tsx
• src/components/equipment/shop-list.tsx
Administration, Profile, and Preferences
User administration has dedicated actions and role/status presentation. Individual profile and password changes are distinct from broader application settings such as theme and notifications.
• src/app/(dashboard)/users/actions.ts
• src/components/users/users-data-table.tsx
• src/app/(dashboard)/profile/page.tsx
• src/app/(dashboard)/settings/page.tsx
Persistence, Security, and Runtime
The runtime is TypeScript/Next.js with React UI components and server actions/API routes. Supabase is the external backend for authentication and database access; schema migrations, seed data, and row-level security policies are versioned in-repo. An admin Supabase client is a privileged boundary and should remain server-only.
• src/lib/supabase/client.ts
• src/lib/supabase/admin.ts
• supabase/migrations/001_schema.sql
• supabase/migrations/002_rls.sql
• scripts/full-setup.sql
Main entry points: layout.tsx Dashboard shell · server.ts Server Supabase client · middleware.ts Request middleware · actions.ts Delay server actions
Components 21
Next.js Application
App Router routes, layouts, server actions, and API handlers.
- Root app shell
src/app/layout.tsx - Root route
src/app/page.tsx - Dashboard shell · Shared navigation and authenticated application chrome.
src/app/(dashboard)/layout.tsx - Dashboard overview · Composes KPI, trend, distribution, recent-entry, and delay views.
src/app/(dashboard)/dashboard/page.tsx - Profile and settings · Personal profile/password changes and application preferences.
src/app/(dashboard)/profile/page.tsx
Authentication
Session protection and Supabase auth integration.
- Login route
src/app/(auth)/login/page.tsx - Request middleware · Refreshes sessions and enforces protected-route access.
middleware.ts - Middleware auth client
src/lib/supabase/middleware.ts - Auth UI state · Client session state and guarded UI access.
src/providers/auth-provider.tsx
Delay Operations
Recording, reporting, and export of delay data.
- Delay entry form
src/components/delays/delay-entry-form.tsx - Delay server actions
src/app/(dashboard)/delay-entry/actions.ts - Delay validation
src/lib/validations/delay.ts - Delay reports · Filtering, tables, and chart visualizations.
src/app/(dashboard)/delay-reports/page.tsx - Delay export API · Returns delay data across an API boundary.
src/app/api/export/delays/route.ts
Master Data & Admin
Equipment hierarchy and user management workflows.
- Equipment management · Manages equipment, sub-equipment, and shops.
src/app/(dashboard)/equipment/page.tsx - Equipment actions
src/app/(dashboard)/equipment/actions.ts - User administration · Manages user roles and status.
src/app/(dashboard)/users/actions.ts
Supabase Backend
External auth/database service and versioned database policy.
- Server Supabase client · Server-side application access to Supabase.
src/lib/supabase/server.ts - Admin Supabase client · Server-only privileged administrative access.
src/lib/supabase/admin.ts - Supabase service
- Schema and RLS migrations · Versioned schema and row-level security definitions.
supabase/migrations/002_rls.sql
Connections 22
- Root app shell → Root route: renders
- Root app shell → Auth UI state: provides session state
- Request middleware → Middleware auth client: uses
- Middleware auth client → Supabase service: refreshes session
- Request middleware → Login route: redirects unauthenticated
- Request middleware → Dashboard shell: permits authenticated
- Dashboard shell → Dashboard overview: hosts
- Dashboard shell → Delay entry form: hosts
- Dashboard shell → Delay reports: hosts
- Dashboard shell → Equipment management: hosts
- Dashboard shell → Profile and settings: hosts
- Delay entry form → Delay server actions: submits
- Delay server actions → Delay validation: validates with
- Delay server actions → Server Supabase client: persists through
- Delay reports → Server Supabase client: queries through
- Delay export API → Server Supabase client: exports queried data
- Equipment management → Equipment actions: mutates through
- Equipment actions → Server Supabase client: persists through
- User administration → Admin Supabase client: uses privileged access
- Server Supabase client → Supabase service: accesses
- Admin Supabase client → Supabase service: admin access
- Schema and RLS migrations → Supabase service: defines schema and RLS