A comprehensive .NET 7/C# field operations optimizer that ingests open routing/traffic data, free weather APIs, and webhook/CSV job feeds to auto-schedule technicians, predict ETAs, cluster routes, and reduce idle miles for service SMBs.
- Intelligent Route Optimization: Uses OpenStreetMap + OSRM/Valhalla for route calculation and optimization
- Real-time Weather Integration: Open-Meteo/NOAA weather data for scheduling optimization
- Multi-source Job Ingestion: Webhook and CSV job feed support
- ETA Prediction: ML.NET-powered demand forecasting and ETA calculation
- Technician Auto-scheduling: Skills-based matching and availability optimization
- Multi-tenant Support: Built-in tenant isolation for service SMBs
- Architecture: Clean Architecture + CQRS/MediatR pattern
- Backend: ASP.NET Core minimal APIs + gRPC services
- Frontend: Blazor WebAssembly with MapLibre GL mapping
- Database: PostgreSQL with Entity Framework Core
- Caching: Redis for performance optimization
- Background Processing: Hangfire OSS + MassTransit + RabbitMQ
- Authentication: OpenIddict + ASP.NET Identity
- Observability: OpenTelemetry β Prometheus + Grafana
- Search: PostgreSQL Full-Text Search
- Feature Flags: Unleash OSS
- Real-time Updates: SignalR
- Resilience: Polly for robust external service integration
- Containerization: Docker + Docker Compose
- Orchestration: k3d/k3s support
- CI/CD: GitHub Actions
- IaC: Infrastructure as Code approach
- Monitoring: Full observability stack with metrics, tracing, and logging
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Presentation Layer β
βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββ€
β Blazor WASM UI β ASP.NET Core API β
β + MapLibre GL β (Minimal APIs + gRPC) β
β + SignalR Client β + SignalR Hub β
βββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββ
β Application Layer β
βββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββ€
β CQRS + MediatR β
β Commands, Queries, Handlers, Validators β
βββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββ
β Infrastructure Layer β
βββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββ€
β EF Core + PostgreSQL β External Services Integration β
β Redis Caching β β’ OpenStreetMap/OSRM β
β Hangfire/MassTransit β β’ Open-Meteo Weather β
β OpenTelemetry β β’ Webhook/CSV Ingestion β
βββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββ
β Domain Layer β
βββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββ€
β Entities, Value Objects, Domain Services β
β Technician, ServiceJob, Route, etc. β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Start core services (PostgreSQL, Redis, RabbitMQ)
.\start-services.ps1 -Core
# Or start all services
.\start-services.ps1 -All
# Stop all services
.\start-services.ps1 -Stop# Start core services only
docker compose -f docker-compose.core.yml up -d postgres redis rabbitmq
# Start with monitoring
docker compose -f docker-compose.core.yml --profile monitoring up -d
# Or start everything (may take longer due to OSRM initialization)
docker compose up -d# Run database migrations (after PostgreSQL is running)
dotnet ef database update --project src/FieldOpsOptimizer.Infrastructure --startup-project src/FieldOpsOptimizer.Api
# Start the API
dotnet run --project src/FieldOpsOptimizer.Api
# Start the Blazor WASM app
dotnet run --project src/FieldOpsOptimizer.WebAfter starting the services:
- Main Application: http://localhost:5002
- API Documentation: http://localhost:5001/swagger
- Grafana Dashboard: http://localhost:3000 (see .env for credentials)
- Prometheus: http://localhost:9090
- RabbitMQ Management: http://localhost:15672 (see .env for credentials)
- Seq Logging: http://localhost:5341 (see .env for credentials)
- Jaeger Tracing: http://localhost:16686
- Unleash Feature Flags: http://localhost:4242
- MinIO Console: http://localhost:9001 (see .env for credentials)
The project includes comprehensive CI/CD automation:
Runs on every push and pull request to main and develop branches:
- Build & Test: Compiles solution and runs all 249 tests
- Code Coverage: Generates coverage reports with Coverlet
- Code Quality: Validates code formatting and checks for warnings
- Security Scan: Scans dependencies for known vulnerabilities
- PR Comments: Automatically adds test results and coverage to PRs
# Triggered automatically on:
- Push to main/develop
- Pull requests to main/develop
# Manual trigger:
gh workflow run ci.ymlBuilds and publishes Docker images to GitHub Container Registry:
- Multi-stage Builds: Optimized Docker images for API and Web
- Multi-platform: Supports linux/amd64 and linux/arm64
- Security Scanning: Trivy scans for container vulnerabilities
- Artifact Attestation: Generates SLSA provenance
# Triggered on:
- Push to main
- Version tags (v*.*.*)
- Manual workflow dispatch
# Images published to:
ghcr.io/<username>/field-ops-optimizer-api:latest
ghcr.io/<username>/field-ops-optimizer-web:latestManual deployment workflow with environment-specific configurations:
- Environments: Development, Staging, Production
- Version Control: Deploy specific versions or latest
- Approval Gates: Manual approval required for production
- Smoke Tests: Automated health checks after deployment
- Rollback: Automatic rollback on deployment failures
# Manual deployment:
gh workflow run cd-deploy.yml -f environment=staging -f version=v1.2.3- GitHub Container Registry: Ensure GitHub Packages is enabled for your repository
- Environments: Configure environments in GitHub repository settings:
development: Auto-deploy on successful buildstaging: Requires one reviewerproduction: Requires two reviewers + branch protection
- Secrets: No additional secrets required (uses
GITHUB_TOKEN)
# Build API image
docker build -f src/FieldOpsOptimizer.Api/Dockerfile -t field-ops-api:local .
# Build Web image
docker build -f src/FieldOpsOptimizer.Web/Dockerfile -t field-ops-web:local .
# Run locally
docker run -p 8080:8080 field-ops-api:local
docker run -p 80:80 field-ops-web:localLast Updated: December 24, 2024
Phase: CI/CD & DevOps (Phase 5 Complete - Automated Pipeline! π)
- Clean Architecture foundation with Domain-Driven Design
- Domain modeling (Technician, ServiceJob, Route entities)
- CQRS/MediatR infrastructure with command/query separation
- PostgreSQL + Entity Framework Core data layer
- Repository pattern implementation with UoW
- Docker Compose infrastructure setup
- ASP.NET Core Web API with RESTful endpoints
- Blazor WebAssembly frontend with responsive UI
- Health checks for database and external services
- Comprehensive logging and error handling
- API documentation with Swagger/OpenAPI
- Technician management (CRUD operations)
- Service job management and tracking
- Route optimization engine foundation
- Weather service integration (Open-Meteo)
- External routing service integration (OSRM)
- Database migrations and seeding
- Data validation and business rules
- Multi-container Docker setup
- PostgreSQL database container
- Redis caching layer
- RabbitMQ message broker
- Monitoring stack (Prometheus, Grafana)
- Distributed tracing (Jaeger)
- Centralized logging (Seq)
- Feature flags (Unleash)
- Object storage (MinIO)
- PowerShell deployment scripts
- Phase 1: Fixed all API controller compiler warnings
- Phase 1: Resolved enum mismatches between DTO and Domain layers
- Phase 1: Fixed async method warnings in API controllers
- Phase 2: Fixed AuthService security issues (proper logging, error handling)
- Phase 2: Fixed WeatherService and TenantService async warnings
- Phase 3: Fixed all optimization algorithm warnings (async, nullability)
- Phase 3: Fixed OSRMRoutingService null reference warning
- Phase 4: Enabled TreatWarningsAsErrors across all projects
- Phase 4: Hardened tenant security (JWT-only, no header/query spoofing)
- Phase 4: Fixed WeatherData nullability issues
- 100% Warning Elimination: 16 β 0 warnings
- Phase 5: Comprehensive test coverage (249 tests - Domain, Application, Infrastructure)
- Phase 5: CI/CD pipeline with GitHub Actions
- All tests passing (249 tests)
- Build succeeds with 0 errors, 0 warnings, TreatWarningsAsErrors enforced
- GitHub Actions CI pipeline (build, test, code quality, security scan)
- Automated test execution (249 tests)
- Code coverage reporting with Coverlet
- Docker image build and push to GitHub Container Registry
- Multi-stage Docker builds for API and Web
- Security scanning with Trivy
- CD pipeline with environment-specific deployments (dev, staging, production)
- Manual approval gates for production deployments
- Automated rollback on deployment failures
- Domain Tests: 142 tests (entities, value objects, domain services)
- Application Tests: 28 tests (CQRS handlers, validators)
- Infrastructure Tests: 79 tests (optimization algorithms, external services, auth)
- Total Coverage: 249 tests with 100% pass rate
- Advanced route optimization algorithms (genetic algorithms, simulated annealing)
- ML.NET integration for demand forecasting
- Real-time updates with SignalR
- Performance optimization and caching strategies
- Kubernetes deployment manifests
- Background job processing with Hangfire
- Mobile app (Xamarin/MAUI)
- Advanced analytics dashboard
- Integration with external CRM systems
- Load testing & performance benchmarks
dotnet test tests/FieldOpsOptimizer.Domain.Tests
dotnet test tests/FieldOpsOptimizer.Application.Testsdotnet test tests/FieldOpsOptimizer.Api.Testsdotnet testBuilt following Clean Architecture principles with clear separation of concerns:
- Domain Layer: Core business entities, value objects, and domain services
- Application Layer: Use cases, CQRS commands/queries, and application services
- Infrastructure Layer: Data persistence, external service integrations, and cross-cutting concerns
- Presentation Layer: Web API controllers and Blazor WebAssembly UI components
src/
βββ FieldOpsOptimizer.Domain/ # π’ Domain entities and business logic
β βββ Entities/ # Core business entities (Technician, Job, Route)
β βββ ValueObjects/ # Domain value objects
β βββ Services/ # Domain services
β βββ Exceptions/ # Domain-specific exceptions
β
βββ FieldOpsOptimizer.Application/ # π§ Application services and CQRS
β βββ Features/ # Feature-based organization
β β βββ Technicians/ # Commands, queries, and handlers
β βββ Common/ # Shared interfaces and models
β
βββ FieldOpsOptimizer.Infrastructure/ # π Data access and external services
β βββ Data/ # EF Core contexts, configurations, migrations
β βββ ExternalServices/ # Weather, routing service clients
β βββ Optimization/ # Route optimization algorithms
β βββ Services/ # Infrastructure service implementations
β
βββ FieldOpsOptimizer.Api/ # π REST API endpoints and infrastructure
β βββ Controllers/ # API controllers
β βββ Middleware/ # Custom middleware
β βββ Infrastructure/ # Health checks, metrics, tracing
β βββ DTOs/ # Data transfer objects
β
βββ FieldOpsOptimizer.Web/ # π» Blazor WebAssembly frontend
β βββ Pages/ # Razor pages and components
β βββ Components/ # Reusable UI components
β βββ Services/ # Client-side services
β βββ Shared/ # Shared layouts and components
β
βββ FieldOpsOptimizer.Simulator/ # π² Demo data generation and testing
tests/
βββ FieldOpsOptimizer.Domain.Tests/ # π§ͺ Domain unit tests
βββ FieldOpsOptimizer.Application.Tests/ # π§ͺ Application unit tests
βββ FieldOpsOptimizer.Api.Tests/ # π§ͺ API integration tests
infrastructure/ # π³ Container and infrastructure configs
βββ prometheus/ # Metrics collection configuration
βββ grafana/ # Monitoring dashboards
βββ osrm/ # Routing engine data and configs
βββ postgres/ # Database initialization scripts
βββ scripts/ # Deployment and utility scripts
docs/ # π Additional documentation
scripts/ # π PowerShell deployment scripts
βββ Deploy-Database.ps1
βββ start-services.ps1
βββ security-check.ps1
The API follows RESTful conventions and includes comprehensive OpenAPI/Swagger documentation.
Base URL: http://localhost:5001/api
GET /api/technicians- List all techniciansGET /api/technicians/{id}- Get technician by IDPOST /api/technicians- Create new technicianPUT /api/technicians/{id}- Update technicianDELETE /api/technicians/{id}- Delete technician
GET /api/servicejobs- List service jobsPOST /api/servicejobs- Create new service jobPUT /api/servicejobs/{id}/assign- Assign job to technician
POST /api/routes/optimize- Optimize routes for techniciansGET /api/routes/{id}- Get route details
GET /health- Application health statusGET /health/ready- Readiness probeGET /health/live- Liveness probe
Currently in development. The API will support:
- JWT Bearer tokens
- Role-based access control (RBAC)
- Multi-tenant isolation
- .NET 7 SDK
- Docker Desktop
- PostgreSQL (for local development without Docker)
- Visual Studio 2022 or VS Code
-
Clone the repository
git clone <repository-url> cd Project_Trailblazer
-
Start infrastructure services
# Start core services (PostgreSQL, Redis, RabbitMQ) .\start-services.ps1 -Core
-
Setup database
# Apply migrations dotnet ef database update --project src/FieldOpsOptimizer.Infrastructure --startup-project src/FieldOpsOptimizer.Api -
Run the application
# Terminal 1 - API dotnet run --project src/FieldOpsOptimizer.Api # Terminal 2 - Web UI dotnet run --project src/FieldOpsOptimizer.Web
Create a .env file in the root directory:
# Database
POSTGRES_DB=fieldops_db
POSTGRES_USER=fieldops_user
POSTGRES_PASSWORD=your_secure_password
# Redis
REDIS_PASSWORD=your_redis_password
# RabbitMQ
RABBITMQ_DEFAULT_USER=admin
RABBITMQ_DEFAULT_PASS=your_rabbitmq_password
# External Services
OPEN_METEO_API_KEY=your_weather_api_key
OSRM_SERVER_URL=http://localhost:5000
# Monitoring
GRAFANA_ADMIN_PASSWORD=your_grafana_password
SEQ_ADMIN_PASSWORD=your_seq_password# Format code
dotnet format
# Run static analysis
dotnet build --verbosity normal
# Run all tests with coverage
dotnet test --collect:"XPlat Code Coverage" --results-directory TestResults# Check if PostgreSQL container is running
docker ps | grep postgres
# Check database logs
docker logs fieldopsoptimizer_postgres_1
# Test connection manually
docker exec -it fieldopsoptimizer_postgres_1 psql -U fieldops_user -d fieldops_dbIf you encounter port conflicts:
- API (5001): Check for other applications using this port
- PostgreSQL (5432): Modify port in
docker-compose.core.yml - Redis (6379): Modify port in
docker-compose.core.yml
For development on resource-constrained machines:
# Start only core services
.\start-services.ps1 -Core
# Skip memory-intensive services like OSRM initially# Clean solution
dotnet clean
# Restore packages
dotnet restore
# Rebuild
dotnet build- Application Logs: Available in Seq at http://localhost:5341
- Container Logs:
docker logs <container_name> - Database Logs: Check PostgreSQL container logs
- API Logs: Located in
src/FieldOpsOptimizer.Api/logs/
- Fork the repository
- Create a feature branch
git checkout -b feature/your-feature-name
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
dotnet test - Follow coding standards
dotnet format
- Submit a Pull Request
- Follow Microsoft C# Coding Conventions
- Use meaningful variable and method names
- Add XML documentation for public APIs
- Write unit tests for new features
- Follow SOLID principles
- Use async/await for I/O operations
- Domain Layer: Pure business logic, no dependencies on infrastructure
- Application Layer: Use cases and orchestration, depends only on Domain
- Infrastructure Layer: External concerns, implements Application interfaces
- API Layer: HTTP concerns, thin controllers using MediatR
- Provide a clear description of changes
- Include tests for new functionality
- Update documentation if needed
- Ensure CI checks pass
- Keep PRs focused and reasonably sized
- API Response Times: <200ms for CRUD operations
- Route Optimization: <5s for 50 jobs/10 technicians
- Database Queries: <100ms average
- Memory Usage: <512MB baseline
- Metrics: Prometheus + Grafana dashboards
- Tracing: Jaeger for distributed tracing
- Logging: Seq for centralized log aggregation
- Health Checks: Built-in ASP.NET Core health checks
- Enable Redis caching for frequently accessed data
- Use pagination for large datasets
- Implement database query optimization
- Monitor memory usage during route optimization
- Input validation and sanitization
- SQL injection prevention via Entity Framework
- CORS policy configuration
- Environment-specific configuration
- Secrets management (planned)
If you discover a security vulnerability, please send an email to [security@example.com] instead of opening a public issue.
This project is licensed under the MIT License - see the LICENSE file for details.
- Use environment-specific configuration
- Enable HTTPS/TLS encryption
- Implement proper logging and monitoring
- Set up automated backups for PostgreSQL
- Configure load balancing if needed
- Use a reverse proxy (nginx/Apache)
# Build production images
docker-compose -f docker-compose.yml -f docker-compose.prod.yml build
# Deploy with production configuration
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d- Documentation: See the docs/ directory
- Issues: GitHub Issues for bug reports and feature requests
- Discussions: GitHub Discussions for questions and ideas
Built with β€οΈ by the Field Operations Team