Skip to content

A modern React admin dashboard built with TypeScript, Vite, and Tailwind CSS. It features code-splitting with React.lazy and Suspense, efficient data fetching using TanStack Query, and a clean, modular architecture. The app includes paginated tables, CRUD forms, and reusable components, with routing managed by React Router.

Notifications You must be signed in to change notification settings

4rn4vk/Admin-Dashboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Admin Dashboard

A modern, full-stack admin dashboard built with React, TypeScript, and Vite. Features a responsive layout with navigation, user management, assessment tracking, and analytics dashboard with mock API integration. Optimized with lazy-loaded routes, virtualized lists, and Web Vitals monitoring.

πŸš€ Features

  • Responsive Design β€” Mobile-first layout with collapsible navigation
  • User Management β€” View and manage user accounts
  • Assessment Tracking β€” Create, view, and manage assessments with paginated tables
  • Dashboard Analytics β€” Overview of key metrics and statistics
  • Lazy-Loaded Routes β€” Code splitting for optimal initial load performance
  • Efficient Tables β€” Paginated tables for assessments and users
  • Mock API β€” Built-in Express server for development
  • React Query β€” Efficient data fetching and caching
  • Toast Notifications β€” User-friendly feedback system
  • Dark/Light Theme Toggle β€” Switch between dark and light themes from the header; Tailwind configured for class-based dark mode

πŸ› οΈ Technologies Used

Frontend

  • React 18 β€” UI library
  • TypeScript β€” Type-safe development
  • Vite β€” Fast build tool and dev server
  • React Router β€” Client-side routing with lazy-loaded components
  • TanStack Query (React Query) β€” Server state management
  • Tailwind CSS β€” Utility-first CSS framework
  • (note) react-window was explored but removed from the assessments table due to table/tbody compatibility; the app uses paginated standard tables.

Backend

  • Express.js β€” Node.js web framework
  • CORS β€” Cross-origin resource sharing
  • TypeScript β€” Type-safe backend

Development Tools

  • Vitest β€” Unit testing framework
  • Testing Library β€” React component testing
  • ESLint β€” Code linting (flat config)
  • Prettier β€” Code formatting
  • Husky β€” Git hooks
  • lint-staged β€” Pre-commit checks

Deployment

  • Docker β€” Containerization
  • Fly.io β€” Platform for deployment

πŸ“‹ Prerequisites

  • Node.js 18+ and npm
  • (Optional) Docker for containerized deployment

βš™οΈ Setup & Installation

  1. Clone the repository

    git clone <repository-url>
    cd admin-dashboard
  2. Install dependencies

    npm install
  3. Start the development server (Vite dev server on port 5173)

    npm run dev

    The app will open at http://localhost:5173

  4. Start the mock API server (in a separate terminal on port 3001)

    npm run api

    API endpoints: http://localhost:3001

  5. Verify the setup

    • Frontend should be running at http://localhost:5173
    • API should be running at http://localhost:3001
    • Navigation menu shows Dashboard, Assessments, and Users routes
    • Lazy-loaded routes will show loading spinner on first navigation

πŸ“œ Available Scripts

Development

  • npm run dev β€” Start Vite dev server with HMR
  • npm run api β€” Start mock Express API server
  • npm run build β€” Create optimized production build
  • npm run preview β€” Preview production build locally

Testing & Quality

  • npm test β€” Run Vitest once with verbose reporter (suitable for CI, equivalent to npx vitest run --reporter verbose)
  • npm run test:watch β€” Run Vitest in interactive watch mode (developer workflow)

Vitest is configured to only include project tests β€” src/**/*.test.{ts,tsx} β€” and explicitly excludes node_modules and e2e/.

  • npm run coverage β€” Run tests with coverage report
  • npm run lint β€” Run ESLint on all files
  • npm run typecheck β€” Run TypeScript type checking
  • npm run format β€” Check Prettier formatting
  • npm run format:write β€” Apply Prettier formatting fixes

Storybook

  • npm run storybook β€” Start Storybook dev server
  • npm run build-storybook β€” Build Storybook static site

E2E Testing

  • npm run test:e2e β€” Run Playwright end-to-end tests

πŸš€ Quick Start

# Install and run everything
npm install

# Terminal 1: Frontend dev server
npm run dev

# Terminal 2: Mock API server
npm run api

# Terminal 3 (optional): Watch tests
npm test

Then navigate to http://localhost:5173 in your browser.

πŸ“Š Performance Optimizations

Lazy-Loaded Routes

Routes are code-split using React.lazy() and Suspense:

  • Dashboard β€” Loads on demand at /dashboard
  • Assessments β€” Loads on demand at /assessments
  • Users β€” Loads on demand at /users

This reduces initial bundle size and improves Time to Interactive (TTI).

Assessments Table

The Assessments page renders a paginated, sortable table with create/edit/delete flows and server-driven pagination. Note: react-window was explored for virtualization but removed after it proved incompatible with <table>/<tbody> semantics β€” pagination and standard rendering are used for compatibility and accessibility.

