Skip to main content

Overview

The Product Distribution Dashboard frontend is built with Angular 18, using standalone components and modern Angular patterns. This guide covers the setup process for local development.

Prerequisites

Node.js and npm

  • Node.js: Version 18.x or higher
  • npm: Version 9.x or higher (comes with Node.js)
Verify your installation:
node --version
npm --version

Angular CLI

Install the Angular CLI globally:
npm install -g @angular/[email protected]
Verify the installation:
ng version

Installation

Navigate to the frontend directory and install dependencies:
cd frontend
npm install

Project Structure

The frontend follows Angular’s standard structure with path aliases for clean imports:
frontend/
├── src/
│   ├── app/
│   │   ├── services/          # HTTP and business logic services
│   │   ├── models/            # TypeScript interfaces and types
│   │   ├── pipes/             # Custom pipes for data formatting
│   │   ├── utils/             # Utility functions
│   │   ├── dashboard-map/     # Map visualization component
│   │   ├── dashboard-table/   # Table view component
│   │   ├── dashboard-metrics/ # Metrics display components
│   │   ├── dashboard-filters/ # Filter controls component
│   │   ├── dashboard-tabs/    # Tab navigation component
│   │   ├── app.component.ts   # Root component
│   │   └── app.config.ts      # Application configuration
│   ├── environments/          # Environment-specific configs
│   ├── styles.scss           # Global styles
│   └── main.ts               # Application entry point
├── angular.json              # Angular workspace configuration
├── tsconfig.json            # TypeScript configuration
└── package.json             # Dependencies and scripts

Path Aliases

The project uses TypeScript path aliases for cleaner imports:
import { ProductService } from '@services/product.service';
import { Product } from '@models/product.model';
import { FormatNumberPipe } from '@pipes/format-number.pipe';
import { formatNumber } from '@utils/format-number.util';

Dependencies

Core Dependencies

  • @angular/core: ^18.0.0 - Angular framework
  • @angular/common: ^18.0.0 - Common Angular utilities
  • @angular/forms: ^18.0.0 - Form handling
  • @angular/router: ^18.0.0 - Routing (not currently used)
  • rxjs: ~7.8.0 - Reactive programming library

UI Component Libraries

  • @angular/cdk: ^18.2.14 - Component Dev Kit (virtual scrolling)
  • @ng-select/ng-select: ^13.9.1 - Dropdown select components

Visualization Libraries

  • leaflet: ^1.9.4 - Interactive maps
  • leaflet.markercluster: ^1.5.3 - Map marker clustering
  • leaflet-polylinedecorator: ^1.6.0 - Route decorations
  • chart.js: ^4.5.1 - Charting library
  • ng2-charts: ^7.0.0 - Angular wrapper for Chart.js

Development Dependencies

  • @angular/cli: ^18.0.4 - Angular command-line tools
  • typescript: ~5.4.2 - TypeScript compiler
  • eslint: ^9.39.1 - Code linting
  • prettier: ^3.7.3 - Code formatting
  • jasmine-core: ~5.1.0 - Testing framework
  • karma: ~6.4.0 - Test runner

npm Scripts

Development

# Start development server (http://localhost:4200)
npm start

# Start with watch mode for continuous builds
npm run watch

Building

# Production build
npm run build

# Output: dist/frontend/

Code Quality

# Run ESLint
npm run lint

# Format code with Prettier
npm run format

# Check formatting without changes
npm run format:check

Testing

# Run unit tests with Karma
npm test

Development Server

Starting the Server

Start the development server:
npm start
The application will be available at http://localhost:4200. The development server includes:
  • Hot Module Replacement: Changes reload automatically
  • Source Maps: Debug TypeScript code in the browser
  • Error Overlay: Clear error messages in the browser

Configuration

The development server is configured in angular.json:
"serve": {
  "builder": "@angular-devkit/build-angular:dev-server",
  "configurations": {
    "development": {
      "buildTarget": "frontend:build:development"
    }
  },
  "defaultConfiguration": "development"
}

API Connection

The frontend connects to the backend API using environment configuration:
// src/environments/environment.ts
export const environment = {
  production: false,
  apiUrl: 'http://localhost:3000/api'
};
Ensure the backend is running before starting the frontend development server.

TypeScript Configuration

The project uses strict TypeScript settings for type safety:
  • strict: true - Enable all strict type checking options
  • noImplicitReturns: true - Require explicit return types
  • noFallthroughCasesInSwitch: true - Prevent switch fallthrough
  • strictTemplates: true - Strict template type checking

Browser Support

The application targets modern browsers with ES2022 support:
  • Chrome (latest)
  • Firefox (latest)
  • Safari (latest)
  • Edge (latest)

Next Steps

Build docs developers (and LLMs) love