by mostlylucid
Bot detection framework for ASP.NET Core with wave-based detection, adaptive learning, and reverse-proxy integration.
This repository is a monorepo for the StyloBot ecosystem:
Mostlylucid.BotDetection: Core detection library and middlewareMostlylucid.BotDetection.Demo: End-to-end demo app with test pages, API endpoints, and live signaturesStylobot.Gateway: Docker-first YARP gateway with built-in detectionMostlylucid.BotDetection.UI: Dashboard/tag helpers/view componentsMostlylucid.BotDetection.UI.PostgreSQL: PostgreSQL + TimescaleDB + pgvector persistencemostlylucid.stylobot.website: Marketing/demo website using the detection stack
- .NET SDK
10.0(repo projects targetnet10.0) - Docker + Docker Compose (optional, for containerized flows)
- Optional for advanced scenarios:
- PostgreSQL/TimescaleDB
- Ollama (for LLM provider mode)
dotnet run --project Mostlylucid.BotDetection.DemoOpen:
http://localhost:5080/bot-testhttp://localhost:5080/SignatureDemohttp://localhost:5080/bot-detection/check
If you run the HTTPS launch profile, HTTPS is also available at https://localhost:5001.
Run gateway with one upstream (zero-config mode):
docker run --rm -p 8080:8080 -e DEFAULT_UPSTREAM=http://host.docker.internal:3000 scottgal/stylobot-gateway:latestHealth endpoint:
curl http://localhost:8080/admin/healthIf ADMIN_SECRET is configured, include header X-Admin-Secret for /admin/* endpoints.
The default policy runs fast contributors first and can escalate based on policy config. In demo and gateway configs, the active policies include contributors such as:
- User-Agent, Header, IP, SecurityTool
- Behavioral, AdvancedBehavioral, CacheBehavior
- ClientSide, Inconsistency, VersionAge, ReputationBias
- FastPathReputation, ProjectHoneypot, HoneypotLink
- TLS/TCP/HTTP2 fingerprinting and cross-layer correlation
- Cluster detection (label propagation + FFT spectral analysis)
- Country reputation tracking (time-decayed bot rates)
- Heuristic scoring (and optional LLM path when configured)
Real contributor lists are controlled by BotDetection:Policies in each app config.
Export detection data for ML training:
# JSONL streaming export with labels
curl http://localhost:5080/bot-detection/training/export > training-data.jsonl
# Cluster data
curl http://localhost:5080/bot-detection/training/clusters
# Country reputation
curl http://localhost:5080/bot-detection/training/countriesRegister with app.MapBotTrainingEndpoints(). See Training Data API docs.
- Speed with intelligence: low-latency request handling with explainable detector evidence.
- Temporal behavior resolution: cross-request, windowed signal correlation for stronger bot/human discrimination.
- Powered by
mostlylucid.ephemeral: efficient ephemeral state and coordinator patterns that enable across-time analysis without heavy per-request latency. - Operator-first control: you decide policy actions and rollout strategy.
# Build all projects
dotnet build mostlylucid.stylobot.sln
# Run the demo app
dotnet run --project Mostlylucid.BotDetection.Demo
# Run the gateway app
dotnet run --project Stylobot.Gateway
# Run tests
dotnet test mostlylucid.stylobot.slndocker-compose.yml: TimescaleDB + demo appdocker-compose.demo.yml: full stack (Caddy + gateway + website + DB + extras)
Start minimal compose stack:
cp .env.example .env
# set POSTGRES_PASSWORD in .env
docker compose up -dStart here for canonical docs:
docs/README.md(entry index)QUICKSTART.md(hands-on local runbook)DOCKER_SETUP.md(compose and deployment workflows)
Library and component docs:
Mostlylucid.BotDetection/README.mdMostlylucid.BotDetection/docs/Stylobot.Gateway/README.mdMostlylucid.BotDetection.UI/README.mdMostlylucid.BotDetection.UI.PostgreSQL/README.mdMostlylucid.BotDetection/docs/detection-strategies.mdMostlylucid.BotDetection/docs/action-policies.md
Detector docs:
Mostlylucid.BotDetection/docs/user-agent-detection.mdMostlylucid.BotDetection/docs/header-detection.mdMostlylucid.BotDetection/docs/ip-detection.mdMostlylucid.BotDetection/docs/behavioral-analysis.mdMostlylucid.BotDetection/docs/advanced-behavioral-detection.mdMostlylucid.BotDetection/docs/client-side-fingerprinting.mdMostlylucid.BotDetection/docs/version-age-detection.mdMostlylucid.BotDetection/docs/security-tools-detection.mdMostlylucid.BotDetection/docs/ai-detection.mdMostlylucid.BotDetection/docs/cluster-detection.mdMostlylucid.BotDetection/docs/training-data-api.md
This repo has many historical architecture/experiment docs. Prefer the files listed above when you need current setup and operational behavior.