Skip to content

๐Ÿ•น๏ธ DevOps Demo Application - Frontend

React TypeScript Vite Chakra UI

The frontend of our DevOps demo application is a modern, responsive web interface built with cutting-edge technologies:

๐Ÿ’ป Table of Contents

โœจ Features

  • Modern React with Hooks: Functional components and React hooks
  • Type-safe Development: Full TypeScript integration
  • Responsive Design: Mobile-first approach with Chakra UI
  • Efficient Data Fetching: TanStack Query for API interactions
  • Declarative Routing: Type-safe routing with TanStack Router
  • Dark/Light Mode: Built-in theme support
  • Authentication: JWT-based authentication flow

๐Ÿ“ Requirements

  • Node.js 18+ (use nvm or fnm for version management)
  • pnpm (recommended package manager for faster, more efficient builds)
  • Docker (optional, for containerized development)

๐Ÿ”ง Development Setup

Docker-based Development

The easiest way to get started is using Docker Compose from the project root:

# From the project root directory
docker compose up -d

This will start:

  • Frontend at http://dashboard.localhost
  • Backend API at http://api.localhost
  • Database and other services

Local Development

For a more responsive development experience, you can run the frontend locally.

  1. Node.js Version Management

Before you begin, ensure that you have either the Node Version Manager (nvm) or Fast Node Manager (fnm) installed:

# Install fnm (recommended)
# macOS with Homebrew
brew install fnm

# Or install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
  1. Install Dependencies
# Navigate to frontend directory
cd frontend

# Use the correct Node.js version
fnm use    # or: nvm use

# Install dependencies
pnpm install
  1. Start Development Server
pnpm dev

The development server will start at http://localhost:5173 with hot module replacement enabled.

๐Ÿ“‚ Project Structure

frontend/
โ”œโ”€โ”€ public/              # Static assets
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ api/              # API client and hooks
โ”‚   โ”œโ”€โ”€ components/       # Reusable UI components
โ”‚   โ”œโ”€โ”€ features/          # Feature-specific components
โ”‚   โ”œโ”€โ”€ hooks/             # Custom React hooks
โ”‚   โ”œโ”€โ”€ lib/               # Utilities and helpers
โ”‚   โ”œโ”€โ”€ providers/         # Context providers
โ”‚   โ”œโ”€โ”€ routes/            # Application routes
โ”‚   โ”œโ”€โ”€ theme/             # Chakra UI theme customization
โ”‚   โ”œโ”€โ”€ types/             # TypeScript type definitions
โ”‚   โ”œโ”€โ”€ App.tsx            # Main application component
โ”‚   โ””โ”€โ”€ main.tsx           # Application entry point
โ”œโ”€โ”€ .eslintrc.js         # ESLint configuration
โ”œโ”€โ”€ package.json         # Dependencies and scripts
โ”œโ”€โ”€ tsconfig.json        # TypeScript configuration
โ””โ”€โ”€ vite.config.ts        # Vite configuration

๐Ÿงช Testing

The frontend includes a test suite using Vitest and React Testing Library:

# Run tests
npm test

# Run tests with coverage
npm test -- --coverage

# Run tests in watch mode
npm test -- --watch

๐Ÿ’พ Building for Production

To create a production build:

npm run build

The build output will be in the dist directory. You can preview the production build locally:

npm run preview

๐Ÿš€ Deployment

The frontend is designed to be deployed as a static site or as a Docker container. The deployment is handled automatically by GitHub Actions when changes are pushed to the appropriate branches.

Environment Variables

The frontend uses environment variables for configuration. In development, these are defined in .env.development. For production, they are injected during the build process.

Key environment variables:

Variable Purpose Example
VITE_API_URL Backend API URL https://api.example.com
VITE_APP_ENV Application environment production

For more information on the deployment process, see the CI/CD Pipeline section in the main README.