A Golang-based microservice for registering and monitoring the health of HTTP URLs. Built with idiomatic Go and clean architecture, it’s designed for production-ready reliability and maintainability.
- Register and track the health of HTTP URLs
- Manually update URL status (automated cron checks planned)
- Clean architecture (Handler → Service → Storage)
- PostgreSQL storage via
pgxpool - Idiomatic, production-grade Go codebase
hcaas/
├── cmd/
│ └── server/
│ └── main.go # Application entry point
├── handler/ # HTTP handlers (Chi-based)
├── model/ # URL struct definitions
├── service/ # Business logic
├── storage/ # PostgreSQL storage layer
├── .env # Environment variable config
├── .env.example # Example environment config
├── go.mod # Go module dependencies
├── go.sum # Dependency checksums
├── README.md # Project documentation
- Language: Go 1.22+
- HTTP Router: Chi
- Database: PostgreSQL (via pgxpool)
- Architecture: Clean layered architecture (Handler → Service → Storage)
- Go: 1.22 or higher
- PostgreSQL: A running instance (local or remote)
- Git: For cloning the repository
git clone https://github.com/samims/hcaas
cd hcaasCopy the example environment file:
cp .env.example .envUpdate .env with your PostgreSQL configuration:
DATABASE_URL=postgres://username:password@localhost:5432/yourdb?sslmode=disableReplace username, password, and yourdb with your PostgreSQL credentials.
go mod tidygo run ./cmd/serverThe service starts on http://localhost:3000 (default port).
| Method | Endpoint | Description |
|---|---|---|
POST |
/urls |
Register a new URL for monitoring |
GET |
/urls |
List all monitored URLs |
PATCH |
/urls/{id} |
Update health status of a URL |
Register a new URL to monitor.
Request Body:
{
"address": "https://example.com"
}Note: Health checks currently use GET by default. Support for other HTTP methods is planned.
Response:
{
"id": "e2c1b7f4-6d04-4fc6-a1de-2cf85801f645",
"address": "https://example.com",
"status": "unknown",
"checked_at": "2025-07-21T12:05:07Z"
}Status: 201 Created
List all monitored URLs.
Response:
[
{
"id": "e2c1b7f4-6d04-4fc6-a1de-2cf85801f645",
"address": "https://example.com",
"status": "up",
"checked_at": "2025-07-21T12:00:00Z"
}
]Update the health status of a URL (used internally for now).
Request Body:
{
"status": "down"
}Response:
{
"id": "e2c1b7f4-6d04-4fc6-a1de-2cf85801f645",
"address": "https://example.com",
"status": "down",
"checked_at": "2025-07-21T12:05:30Z"
}Status: 200 OK
Test the API using the following cURL commands:
# Add a URL
curl -X POST http://localhost:3000/urls \
-H "Content-Type: application/json" \
-d '{"address": "https://example.com"}'
# List URLs
curl http://localhost:3000/urls
# Update status
curl -X PATCH http://localhost:3000/urls/e2c1b7f4-6d04-4fc6-a1de-2cf85801f645 \
-H "Content-Type: application/json" \
-d '{"status": "up"}'HCaaS follows a clean architecture with three layers:
- Handler: Manages HTTP requests and responses using Chi.
- Service: Handles business logic for URL registration and health checks.
- Storage: Persists data to PostgreSQL via
pgxpool.
This modular design ensures testability and scalability.
- Idiomatic Go: Simple, readable, and maintainable code.
- Separation of Concerns: Handlers delegate to services, which interact with storage.
- Interface-Driven: Enables easy mocking for testing.
- Extensible: Designed for future features like cron-based checks.
- PostgreSQL integration
- RESTful API with Chi
- Automated cron-based health checks
- Support for additional HTTP methods
- Alerts (email, webhooks)
- Authentication and rate limiting
- Comprehensive test suite with mocks
Samiul Sk
Senior Software Engineer
Kolkata, India
Passionate about microservices, Go, and scalable system design.
LinkedIn | GitHub
This project is licensed under the MIT License.
Contributions are welcome! Please:
- Fork the repository.
- Create a feature branch (
git checkout -b feature/xyz). - Submit a pull request with clear descriptions.
See CONTRIBUTING.md for details. Report issues or suggest features on GitHub.
Want to enhance this project? Let me know if you’d like:
- A
Dockerfileanddocker-compose.ymlfor containerized deployment - A Mermaid diagram illustrating the architecture
- A
docs/folder structure for GitHub Pages - Additional badges (e.g., code coverage, last commit)
⭐️ Feel free to fork, improve, or use this as a portfolio project!