Veevvo Developer Documentation

Architecture Overview

System Architecture

The Verse Proxy system is a modern microservices-based solution for Wialon IPS protocol testing and message processing:

  • Web Interface - Modern web-based testing interface with real-time monitoring
  • WebSocket Proxy - Real-time communication bridge (port 8080)
  • Connection Tracker - Real-time connection monitoring with WebSocket (port 8081)
  • TCP Socket Server - Wialon IPS protocol handling (port 3031)
  • Main Application - Core business logic and HTTP API (port 3030)
  • Kafka Infrastructure - Message broker with UI (ports 9092, 8082)
  • Redis - Connection state storage and caching (port 6379)

Data Flow

Message flow through the Kafka-based system:

  1. Web Browser → WebSocket Proxy (port 8080)
  2. WebSocket Proxy → TCP Socket Server (port 3031)
  3. TCP Socket Server → Kafka Topics (port 9092)
  4. Kafka → Connection Tracker Service
  5. Connection Tracker → Redis (port 6379)
  6. Connection Tracker → WebSocket Clients (port 8081)

Connection Tracker Service

Overview

The Connection Tracker Service provides real-time monitoring of TCP connections and device status. It integrates with Kafka for message processing and Redis for state storage.

  • Real-time Monitoring - Live connection tracking via WebSocket
  • Kafka Integration - Processes connection events from main app
  • Redis Storage - Stores connection state and device information
  • WebSocket API - Real-time updates to web clients

Features

  • Connection Events - Track new, update, and remove events
  • Device Information - Store IP, port, and device details
  • Real-time Updates - WebSocket notifications to clients
  • Health Monitoring - Built-in health checks and status reporting

WebSocket API

// Connect to Connection Tracker WebSocket
const ws = new WebSocket('ws://localhost:8081');

// Listen for connection events
ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  console.log('Connection event:', data);
};

// Event types: 'new', 'update', 'remove'
// Data includes: socketId, serverId, deviceInfo, timestamp

End-to-End Testing

Test Infrastructure

The project includes comprehensive E2E testing using Playwright:

  • Playwright Tests - Cross-browser testing framework
  • Mobile Testing - Responsive design validation
  • WebSocket Testing - Real-time connection validation
  • Docker Integration - Container-based testing

Test Scripts

  • run-all-e2e-tests.sh - Complete E2E test suite
  • run-comprehensive-tests.sh - Extended testing scenarios
  • test-system.sh - System health validation
  • veevvo-e2e-tests.spec.js - Main test specifications

Test Coverage

# Core Functionality Tests
- Web interface loading and navigation
- TCP connection testing
- WebSocket communication
- Connection tracking
- Mobile responsiveness
- Error handling

# Integration Tests
- Kafka message processing
- Redis state management
- Docker service communication
- Cross-service data flow

Port Configuration

Port Service Description Access
80 Web Interface (Nginx) Main web testing interface http://localhost
8080 WebSocket Proxy WebSocket to TCP bridge ws://localhost:8080
8081 Connection Tracker WebSocket Real-time connection monitoring ws://localhost:8081
3030 Main Application (HTTP) Health checks and API endpoints http://localhost:3030
3031 TCP Socket Server Wialon IPS protocol handling localhost:3031
9092 Kafka Message broker protocol Internal only
8082 Kafka UI Web-based topic management http://localhost:8082
6379 Redis Connection state storage Internal only
2181 Zookeeper Kafka coordination service Internal only

Veevvo Protocol

Message Types

  • Login: #L#123456789012345;password
  • Data: #D#010120;120000;5544.6025;N;03739.6834;E;35;215;100;8;1.2;0;0;0;0;0
  • Short Data: #S#010120;120000;5544.6025;N;03739.6834;E;35;215;100;8;1.2;0;0;0;0;0
  • Black Box: #B#010120;120000;5544.6025;N;03739.6834;E;35;215;100;8;1.2;0;0;0;0;0
  • Custom: #C#010120;120000;5544.6025;N;03739.6834;E;35;215;100;8;1.2;0;0;0;0;0

Acknowledgments

All messages receive acknowledgments:

  • Login Ack: #AL#123456789012345
  • Data Ack: #AL#010120;120000;5544.6025;N;03739.6834;E;35;215;100;8;1.2;0;0;0;0;0

Development Commands

Local Development

# Install dependencies
npm install

# Start all services with Docker
npm run docker:up
./scripts/docker-manager.sh start all

# Start main application
npm run start

# Development mode with auto-reload
npm run dev

# Start specific services
npm run start --workspace=@verse-proxy/connection-tracker
npm run start --workspace=@verse-proxy/main-app

Testing Commands

# Run all tests
npm run test:all

# Run E2E tests
npm run test:e2e
./run-all-e2e-tests.sh

# Run comprehensive tests
./run-comprehensive-tests.sh

# Test system health
./test-system.sh

# Test TCP connection
./scripts/connection-checker.sh tcp localhost 3031

# Test HTTP endpoints
./scripts/connection-checker.sh http localhost 3030

Docker Management

Docker Manager Script

# Start all services
./scripts/docker-manager.sh start all

# Start specific service
./scripts/docker-manager.sh start main-app
./scripts/docker-manager.sh start connection-tracker

# Stop all services
./scripts/docker-manager.sh stop all

# Check service status
./scripts/docker-manager.sh status

