A comprehensive network traffic analysis dashboard built with React, TypeScript, and Vite.
Frontend: Deployed to Cloudflare Pages (CDN, global distribution)
Backend: Runs on Raspberry Pi 5 (packet capture, database, API)
This architecture simplifies deployment and improves performance by serving the frontend from Cloudflare's edge network while keeping the backend on your local Raspberry Pi for packet capture and data processing.
📖 Deployment Guide: See docs/CLOUDFLARE_DEPLOYMENT.md for detailed Cloudflare Pages deployment instructions.
- Real-time network traffic monitoring
- Advanced analytics and visualization
- Geographic distribution mapping
- Protocol breakdown and analysis
- Security posture monitoring
- Anomaly detection
- Node.js 20 or higher
- npm or yarn
# Install dependencies
npm install
# Start development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run previewThe application uses environment variables to configure API connections and behavior.
Create a .env file in the project root (see .env.example for a template):
# Enable/disable real API mode
# Set to 'true' to connect to backend API, 'false' to use mock data
VITE_USE_REAL_API=false
# Backend API Base URL
# Default: http://localhost:8000
# For Raspberry Pi: http://<raspberry-pi-ip>:8000
VITE_API_BASE_URL=http://localhost:8000| Variable | Description | Default | Required |
|---|---|---|---|
VITE_USE_REAL_API |
Enable real backend API mode (true/false) |
false |
No |
VITE_API_BASE_URL |
Backend API server URL | http://localhost:8000 |
No |
Validate your environment configuration:
npm run validate:envThis script will:
- Check that all environment variables are set correctly
- Validate URL formats
- Warn about missing or incorrect configurations
- Provide setup tips
Mock Data Mode (Default):
- Set
VITE_USE_REAL_API=falseor omit the variable - Application uses generated mock data
- Works completely offline
- Useful for development and testing UI
Real API Mode:
- Set
VITE_USE_REAL_API=true - Set
VITE_API_BASE_URLto your backend server URL - Connects to Raspberry Pi 5 backend or local backend
- Requires backend to be running
- Provides real-time data via WebSocket
Local Development (Mock Data):
VITE_USE_REAL_API=falseLocal Development (Backend on same machine):
VITE_USE_REAL_API=true
VITE_API_BASE_URL=http://localhost:8000Raspberry Pi Backend:
VITE_USE_REAL_API=true
VITE_API_BASE_URL=http://192.168.1.100:8000Frontend: Deployed to Cloudflare Pages (CDN, global distribution)
Backend: Runs on Raspberry Pi 5 (packet capture, database, API, all processing)
This architecture simplifies deployment and improves performance by serving the frontend from Cloudflare's edge network while keeping all backend components (database, packet capture, processing) on your local Raspberry Pi for optimal privacy, performance, and cost.
Why keep everything on Pi?
- Packet Capture: Requires direct network interface access (cannot run on Cloudflare)
- Database: Privacy (data stays local), performance (<1ms vs 100-500ms), cost ($0 vs egress fees)
- Real-time Processing: Needs low latency for immediate packet analysis
- See docs/ARCHITECTURE_DECISION_DATABASE.md for detailed analysis
📖 Deployment Guide: See docs/CLOUDFLARE_DEPLOYMENT.md for detailed Cloudflare Pages deployment instructions.
📖 Enhanced Deployment: See docs/ENHANCED_DEPLOYMENT.md for automated CI/CD setup.
📖 Custom Domain: See docs/CUSTOM_DOMAIN_SETUP.md to set upnet.andernet.dev.
📖 Migration Guide: See docs/MIGRATION_TO_CLOUDFLARE.md if migrating from Docker deployment.
This project is configured for deployment to Cloudflare Pages.
-
Create a Cloudflare API Token:
- Go to Cloudflare Dashboard
- Click "Create Token"
- Use "Edit Cloudflare Workers" template or create custom token with:
- Account.Cloudflare Pages:Edit
- Zone.Zone:Read (if using custom domains)
- Copy the token
-
Get your Cloudflare Account ID:
- Go to Cloudflare Dashboard
- Your Account ID is shown in the right sidebar
-
Configure GitHub Secrets:
- Go to your GitHub repository
- Navigate to Settings → Secrets and variables → Actions
- Add the following secrets:
CLOUDFLARE_API_TOKEN: Your Cloudflare API tokenCLOUDFLARE_ACCOUNT_ID: Your Cloudflare Account ID
Once configured, the project will automatically deploy:
- Production: Pushes to
mainormasterbranch - Preview: Pull requests to
mainormasterbranch
The GitHub Actions workflow will:
- Build the project using
npm run build - Deploy the
distdirectory to Cloudflare Pages - Create preview deployments for pull requests
You can also deploy manually using Wrangler CLI:
# Install Wrangler globally (if not already installed)
npm install -g wrangler
# Login to Cloudflare
wrangler login
# Build the project
npm run build
# Deploy to Cloudflare Pages
wrangler pages deploy dist --project-name=net-trafficThe project uses a comprehensive testing strategy:
- Unit Tests: Run on every push and PR (must pass for deployment)
- E2E Tests: Run on push to main/master with 4 workers for fast parallel execution
- Don't block deployment if they fail (results still saved)
- Not run on PRs to save CI time
- Nightly Tests: Full test suite runs every night at 2 AM UTC
See docs/TESTING_STRATEGY.md for complete testing documentation.
Comprehensive documentation is available in the project:
- Raspberry Pi 5 Quick Start - ⚡ Get started in 15 minutes!
- USER_GUIDE.md - Complete user guide with getting started, features, and troubleshooting
- AGENT_INSTRUCTIONS.md - Instructions for AI agents and developers
- INTEGRATION_GUIDE.md - Frontend-backend integration guide
- PERFORMANCE_OPTIMIZATIONS.md - Performance optimization guide
- TESTING_STRATEGY.md - Complete testing strategy and workflows
- TESTING_SETUP.md - Vitest and integration testing setup
- UNIT_TESTING_SUMMARY.md - Summary of unit tests and coverage
- E2E Tests Guide - Playwright E2E testing guide
- ROADMAP.md - Development roadmap and phases
- REMAINING_TASKS.md - Current task list with priorities
- DOCUMENTATION_INDEX.md - Complete documentation index
See DOCUMENTATION_INDEX.md for a full list of all documentation files.
├── src/
│ ├── components/ # React components
│ ├── lib/ # Utilities and types
│ ├── hooks/ # Custom React hooks
│ └── styles/ # CSS styles
├── .github/
│ ├── workflows/ # GitHub Actions workflows
│ └── ISSUE_TEMPLATE/ # Issue templates
├── .vscode/ # VS Code workspace settings
├── src/ # Source code
└── vite.config.ts # Vite build configuration
vite.config.ts: Vite build settingseslint.config.js: ESLint configuration.prettierrc.json: Prettier formatting rules.github/workflows/: CI/CD pipelines- See WORKSPACE_CONFIG.md for detailed configuration guide
The Spark Template files and resources from GitHub are licensed under the terms of the MIT license, Copyright GitHub, Inc.