A modern, real-time web application for visualizing and analyzing network traffic flows within Tailscale networks.
TSFlow uses a Go backend + React frontend architecture for optimal performance and security:
┌─────────────────┐ ┌─────────────────┐ ┌──────────────────┐
│ React App │ │ Go Backend │ │ Tailscale API │
│ (Frontend) │◄──►│ (Gin Server) │◄──►│ api.tailscale. │
│ │ │ │ │ com │
└─────────────────┘ └─────────────────┘ └──────────────────┘
Benefits:
- ✅ No CORS Issues: Backend handles all Tailscale API calls
- ✅ Better Security: API keys stored server-side only
- ✅ Improved Performance: Efficient Go backend with caching
- ✅ Production Ready: Single Docker image with both components
- Interactive force-directed graph showing device connections
- Real-time traffic flow animation with D3.js
- Multiple layout algorithms (force-directed, circular, grid, hierarchical)
- Zoom and pan controls for detailed exploration
- Real-time traffic metrics and statistics
- Protocol and port usage analysis (TCP, UDP, ICMP)
- Device activity monitoring across your tailnet
- Historical data visualization with customizable time ranges
- Flexible time range selection (5min, 1hour, 24hours, custom)
- Protocol-based filtering (TCP, UDP, ICMP)
- Traffic type filtering (virtual, subnet, physical)
- IP category filtering (Tailscale, private, public)
- Bandwidth and connection threshold filtering
- Real-time device status monitoring (online/offline)
- Detailed device information and metadata
- Operating system detection and iconography
- Tag-based organization and filtering
- Go (Gin) backend for high-performance API serving
- React 18 with TypeScript for type safety
- Vite for lightning-fast frontend development
- Tailwind CSS for beautiful, responsive design
- D3.js for powerful network visualization
- SWR for efficient data fetching and caching
- Tailscale API key with appropriate permissions
- Docker (recommended) or Go 1.21+ and Node.js 18+
The quickest way to get started:
# Create environment file
cp env.example .env
# Edit .env with your Tailscale credentials
# Run with Docker Compose
docker-compose up -d
# View logs
docker-compose logs -f tsflow
Then navigate to http://localhost:8080
to start exploring your network!
Run directly using the pre-built container images from GitHub Container Registry:
# Simple docker run
docker run -d \
--name tsflow \
-p 8080:8080 \
-e TAILSCALE_API_KEY=your-api-key \
-e TAILSCALE_TAILNET=your-tailnet \
-e ENVIRONMENT=production \
--restart unless-stopped \
ghcr.io/rajsinghtech/tsflow:latest
Available image tags:
latest
- Latest stable release from main branch<version>
- Tagged releases (e.g.,v1.0.0
)<commit-sha>
- Specific commit builds
Create a docker-compose.yml
file:
services:
tsflow:
image: ghcr.io/rajsinghtech/tsflow:latest
container_name: tsflow
ports:
- "8080:8080"
environment:
- TAILSCALE_API_KEY=${TAILSCALE_API_KEY}
- TAILSCALE_TAILNET=${TAILSCALE_TAILNET}
- PORT=8080
- ENVIRONMENT=production
env_file:
- .env
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 3
Commands:
# Start the application
docker-compose up -d
# View logs
docker-compose logs -f tsflow
# Update to latest version
docker-compose pull && docker-compose up -d
# Stop the application
docker-compose down
Deploy TSFlow on Kubernetes using the provided manifests:
# Clone the repository
git clone https://github.com/rajsinghtech/tsflow.git
cd tsflow/k8s
# Set your Tailscale credentials
export TAILSCALE_API_KEY="your-api-key-here"
export TAILSCALE_TAILNET="your-tailnet-name"
# Deploy using Kustomize
kubectl apply -k .
-
Create the namespace:
kubectl create namespace tailscale
-
Create the secret with your credentials:
kubectl create secret generic tsflow \ --namespace=tailscale \ --from-literal=TAILSCALE_API_KEY="your-api-key" \ --from-literal=TAILSCALE_TAILNET="your-tailnet"
-
Deploy the application:
# Apply all manifests kubectl apply -f k8s/deployment.yaml kubectl apply -f k8s/service.yaml # Optional: Apply HTTPRoute for Gateway API kubectl apply -f k8s/httproute.yaml
-
Access the application:
# Port forward for local access kubectl port-forward -n tailscale svc/tsflow 8080:80 # Or use ingress/gateway based on your cluster setup
The k8s directory contains:
deployment.yaml
- Main application deploymentservice.yaml
- ClusterIP servicesecret.yaml
- Secret template for credentialshttproute.yaml
- Gateway API route (optional)kustomization.yaml
- Kustomize configuration
Key features:
- Single replica with
Recreate
strategy - Health checks and resource limits
- ConfigMap and Secret support
- Gateway API compatibility
For developers who want to build and run TSFlow locally:
- Go 1.21+ for backend development
- Node.js 18+ and npm for frontend development
- Git for version control
-
Clone the repository:
git clone https://github.com/rajsinghtech/tsflow.git cd tsflow
-
Configure environment:
cp env.example .env
Edit
.env
and add your Tailscale credentials:TAILSCALE_API_KEY=tskey-api-your-api-key-here TAILSCALE_TAILNET=your-tailnet-name PORT=8080 ENVIRONMENT=development
-
Build and run the frontend:
cd frontend npm install npm run build cd ..
-
Run the backend:
cd backend go mod download go run main.go
-
Development workflow:
# For frontend development with hot reload cd frontend npm run dev # Runs on port 5173 with proxy to backend # For backend development with auto-reload cd backend go install github.com/cosmtrek/air@latest air # Auto-reloads on Go file changes
Build the Docker image locally from source:
# Build the image
docker build -t tsflow:local .
# Run the container
docker run -d \
--name tsflow-local \
-p 8080:8080 \
-e TAILSCALE_API_KEY=your-api-key \
-e TAILSCALE_TAILNET=your-tailnet \
--restart unless-stopped \
tsflow:local
# Frontend testing
cd frontend
npm run test # Run unit tests
npm run lint # Check code style
npm run type-check # TypeScript validation
# Backend testing
cd backend
go test ./... # Run tests
go fmt ./... # Format code
go vet ./... # Static analysis
- Go to the Tailscale Admin Console
- Create a new API key with the following permissions:
devices:read
- To fetch device informationlogs:read
- To access network flow logs
- Copy the API key to your
.env
file
Variable | Description | Required | Default |
---|---|---|---|
TAILSCALE_API_KEY |
Your Tailscale API key | ✅ Yes | - |
TAILSCALE_TAILNET |
Your tailnet name | ✅ Yes | - |
PORT |
Backend server port | No | 8080 |
ENVIRONMENT |
Runtime environment | No | development |
tsflow/
├── backend/ # Go backend server
│ ├── main.go # Main server entry point
│ ├── go.mod # Go module definition
│ ├── internal/ # Internal packages
│ │ ├── config/ # Configuration management
│ │ ├── handlers/ # HTTP request handlers
│ │ └── services/ # Business logic services
│ └── README.md # Backend documentation
├── frontend/ # React frontend application
│ ├── src/ # Source code
│ │ ├── components/ # Reusable UI components
│ │ ├── pages/ # Page components
│ │ ├── lib/ # Utilities and API client
│ │ └── types/ # TypeScript definitions
│ ├── package.json # Frontend dependencies
│ └── dist/ # Built frontend (after build)
├── docker-compose.yml # Docker Compose configuration
├── Dockerfile # Multi-stage Docker build
├── .env # Environment variables
└── README.md # This file
The dashboard provides a high-level view of your network:
- Metrics Cards: Total devices, network traffic, active connections, and online rate
- Traffic Chart: Real-time visualization of network traffic over time
- Device List: Overview of all devices with status indicators
- Quick Actions: One-click access to detailed views
The network view offers interactive topology visualization:
- Interactive Graph: D3.js powered network topology
- Real-time Updates: Live traffic flow animation
- Filter Controls: Time range, protocol, and traffic type filters
- Device Details: Click devices to view detailed information
- Layout Options: Multiple graph layout algorithms
Detailed log view with comprehensive filtering:
- Traffic Analysis: Virtual, subnet, and physical traffic breakdown
- Protocol Details: TCP, UDP, and ICMP traffic inspection
- Time Range Selection: From 5 minutes to custom date ranges
- Search and Filter: Advanced filtering by source, destination, protocol
- Export Capability: Download logs for external analysis
The Go backend exposes the following REST API endpoints:
Endpoint | Method | Description |
---|---|---|
/health |
GET | Health check endpoint |
/api/devices |
GET | List all Tailscale devices |
/api/network-logs |
GET | Fetch network logs with time range |
/api/network-map |
GET | Get network topology data |
Example API calls:
# Health check
curl http://localhost:8080/health
# Get devices
curl http://localhost:8080/api/devices
# Get network logs (last 10 minutes)
curl "http://localhost:8080/api/network-logs?start=2024-12-19T10:00:00Z&end=2024-12-19T10:10:00Z"
- Enable logging: Network logging must be enabled in Tailscale admin console
- Check permissions: API key needs
logs:read
permission - Recent activity: Try a shorter time range - logs may only be available for recent activity
- Backend logs: Check
docker-compose logs tsflow
for error messages
- Check credentials: Verify API key and tailnet name in
.env
file - Test backend directly:
curl -H "Authorization: Bearer your-api-key" \ "https://api.tailscale.com/api/v2/tailnet/your-tailnet/devices"
- Backend health: Ensure backend is running:
curl http://localhost:8080/health
- Environment variables: Verify
.env
file is properly loaded
- Environment file: Ensure
.env
file exists and contains correct values - Port conflicts: Make sure port 8080 is available
- Build cache: Try
docker-compose build --no-cache
for clean rebuild - Container logs: Check
docker-compose logs tsflow
for detailed error messages
- Go dependencies: Run
go mod download
in backend directory - Frontend build: Run
npm run build
in frontend directory - Port conflicts: Backend runs on 8080, ensure it's available
- API connectivity: Backend must be able to reach api.tailscale.com
The Go backend serves as a secure API gateway:
- API Gateway: Proxies and caches Tailscale API calls
- Static Serving: Serves the built React frontend
- Authentication: Handles Tailscale API authentication
- Error Handling: Provides consistent error responses
- Health Checks: Built-in monitoring endpoints
Key Components:
internal/config/
- Environment configurationinternal/handlers/
- HTTP request/response handlinginternal/services/
- Tailscale API integrationmain.go
- Server initialization and routing
The React frontend provides a modern, responsive UI:
- Component Architecture: Modular, reusable components
- State Management: SWR for server state, React hooks for UI state
- Data Visualization: D3.js for network graphs, charts for metrics
- Responsive Design: Tailwind CSS with mobile-first approach
- Type Safety: Full TypeScript coverage
Key Components:
pages/Dashboard.tsx
- Main overview pagepages/NetworkView.tsx
- Interactive network topologypages/Logs.tsx
- Detailed log analysislib/api.ts
- Backend API clientcomponents/
- Reusable UI components
The Dockerfile uses a multi-stage build for optimal image size:
- Frontend Build Stage: Node.js environment to build React app
- Backend Build Stage: Go environment to compile binary
- Runtime Stage: Minimal Alpine image with static files and binary
This results in a production-ready image under 50MB.
We welcome contributions! Please follow these guidelines:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Make your changes in the appropriate directory (
frontend/
orbackend/
) - Test your changes locally
- Run linting:
npm run lint
(frontend) orgo fmt
(backend) - Commit your changes:
git commit -m 'Add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
- Frontend: TypeScript, Prettier formatting, ESLint rules
- Backend: Go standard formatting (
go fmt
), clear error handling - Commits: Use conventional commit messages
- Documentation: Update README and inline comments
# Frontend testing
cd frontend
npm run test
npm run lint
npm run type-check
# Backend testing
cd backend
go test ./...
go fmt ./...
go vet ./...
This project is licensed under the MIT License - see the LICENSE file for details.
- Tailscale for the amazing network platform and API
- Gin for the fast Go web framework
- D3.js for powerful data visualization capabilities
- React and the broader React ecosystem
- Tailwind CSS for the design system
Built with ❤️ for the Tailscale community