Key behaviors:

  • Sorting by column headers
  • Pagination controls for navigating pages
  • Modal form for create & edit actions (AssessmentForm)
  • Confirmation-driven deletes and toast notifications

Code Splitting

The production build automatically splits code into:

  • index.js β€” Main app shell
  • Dashboard.js β€” Dashboard page chunk
  • Assessments.js β€” Assessments page chunk
  • Users.js β€” Users page chunk

πŸ“ Project Structure

admin-dashboard/
β”œβ”€β”€ api/
β”‚   └── server.ts              # Express mock API server
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ api/                   # API client functions
β”‚   β”‚   β”œβ”€β”€ assessments.ts
β”‚   β”‚   β”œβ”€β”€ client.ts
β”‚   β”‚   β”œβ”€β”€ dashboard.ts
β”‚   β”‚   β”œβ”€β”€ health.ts
β”‚   β”‚   └── users.ts
β”‚   β”œβ”€β”€ assets/                # Static assets
β”‚   β”œβ”€β”€ components/            # Reusable components
β”‚   β”‚   β”œβ”€β”€ AssessmentForm.tsx
β”‚   β”‚   β”œβ”€β”€ Layout.tsx         # Main layout with nav
β”‚   β”‚   β”œβ”€β”€ Modal.tsx
β”‚   β”‚   └── ToastContainer.tsx
β”‚   β”œβ”€β”€ contexts/              # React context providers
β”‚   β”‚   └── ToastContext.tsx
β”‚   β”œβ”€β”€ lib/                   # Libraries and utilities
β”‚   β”‚   β”œβ”€β”€ queryClient.ts
β”‚   β”‚   └── performanceMetrics.ts (optional)
β”‚   β”œβ”€β”€ pages/                 # Page components (lazy-loaded)
β”‚   β”‚   β”œβ”€β”€ Dashboard.tsx
β”‚   β”‚   β”œβ”€β”€ Assessments.tsx    # Virtualized table
β”‚   β”‚   └── Users.tsx
β”‚   β”œβ”€β”€ App.tsx                # Main app component
β”‚   β”œβ”€β”€ main.tsx               # Entry point with routing
β”‚   └── index.css
β”œβ”€β”€ e2e/                       # Playwright E2E tests
β”œβ”€β”€ Dockerfile                 # Docker configuration
β”œβ”€β”€ fly.toml                   # Fly.io deployment config
β”œβ”€β”€ vite.config.ts             # Vite + Vitest config
└── package.json               # Dependencies and scripts

πŸ§ͺ Testing

Unit & Component Tests

npm test
  • Tests located in src/ alongside components
  • Uses Vitest and Testing Library
  • Accessibility checks using axe-core (see src/App.a11y.test.tsx) β€” axe runs in the Vitest environment and the color-contrast rule is disabled by default to avoid jsdom false positives
  • Jest-DOM matchers in src/setupTests.ts
  • Watch mode enabled by default

Coverage Reports

npm run coverage

Generates coverage reports in coverage/ directory.

E2E Tests

npm run test:e2e

Playwright tests are located in the e2e/ directory and include flows for Dashboard, Assessments (listing, create modal, error handling) and Users (listing and filters). The Playwright config includes a webServer entry so the dev server (npm run dev) is started automatically when running npm run test:e2e locally; you don't need to start the dev server manually. Use npx playwright show-report to open the last HTML report.

πŸ”’ Git Hooks

Husky automatically enforces quality checks:

# Pre-commit hook runs:
- ESLint (zero warnings)
- Prettier format check
- lint-staged on staged files

All checks must pass before committing.

🐳 Docker

Build and run containerized:

# Build image
docker build -t admin-dashboard .

# Run container
docker run -p 5173:5173 -p 3001:3001 admin-dashboard

Access at http://localhost:5173

πŸš€ Deployment

Fly.io

Configuration in fly.toml. Deploy with:

# Install Fly CLI: https://fly.io/docs/getting-started/installing-flyctl/
fly deploy

Vercel

Configuration in vercel.json. Deploy from Git or:

# Install Vercel CLI
npm i -g vercel
vercel

πŸ“ Notes

  • ESLint uses modern flat config (eslint.config.mts)
  • Vitest configured in vite.config.ts
  • TailwindCSS dark theme with custom color tokens
  • React Query client in src/lib/queryClient.ts
  • Lazy routes with loading UI in src/main.tsx
  • Paginated tables with standard rendering (react-window removed from src/pages/Assessments.tsx for compatibility)

🀝 Contributing

  1. Create a feature branch
  2. Make changes
  3. Ensure all tests pass: npm test
  4. Ensure no lint errors: npm run lint
  5. Format code: npm run format:write
  6. Commit (git hooks will validate)
  7. Open a pull request

πŸ“„ License

This project is private and not licensed for public use.

About

A modern React admin dashboard built with TypeScript, Vite, and Tailwind CSS. It features code-splitting with React.lazy and Suspense, efficient data fetching using TanStack Query, and a clean, modular architecture. The app includes paginated tables, CRUD forms, and reusable components, with routing managed by React Router.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages