Web-based debugging interface for swift-complexity. Analyze Swift code complexity metrics interactively in your browser.
- Interactive Code Editor: Monaco Editor with Swift syntax highlighting
- Real-time Analysis: Instant complexity calculation for Swift code
- Multiple Metrics: Both cyclomatic and cognitive complexity
- Visual Results: Color-coded complexity scores and summary statistics
- Multiple Output Formats: JSON, XML, Text, and Xcode formats
- Responsive Design: Works on desktop and mobile devices
- Framework: Next.js 15 with App Router
- Language: TypeScript
- Styling: Tailwind CSS
- Editor: Monaco Editor (@monaco-editor/react)
- Build Adapter: OpenNext for Cloudflare
- Deployment: Cloudflare Workers
- Framework: Vapor 4
- Language: Swift 6.1
- Core Library: SwiftComplexityCore
- Deployment: Cloudflare Containers
- Node.js 20+ (for frontend)
- Swift 6.1+ (for backend)
- Docker (for containerized deployment)
cd debug-website/backend
# Install dependencies
swift package resolve
# Run development server
swift run App serve --hostname 0.0.0.0 --port 8080The backend API will be available at http://localhost:8080.
cd debug-website/frontend
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env.local
# Edit .env.local to point to your backend
# Run development server (Next.js)
npm run dev
# Or run with Wrangler for local Workers environment
npx wrangler devThe frontend will be available at http://localhost:3000 (npm run dev) or http://localhost:8788 (wrangler dev).
cd debug-website/backend
swift testcd debug-website/frontend
npm run type-checkcd debug-website/frontend
# Build with OpenNext for Cloudflare Workers
npm run open-next:build
# Deploy to Cloudflare Workers
npx wrangler deploy --env production
# Or use the combined command
npm run deployThe OpenNext build adapter converts Next.js into a format compatible with Cloudflare Workers.
cd debug-website/backend/app
# Build Docker image (from app directory)
docker build -t swift-complexity-api .
# Deploy to Cloudflare Containers
npx wrangler deployNEXT_PUBLIC_API_URL=http://localhost:8080For production, configure environment variables in wrangler.toml:
[vars]
NEXT_PUBLIC_API_URL = "http://localhost:8787"
[env.production.vars]
NEXT_PUBLIC_API_URL = "https://api.swift-complexity.fummicc1.dev"Set these in Cloudflare Workers dashboard or wrangler.toml:
LOG_LEVEL=infoAnalyzes Swift code and returns complexity metrics.
Request:
{
"code": "func example() { ... }",
"fileName": "example.swift",
"format": "json", // Optional: "text" | "json" | "xml" | "xcode"
"threshold": 10 // Optional: filter functions by complexity
}Response (without format):
{
"filePath": "example.swift",
"functions": [
{
"name": "example",
"signature": "func example()",
"cyclomaticComplexity": 2,
"cognitiveComplexity": 1,
"location": { "line": 1, "column": 1 }
}
],
"summary": {
"totalFunctions": 1,
"averageCyclomaticComplexity": 2.0,
...
}
}Response (with format):
{
"formatted": "... formatted output string ..."
}Analyzes multiple Swift files.
Health check endpoint.
Monaco Editor component with Swift language support.
Displays analysis results with:
- Summary statistics
- Function-by-function breakdown
- Color-coded complexity scores (green/yellow/red)
The backend includes a multi-stage Dockerfile optimized for Cloudflare Containers:
- Build stage: Compiles Swift code with release optimizations
- Run stage: Minimal Ubuntu image with only runtime dependencies
- Backend uses Swift 6.1 with strict concurrency checking
- Frontend uses React 19 with Next.js App Router
- OpenNext adapter (
@opennextjs/cloudflare) enables Next.js on Cloudflare Workers - Image optimization is disabled for Workers compatibility
- CORS configured to allow requests from
swift-complexity.fummicc1.dev - All API responses are JSON-encoded
- Static assets are served via Workers Assets binding
This is part of the swift-complexity project. Please refer to the main repository for contribution guidelines.
Same as the parent swift-complexity project.