How mshumayl/cidr-checkr works
Project type and purpose
• This is a Go‑based, headless HTTP API server (“cidr‑checkr”) that exposes CIDR analysis and overlap‑detection functionality.
• Its primary audience is network engineers, security teams, and DevOps pipelines that need to validate or audit IP ranges.
File structure
• Top‑level “cmd/api” holds the entry point (main.go) which spins up an HTTP server.
• “internal/handlers” implements HTTP handlers (routing, request parsing, response formatting).
• “internal/service” contains the core CIDR analysis logic (overlap detection, first/last IP calculations).
• “internal/models” defines the request/response data structures.
• No database/persistence layer—this is an in-memory, compute‑only service.
Key insights from the README
• REST API with a single POST endpoint /api/analyze-cidrs.
• JSON request → list of CIDRs; JSON response → per‑CIDR details + overlap info.
• Intended for integration into automation or CI/CD pipelines.
• External client (e.g., curl, CLI, dashboard, CI job)
• HTTP API server (cmd/api)
• Router/handler layer (internal/handlers)
• Service layer (internal/service/analyzer)
• Data models (internal/models)
b. Relationships & interactions:
1. Client issues HTTP POST → API server listens on :8080
2. Router dispatches request to the appropriate handler
3. Handler unmarshals JSON into model structs
4. Handler calls the analyzer service with the list of CIDRs
5. Service executes analysis: for each CIDR compute first/last IP & hosts, detect overlaps
6. Service returns a result struct back to handler
7. Handler marshals the model to JSON and writes HTTP response
c. Architectural patterns/design principles:
• Layered (API → Handler → Service → Model)
• Single‑responsibility modules: each package has a clear role
• In‑process, stateless microservice (no DB, no persistent state)
• Test coverage at handler and service levels (as shown by *_test.go)
d. Relevant technologies/frameworks:
• Go “net/http” standard library (or a lightweight router)
• JSON marshalling/unmarshalling (encoding/json)
• Native Go testing (go test)
• Go modules (go.mod)
Detailed elements
• Endpoint URL and HTTP method
• Input/Output JSON schemas (request/response model fields)
• Test hooks or mention of unit test packages
• Optionally, note “no external database” to emphasize statelessness