Local Development Setup

Get your ApiTraffic development environment running locally.

Prerequisites

  • Node.js (v18+ recommended)
  • npm or yarn
  • Git
  • Docker (optional, for containerized development)

Installation

  1. Clone the repository:
git clone https://github.com/apitraffic/platform.git
cd platform
  1. Install dependencies:
npm install

Development Options

Run all services locally with npm for maximum development speed:
# Run all services concurrently
npm run dev

# Or run services individually
npm run dev:api       # API server on port 8081
npm run dev:processor # Background processor
npm run dev:relay     # Relay service on port 8082
npm run dev:ui        # UI with Vite hot reloading on port 8080

Option 2: Docker Development

Run all services in Docker with volume mounts for live reloading:
# Using Docker Compose
docker-compose -f docker-compose.dev.yml up -d

# Or using direct Docker run
docker run -d --name apitraffic-dev \
  -p 8080:8080 -p 8081:8081 -p 8082:8082 \
  -e SERVICES=all \
  -e NODE_ENV=development \
  --env-file .env.local \
  -v $(pwd)/apps:/app/apps \
  -v $(pwd)/libs:/app/libs \
  apitraffic

Environment Configuration

Create your local environment file:
.env.local
NODE_ENV=local
VITE_APP_ENV=local
DATABASE_URL=postgresql://user:pass@localhost:5432/apitraffic
API_TRAFFIC_TOKEN=your-dev-token
API_TRAFFIC_BUCKET=your-dev-bucket

Available Scripts

  • npm run dev - Start all services in development mode
  • npm run local - Start all services with local configuration
  • npm run build - Build all applications
  • npm run test - Run tests
  • npm run lint - Lint the codebase
  • npm run format - Format code using Prettier

Project Structure

apitraffic-app/
├── apps/                    # Applications
│   ├── api/                 # Main API server
│   ├── processor/           # Background processor
│   ├── relay/               # Traffic relay service
│   └── ui/                  # Frontend application
├── libs/                    # Libraries
│   ├── shared/              # Shared libraries
│   └── client-libraries/    # Client SDK libraries
└── docs/                    # Documentation

Making Changes

  1. Create a new branch for your feature
  2. Make your changes
  3. Run tests: npm test
  4. Run linting: npm run lint
  5. Submit a pull request

Debugging

For VS Code debugging, use the provided launch configurations in .vscode/launch.json.
# Debug specific service
npm run dev:api    # Then attach debugger to port 9229