Getting Started
Sentinel is a production-grade security intelligence SDK for Go applications using the Gin framework. It provides WAF protection, rate limiting, threat detection, AI analysis, and an embedded React dashboard — all mountable with a single function call.
Installation
Sentinel requires Go 1.24+ and uses pure-Go SQLite (no CGo required).
go get github.com/MUKE-coder/sentinel
Quick Start
The simplest way to use Sentinel is with zero configuration. This gives you an in-memory store, all defaults, and a dashboard at /sentinel/ui.
main.gogo
1package main23import (4 sentinel "github.com/MUKE-coder/sentinel"5 "github.com/gin-gonic/gin"6)78func main() {9 r := gin.Default()1011 // Mount Sentinel with zero config — everything works out of the box12 sentinel.Mount(r, nil, sentinel.Config{})1314 // Your application routes15 r.GET("/api/hello", func(c *gin.Context) {16 c.JSON(200, gin.H{"message": "Hello, World!"})17 })1819 r.Run(":8080")20 // Dashboard: http://localhost:8080/sentinel/ui21 // Default login: admin / sentinel22}
Zero Config
With
sentinel.Config{}, Sentinel uses sensible defaults: in-memory storage, WAF disabled, rate limiting disabled. The dashboard is always available.With WAF and Rate Limiting
Enable security features by setting configuration fields:
main.gogo
1package main23import (4 "time"56 sentinel "github.com/MUKE-coder/sentinel"7 "github.com/gin-gonic/gin"8)910func main() {11 r := gin.Default()1213 sentinel.Mount(r, nil, sentinel.Config{14 Dashboard: sentinel.DashboardConfig{15 Username: "admin",16 Password: "my-secure-password",17 SecretKey: "change-this-in-production",18 },1920 Storage: sentinel.StorageConfig{21 Driver: sentinel.SQLite,22 DSN: "sentinel.db",23 RetentionDays: 90,24 },2526 WAF: sentinel.WAFConfig{27 Enabled: true,28 Mode: sentinel.ModeBlock,29 },3031 RateLimit: sentinel.RateLimitConfig{32 Enabled: true,33 ByIP: &sentinel.Limit{Requests: 100, Window: time.Minute},34 },35 })3637 r.GET("/api/users", func(c *gin.Context) {38 c.JSON(200, gin.H{"users": []string{}})39 })4041 r.Run(":8080")42}
What Happens When You Call Mount
sentinel.Mount() performs the following in order:
- Initializes the storage backend (SQLite or in-memory)
- Runs database migrations
- Creates the IP manager for whitelist/blacklist
- Sets up the async event pipeline with worker goroutines
- Initializes threat profiler, security score engine, geo-locator
- Configures alerting (Slack, email, webhook) if enabled
- Registers middleware: Auth Shield, WAF, Rate Limiter, Security Headers, Performance
- Registers the REST API and WebSocket endpoints
- Optionally initializes the AI provider
- Serves the embedded React dashboard
- Starts background cleanup and score recomputation goroutines
Middleware Order Matters
Sentinel registers middleware in a specific order. Mount it before your application routes so that all routes are protected.
Project Architecture
sentinel/├── core/ # Shared types, constants, models├── ai/ # AI provider interface (Claude, OpenAI, Gemini)├── alerting/ # Alert dispatching (Slack, email, webhook)├── api/ # REST API server, JWT auth, WebSocket hub├── detection/ # WAF pattern matching, custom rule engine├── gorm/ # GORM audit logging plugin├── intelligence/ # Threat profiling, scoring, anomaly detection├── middleware/ # Gin middleware (WAF, rate limit, headers, perf)├── pipeline/ # Async event pipeline (ring buffer, workers)├── reports/ # Compliance report generators├── storage/ # Storage interface + implementations│ ├── memory/ # In-memory store (default)│ └── sqlite/ # Pure-Go SQLite store├── ui/ # Embedded React dashboard├── sentinel.go # Mount() entry point└── models.go # Type aliases from core/
Storage Backends
| Driver | Config Value | Notes |
|---|---|---|
| Memory | sentinel.Memory | Default. No persistence — good for development. |
| SQLite | sentinel.SQLite | Pure Go (no CGo). Recommended for production. |
Testing Your Setup
After starting your application, verify Sentinel is working:
# Check the dashboardcurl http://localhost:8080/sentinel/ui# Try a SQL injection attack (should be blocked if WAF is enabled)curl "http://localhost:8080/api/users?id=1'+OR+'1'='1"# Check rate limiting headerscurl -v http://localhost:8080/api/users 2>&1 | grep X-RateLimit
Next Steps
- Full Configuration Reference — All available options
- WAF Configuration — Custom rules and strictness levels
- Rate Limiting — Per-IP, per-user, per-route limits
- Dashboard — Explore the 13-page security dashboard
Built with by JB