A service to allow licensees to report individual pieces of data (text, image, audio, video, animation) that may be in violation of laws or regulations (e.g. contains PII). The service accepts structured violation reports and returns a report ID for tracking and audit purposes.
- The service runs as a single instance (no load balancing or distributed coordination needed).
- No persistence is required — reports are processed and acknowledged, but not stored.
- The backend is implemented in Go, using gRPC and gRPC-Gateway to expose both REST and gRPC interfaces.
- A valid Bearer token is required to access the endpoint (currently a static token for development/testing).
- Protobuf definitions are managed via Buf and used to generate server and client code.
- Mock interfaces are generated using Mockery.
We use mise to manage the dependencies and tasks for running this project.
- Install mise
curl https://mise.run | sh
- Clone this repo, trust the mise config and install the dependencies
git clone https://github.com/will-rowe/hn && cd hn
mise trust .
mise install
- Generate the required files
mise tasks run generate
- Run the linting and tests:
mise tasks run test
- Start the server with Docker Compose (with an initial run of the e2e):
mise tasks run start
- Run the full end-to-end test (starts the server, runs the e2e test, then exits):
mise tasks run e2e
The API exposes a single endpoint:
POST /v1/reports
Authorization: Bearer <token>
Content-Type: application/json
{
"dataset_id": "abc123",
"data_id": "def456",
"media_type": "MEDIA_TYPE_TEXT",
"violation_type": "VIOLATION_TYPE_PII",
"description": "This contains personally identifiable information."
}
{
"report_id": "report-uuid",
"status": "RECEIVED"
}
The API is defined via Protobuf (report.proto
) and includes both REST and gRPC bindings.
- All handler and service logic is unit tested using testify.
- The
ReportServiceInterface
is mocked using Mockery. - Tests cover validation, correct response behavior, and error cases.
- Run with:
mise tasks run test
Use Go’s built-in benchmarking tools to measure performance of critical functions like ProcessReport()
:
func BenchmarkProcessReport(b *testing.B) {
svc := NewReportService()
req := &report.ReportRequest{
DatasetId: "ds1", DataId: "data1", Description: "Contains PII",
MediaType: report.MediaType_TEXT, ViolationType: report.ViolationType_PII,
}
for i := 0; i < b.N; i++ {
_, _ = svc.ProcessReport(context.Background(), req)
}
}
Run benchmarks with:
go test -bench=. ./backend/reporting
You can use pprof
for deeper CPU and memory profiling.
You can run the server locally and send a report using curl
:
go run main.go
Then, in another terminal:
curl -X POST http://localhost:8080/v1/reports \
-H "Authorization: Bearer testtoken" \
-H "Content-Type: application/json" \
-d '{
"dataset_id": "abc123",
"data_id": "def456",
"media_type": "MEDIA_TYPE_TEXT",
"violation_type": "VIOLATION_TYPE_PII",
"description": "Contains a full name and email address"
}'
A valid JSON response with report_id
and status
should be returned.