Skip to content

adamxrodriguez/nextjs-dashboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Dayboard Hub - Portfolio Customization

Dayboard Hub is a yacht management application built on Next.js 15 with React 19, featuring document management, crew scheduling, and financial reporting. This project has been evolved from a tutorial template into a portfolio-ready application with enterprise-grade features.

🎯 Custom Portfolio Features

This project has been enhanced beyond the base template with the following custom implementations:

βœ… Feature Flags System

Location: app/lib/utils.ts

  • Env-based feature toggles for experimental pages
  • Flags: ENABLE_EXPERIMENTAL_DASHBOARD, ENABLE_ANALYTICS_PAGE, ENABLE_OBSERVABILITY_PAGE
  • Integrated into navigation for conditional rendering

βœ… Role-Based Access Control (RBAC)

Location: middleware.ts, app/lib/definitions.ts

  • Middleware-based RBAC with admin/user roles
  • Admin-only route protection at /dashboard/admin
  • Dynamic role checking in authentication flow

βœ… Edge Caching with Stale-While-Revalidate

Location: app/api/public/data/route.ts, app/public/page.tsx

  • Public API route with edge caching strategy
  • SWR (Stale-While-Revalidate) implementation for optimal performance
  • Cache-Control headers: s-maxage=60, stale-while-revalidate=120

βœ… Per-Route Loading States & Error Boundaries

Locations:

  • app/dashboard/customers/loading.tsx & error.tsx
  • app/dashboard/observability/loading.tsx & error.tsx
  • app/public/loading.tsx & error.tsx
  • All routes have skeleton loaders and comprehensive error handling

βœ… Web Vitals Observability Dashboard

Location: app/dashboard/observability/page.tsx

  • Real-time Core Web Vitals monitoring using next/web-vitals
  • Metrics: FCP, LCP, FID, INP, CLS, TTFB
  • Color-coded performance ratings (good/needs-improvement/poor)
  • Client-side rendering with feature flag protection

βœ… Comprehensive Testing Suite

Locations: tests/, playwright.config.ts, vitest.config.ts

Playwright E2E Tests (tests/example.spec.ts)

  • Homepage navigation and content validation
  • Public route caching verification
  • Feature flag behavior testing
  • Responsive design checks (mobile & desktop)
  • Cross-browser testing (Chrome, Firefox, Safari)

Vitest Component Tests

  • Component rendering (tests/components/card-skeleton.test.tsx)
  • Utility function validation (tests/utils.test.ts)
  • Feature flag system testing (tests/components/feature-flags.test.ts)
  • 80%+ coverage target

βœ… CI/CD Configuration

Location: .github/workflows/ (to be created)

  • GitHub Actions for automated testing
  • Playwright E2E test runs
  • Vitest coverage reports
  • Build verification on pull requests

πŸ“‹ Template vs Custom

Base Template Features (Unchanged)

  • βœ… Next.js App Router architecture
  • βœ… PostgreSQL database integration via Vercel Postgres
  • βœ… Next-Auth authentication
  • βœ… Invoice and customer management CRUD
  • βœ… Revenue charting and analytics
  • βœ… Responsive Tailwind CSS design
  • βœ… Form validation with Zod

Custom Additions (Portfolio Work)

  • βœ… Feature flag system with env-based toggles
  • βœ… RBAC middleware for route protection
  • βœ… Edge caching with SWR strategy
  • βœ… Comprehensive loading states per route
  • βœ… Global and per-route error boundaries
  • βœ… Web Vitals observability dashboard
  • βœ… Full E2E test coverage with Playwright
  • βœ… Component unit tests with Vitest
  • βœ… CI/CD pipeline configuration

πŸš€ Getting Started

Prerequisites

  • Node.js >=20.12.0
  • PostgreSQL database (Vercel Postgres recommended)

Installation

# Install dependencies
yarn install

# Set up environment variables
cp .env.example .env.local

# Configure your environment variables
# See .env.example for required variables

Environment Variables

