The ship made of dead men's nails - A Norse mythology reference representing collection and analysis of threat data for abuse protection.
Naglfar Analytics is an abuse protection system built with .NET 10.0 that acts as a defensive layer between your API gateway and backend services. It analyzes incoming requests, detects malicious patterns, and blocks abusive traffic before it reaches your core application.
Current Status: Monorepo structure established. Architecture and design phase with comprehensive documentation and diagrams.
Repository Structure: This is a monorepo containing multiple microservices including the naglfar-validation service (.NET 10.0), with planned additions for worker services, authentication, and protected demo applications.
- β RESTful API with .NET 10.0 Minimal APIs
- β API Versioning (URL, query string, and header-based)
- β
Health check endpoints (
/healthz,/readyz) for Kubernetes - β
Prometheus metrics endpoint (
/metrics) - β Swagger/OpenAPI documentation
- β Traefik API Gateway (v3.6) integration
- β Docker support with multi-stage Alpine builds
- β Docker Compose orchestration with custom networking
- β Makefile automation (17+ commands)
- β Comprehensive integration tests (10 tests, all passing)
- β Architecture diagrams (9 diagrams with automated generation)
- β Detailed system design and architecture documentation
- β Automated diagram validation and regeneration
π Comprehensive documentation available:
- System Design - High-level architecture and design philosophy
- Naglfar Layer Architecture - Detailed component architecture with diagrams
- API Endpoints - Quick reference for all endpoints
- Architecture Diagrams - Diagram generation workflow and usage
- CHANGELOG - Complete version history and changes
- .NET 10.0 SDK or later
- Docker (required for diagram generation and containerized deployment)
- Docker Compose (for multi-service orchestration)
# Restore dependencies
make restore
# Build the application
make build
# Run the application
make runThe application will be available at http://localhost:5000
# Build Docker image
make docker-build
# Run in Docker container
make docker-runThe application will be available at http://localhost:8080
# Start all services (API + Traefik)
make compose-up
# View logs
make compose-logs
# Stop all services
make compose-down# Health check
curl http://localhost:8000/healthz
# Readiness check
curl http://localhost:8000/readyz
# API info (versioned)
curl http://localhost:8000/api/v1/info
# Prometheus metrics
curl http://localhost:8000/metrics# Access API through Traefik
curl -H "Host: api.local" http://localhost/healthz
curl -H "Host: api.local" http://localhost/api/v1/infoRun make help to see all available commands with descriptions.
make restore- Restore .NET dependenciesmake build- Build the applicationmake run- Run the application locallymake test- Run all testsmake test-watch- Run tests in watch modemake test-coverage- Run tests with code coveragemake clean- Clean build artifacts
make compose-up- Start all services with docker-composemake compose-down- Stop and remove all servicesmake compose-logs- Show logs for all servicesmake validation-rebuild- Rebuild only the naglfar-validation servicemake apigw-restart- Rebuild and restart Traefik API Gateway
make diagrams- Generate all SVG diagrams from Mermaid sourcesmake diagrams-validate- Validate all diagram syntaxmake diagrams-clean- Remove generated SVG filesmake diagrams-check- Check if Docker is available
The project uses modular helper makefiles for service-specific commands. Each service maintains its own helpers.mk file with build and deployment commands.
Book Store Service:
make docker-build-book-store- Build book-store Docker imagemake docker-run-book-store- Run book-store container (port 8090)make lock-dependencies-book-store- Generate Pipfile.lock using Docker (no local Python/pipenv needed)make compose-rebuild-book-store- Rebuild book-store via docker-compose
Naglfar Validation Service:
make docker-build-naglfar- Build naglfar-validation Docker imagemake docker-run-naglfar- Run naglfar-validation containermake docker-stop-naglfar- Stop and remove containermake docker-clean-naglfar- Remove Docker image
Benefits of Modular Makefiles:
- Each service maintains its own build commands in
services/<service>/helpers.mk - Helper makefiles are automatically included by the root Makefile
- Services know their own directory location (location-aware)
- Easy to add new services without modifying the root Makefile
- Run
make helpto see all available commands from all services
The project includes three comprehensive testing frameworks:
Python-based CLI tool for testing user journeys through the system.
# Run all E2E tests
make e2e-all
# Run individual tests
make e2e-browse # Browse books journey
make e2e-purchase # Purchase book journey
make e2e-full-flow # Complete user flow
# View results
make e2e-resultsπ Documentation: testing/e2e/README.md
Load and stress testing using Grafana k6.
# Run all performance tests
make perf-all
# Run individual tests
make perf-browse # Browse books load test
make perf-full-flow # Full user flow test
make perf-stress # Stress test (up to 300 VUs)
# View and compare results
make perf-results
make perf-compareπ Documentation: testing/performance/README.md
YAML-driven capacity testing with Gatling for defining test scenarios without code.
# Run all capacity tests
make capacity-all
# Run individual tests
make capacity-browse # Browse capacity test
make capacity-full-flow # Full flow capacity test
make capacity-stress # System stress test
# View results and reports
make capacity-results
make capacity-report # Open HTML reportKey Features:
- Define test scenarios in YAML files (no Scala code needed)
- Flexible load injection profiles (ramp, constant, spike)
- Built-in authentication flow support (E-TOKEN/AUTH-TOKEN)
- Rich HTML reports with charts and metrics
- Performance thresholds and assertions
π Documentation: testing/capacity/README.md
Example YAML Scenario:
name: "Browse Books Test"
injection:
- type: rampUsers
users: 10
duration: 30s
scenarios:
- name: "Browse Journey"
steps:
- http:
method: GET
path: "/api/books"
checks:
- status: 200naglfar-analytics/ # Monorepo root
βββ services/ # Microservices directory
β βββ book-store/ # Book store service (Python FastAPI)
β β βββ src/ # Source code
β β βββ Pipfile # Python dependencies
β β βββ Pipfile.lock # Locked dependencies
β β βββ Dockerfile # Multi-stage Docker build
β β βββ helpers.mk # Service-specific Makefile commands
β β
β βββ naglfar-validation/ # Validation service (.NET 10.0)
β βββ src/
β β βββ NaglfartAnalytics/
β β βββ Program.cs # Application entry point
β β βββ NaglfartAnalytics.csproj # .NET 10.0 project file
β β βββ appsettings.json # Production configuration
β β βββ appsettings.Development.json # Development configuration
β βββ tests/
β β βββ NaglfartAnalytics.Tests/
β β βββ IntegrationTests.cs # Integration tests (9 tests)
β β βββ MetricsTests.cs # Metrics endpoint tests (1 test)
β β βββ NaglfartAnalytics.Tests.csproj # Test project file
β βββ Dockerfile # Multi-stage Docker build (Alpine)
β βββ helpers.mk # Service-specific Makefile commands
β
βββ infrastructure/ # Infrastructure configuration
β βββ docker-compose.yml # Service orchestration (API + Traefik)
β βββ helpers.mk # Infrastructure Makefile commands
β βββ traefik/ # API Gateway configuration (future)
β βββ kafka/ # Message broker configuration (future)
β βββ neo4j/ # Graph database configuration (future)
β βββ prometheus/ # Monitoring configuration (future)
β
βββ shared/ # Shared libraries (future)
β βββ dotnet/ # Shared .NET libraries
β βββ python/ # Shared Python libraries
β
βββ testing/ # Testing frameworks
β βββ e2e/ # End-to-end tests (Python CLI)
β βββ performance/ # Performance tests (k6)
β βββ capacity/ # Capacity tests (Gatling + YAML)
β
βββ scripts/ # Automation scripts (future)
β βββ ...
β
βββ docs/
β βββ system-design.md # High-level system architecture
β βββ naglfar-layer-architecture.md # Detailed component architecture
β βββ endpoints.md # API endpoint reference
β βββ assets/
β βββ diagrams/
β βββ README.md # Diagram workflow documentation
β βββ *.mmd # Mermaid source files (9 diagrams)
β βββ *.svg # Generated SVG diagrams
β
βββ Makefile # Build automation (17+ commands)
βββ CHANGELOG.md # Complete version history
βββ README.md # This file
The application uses .NET 10.0 Minimal APIs for a lightweight and performant web service with API versioning.
Edit services/naglfar-validation/src/NaglfartAnalytics/Program.cs to add new versioned endpoints:
// Add to v1 API group
v1Group.MapGet("/your-endpoint", () => Results.Ok(new { message = "Hello" }))
.WithName("YourEndpoint")
.WithDescription("Your endpoint description");Application settings can be configured in:
appsettings.json- Production settingsappsettings.Development.json- Development settings- Environment variables (prefixed with
ASPNETCORE_)
The application provides two types of health checks:
- Health Check (
/healthz): Indicates if the application is running and healthy - Readiness Check (
/readyz): Indicates if the application is ready to accept traffic
These endpoints are commonly used by:
- Kubernetes liveness and readiness probes
- Load balancers
- Monitoring systems
- Container orchestrators
- Reference Compose
- Traefik Expose Services
- Traefik Examples
- Traefik Routes
- Mermaid diagrams cli
- Diagrams as code
- Dapr
- Redis
- Redis mod
- Neo4J Driver
- Neo4j examples
- Access Neptune
This project is part of the ik-workshop organization.
See CHANGELOG.md for version history and changes.