# View logs
./scripts/docker-manager.sh logs main-app
./scripts/docker-manager.sh logs connection-tracker

Manual Docker Commands

# Start infrastructure (Kafka, Redis)
docker-compose -f config/docker/infrastructure/docker-compose.yml up -d

# Start main application
docker-compose -f services/main-app/docker-compose.yml up -d

# Start connection tracker
docker-compose -f services/connection-tracker/docker-compose.yml up -d

# Start web interface
docker-compose -f apps/web-interface/docker-compose.yml up -d

# Rebuild containers
docker-compose build --no-cache

Project Structure

verse-proxy/
├── libs/ # Shared libraries
│ ├── socket/ # TCP socket library
│ ├── logger/ # Logging utilities
│ ├── protocol/ # Protocol handling (Kafka-based)
│ ├── utils/ # Common utilities
│ └── redis/ # Redis utilities
├── services/ # Microservices
│ ├── main-app/ # Main application service
│ │ ├── docker-compose.yml # Main app Docker config
│ │ └── Dockerfile
│ ├── connection-tracker/ # Connection tracking service
│ │ ├── docker-compose.yml # Connection tracker Docker config
│ │ └── Dockerfile
│ └── kafka-logger/ # Kafka logging service
├── apps/ # Applications
│ └── web-interface/ # Web testing interface
│ ├── docker-compose.yml # Web interface Docker config
│ ├── index.html # Main web page
│ ├── script.js # Frontend JavaScript
│ ├── docs.html # This documentation page
│ └── connection-tracker-websocket.js # WebSocket service
├── config/ # Configuration files
│ ├── docker/ # Docker configurations
│ │ └── infrastructure/ # Shared infrastructure
│ └── env/ # Environment configurations
├── scripts/ # Build and deployment scripts
│ ├── docker-manager.sh # Docker service management
│ ├── connection-checker.sh # Connection testing utility
│ ├── deploy.sh # Deployment script
│ └── test/ # Test scripts
├── tests/ # Test files
│ ├── unit/ # Unit tests
│ ├── integration/ # Integration tests
│ └── e2e/ # End-to-end tests
├── run-all-e2e-tests.sh # E2E test runner
├── run-comprehensive-tests.sh # Comprehensive test runner
├── test-system.sh # System health tester
├── CLAUDE.md # AI assistant guidance
└── package.json # Root package.json (workspace)

Troubleshooting

Common Issues

  • Connection Refused: Check if services are running with ./scripts/docker-manager.sh status
  • Port Already in Use: Stop existing services first with ./scripts/docker-manager.sh stop all
  • WebSocket Connection Failed: Verify proxy is running on port 8080
  • Kafka Connection Errors: Ensure Kafka infrastructure is running
  • Redis Connection Issues: Check Redis service status

Connection Tracker Issues

  • WebSocket Connection Failed: Clear browser cache (Ctrl+F5) after code updates
  • No Connection Events: Check if Kafka is healthy and main app is publishing events
  • Service Not Responding: Verify Kafka and Redis are running
  • Wrong URL Detection: Frontend connects via nginx proxy at ws://localhost/connection-tracker

Health Checks

  • All Services: ./scripts/docker-manager.sh status
  • Main App: ./scripts/connection-checker.sh http localhost 3030
  • TCP Socket: ./scripts/connection-checker.sh tcp localhost 3031
  • Web Interface: curl http://localhost
  • Kafka UI: curl http://localhost:8082
  • Connection Tracker WS: curl -I http://localhost/connection-tracker (should return 426)
  • Redis: redis-cli ping

💡 Tip: Use ./scripts/connection-checker.sh for reliable TCP/HTTP testing without hanging!

Docker Troubleshooting

  • Outdated Container Code: Rebuild with docker-compose build --no-cache
  • Network Issues: Restart Docker with colima restart (macOS)
  • Service Dependencies: Start infrastructure first, then services
  • Log Analysis: Use ./scripts/docker-manager.sh logs [service]
  • Container Cleanup: docker system prune -a to clean up unused containers

Connection Checker Utility

Overview

The Connection Checker is a robust utility for testing TCP and HTTP connections without hanging. It's essential for both local development and remote deployment testing.

Key Features:

  • No Hanging: Immediate results for both connection types
  • Cross-Platform: Works on macOS and Linux
  • Dual Support: TCP and HTTP connection testing
  • Timeout Control: Configurable timeout for HTTP requests

Usage Examples

# Test TCP connections (e.g., Wialon socket server)
./scripts/connection-checker.sh tcp localhost 3031

# Test HTTP connections (e.g., main app server)
./scripts/connection-checker.sh http localhost 3030

# Test with custom timeout (default is 5 seconds)
./scripts/connection-checker.sh http localhost 3030 10

# Test remote connections
./scripts/connection-checker.sh tcp test.veevvo.com 3031
./scripts/connection-checker.sh http test.veevvo.com 80

Common Test Scenarios

  • Local Development: Verify services are accessible
  • Remote Deployment: Test connectivity to production servers
  • Service Health: Quick health checks for TCP/HTTP endpoints
  • Network Debugging: Identify connection issues quickly

Technical Details

  • TCP Checks: Uses nc -z for reliable connection testing
  • HTTP Checks: Uses curl with timeout to /health endpoint
  • Exit Codes: 0 for success, 1 for failure
  • Dependencies: Requires nc (netcat) and curl