# Database
POSTGRES_URL=your_postgres_url
POSTGRES_PRISMA_URL=your_postgres_prisma_url
POSTGRES_URL_NON_POOLING=your_postgres_non_pooling_url

# Auth
AUTH_SECRET=your_auth_secret_generate_with_openssl

# Public URL
NEXT_PUBLIC_BASE_URL=http://localhost:3000

# Feature Flags
ENABLE_EXPERIMENTAL_DASHBOARD=false
ENABLE_ANALYTICS_PAGE=false
ENABLE_OBSERVABILITY_PAGE=true

Running the Application

# Development server
yarn dev

# Build for production
yarn build

# Start production server
yarn start

Running Tests

# Run all tests
yarn test

# Watch mode for development
yarn test:watch

# Playwright E2E tests
yarn test:e2e

# Coverage report
yarn test:coverage

πŸ—οΈ Architecture

File Structure

nextjs-dashboard/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   └── public/
β”‚   β”‚       └── data/
β”‚   β”‚           └── route.ts          # Edge-cached API
β”‚   β”œβ”€β”€ dashboard/
β”‚   β”‚   β”œβ”€β”€ (overview)/
β”‚   β”‚   β”œβ”€β”€ customers/
β”‚   β”‚   β”‚   β”œβ”€β”€ loading.tsx           # Custom skeleton
β”‚   β”‚   β”‚   β”œβ”€β”€ error.tsx             # Error boundary
β”‚   β”‚   β”‚   └── page.tsx
β”‚   β”‚   └── observability/
β”‚   β”‚       β”œβ”€β”€ loading.tsx
β”‚   β”‚       β”œβ”€β”€ error.tsx
β”‚   β”‚       └── page.tsx              # Web vitals dashboard
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   └── utils.ts                  # Feature flags
β”‚   β”œβ”€β”€ login/
β”‚   β”œβ”€β”€ public/
β”‚   β”‚   β”œβ”€β”€ loading.tsx
β”‚   β”‚   β”œβ”€β”€ error.tsx
β”‚   β”‚   └── page.tsx                  # SWR example
β”‚   └── ui/
β”œβ”€β”€ middleware.ts                     # RBAC implementation
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ example.spec.ts              # Playwright tests
β”‚   β”œβ”€β”€ setup.ts
β”‚   └── utils.test.ts
β”œβ”€β”€ playwright.config.ts
β”œβ”€β”€ vitest.config.ts
└── package.json

πŸ§ͺ Testing Strategy

Playwright E2E Tests

  • Coverage: Critical user flows, navigation, feature flags
  • Browsers: Chrome, Firefox, Safari
  • CI: Runs on every PR

Vitest Unit Tests

  • Coverage Target: 80%+
  • Focus: Utilities, components, feature flags
  • Fast: Runs in parallel, watch mode supported

Test Commands

yarn test              # Run all Vitest tests
yarn test:watch        # Watch mode
yarn test:e2e          # Playwright E2E tests
yarn test:coverage     # Generate coverage report

🎨 Key Technical Decisions

  1. Feature Flags: Simple env-based approach for flexibility without external services
  2. RBAC: Middleware-level for early route protection
  3. Caching: SWR at API level for optimal performance
  4. Error Handling: Per-route error boundaries for granular UX
  5. Testing: Playwright + Vitest for comprehensive coverage
  6. Observability: Client-side Web Vitals for real-time metrics

πŸ“Š Performance Features

  • Edge caching with stale-while-revalidate
  • Route-level loading states (no layout shift)
  • Optimized bundle splitting
  • Core Web Vitals monitoring
  • Progressive enhancement

πŸ” Security Features

  • Middleware-based RBAC
  • Role-based route protection
  • Authenticated API routes
  • Secure environment variables
  • Next-Auth secure sessions

πŸ“ License

This project is built on the Next.js Learn Dashboard template and customized for portfolio purposes.

πŸ™ Acknowledgments

  • Base template: Next.js Learn Dashboard
  • UI: Tailwind CSS
  • Auth: Next-Auth
  • Database: Vercel Postgres
  • Testing: Playwright & Vitest

Releases

No releases published

Packages

No packages published