{"id":51126777,"url":"https://github.com/abitofhelp/dictionary_stdlib","last_synced_at":"2026-06-25T08:32:18.524Z","repository":{"id":350419560,"uuid":"1203672726","full_name":"abitofhelp/dictionary_stdlib","owner":"abitofhelp","description":"An educational REST service implemented exclusively with Ada 2022’s standard library.","archived":false,"fork":false,"pushed_at":"2026-04-10T08:09:14.000Z","size":686,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-10T10:24:27.981Z","etag":null,"topics":["2022","ada","api","containerd","docker","educational","kubernetes","rest","stdlib","tutorial"],"latest_commit_sha":null,"homepage":"","language":"Ada","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abitofhelp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-07T09:01:39.000Z","updated_at":"2026-04-10T08:09:15.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/abitofhelp/dictionary_stdlib","commit_stats":null,"previous_names":["abitofhelp/dictionary_stdlib"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/abitofhelp/dictionary_stdlib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abitofhelp%2Fdictionary_stdlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abitofhelp%2Fdictionary_stdlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abitofhelp%2Fdictionary_stdlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abitofhelp%2Fdictionary_stdlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abitofhelp","download_url":"https://codeload.github.com/abitofhelp/dictionary_stdlib/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abitofhelp%2Fdictionary_stdlib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34767543,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-25T02:00:05.521Z","response_time":101,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["2022","ada","api","containerd","docker","educational","kubernetes","rest","stdlib","tutorial"],"created_at":"2026-06-25T08:32:15.426Z","updated_at":"2026-06-25T08:32:18.502Z","avatar_url":"https://github.com/abitofhelp.png","language":"Ada","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dictionary_Stdlib — Ada 2022 REST Microservice\n\n[![License](https://img.shields.io/badge/license-BSD--3--Clause-blue.svg)](LICENSE) [![Ada](https://img.shields.io/badge/Ada-2022-blue.svg)](https://ada-lang.io) [![Alire](https://img.shields.io/badge/Alire-2.0+-blue.svg)](https://alire.ada.dev)\n\n**Version:** 0.1.0-dev\n**SPDX-License-Identifier:** BSD-3-Clause\n**Copyright:** (c) 2026 Michael Gardner, A Bit of Help, Inc.\n\n\u003e **Educational Project** — This microservice is a teaching tool for engineers\n\u003e learning to build safe, concurrent network services with Ada 2022.\n\u003e Production-level features such as TLS, graceful shutdown, persistent storage,\n\u003e structured logging, connection pooling, and comprehensive error recovery were\n\u003e intentionally omitted to keep the focus on core concepts. See\n\u003e [Intentional Simplifications](#intentional-simplifications) for a complete\n\u003e list of what was left out and why.\n\nA key-value dictionary exposed as a RESTful HTTP/1.1 service, built\nentirely from Ada 2022 standard library packages — **no third-party\ncrates**. The service parses HTTP from raw TCP sockets, demonstrating\nwhat frameworks abstract away.\n\n## What This Project Teaches\n\n| Concept | Where to Look |\n|---------|---------------|\n| Generic programming | `dictionary-bounded_text.ads` — one generic, two instantiations |\n| Pre/Post contracts | `dictionary-validation.ads` — every public function is contracted |\n| Protected objects | `dictionary-store.ads` — concurrent readers, exclusive writers |\n| Ada tasking | `dictionary-server.adb` — task-per-connection concurrency |\n| TCP socket programming | `dictionary-server.adb` — GNAT.Sockets accept loop |\n| HTTP/1.1 wire format | `dictionary-http.adb` — hand-parsed request line, headers, body |\n| JSON at the byte level | `dictionary-json.adb` — hand-rolled parse and serialize |\n| Bounded types | `dictionary-types.ads` — no heap allocation for domain data |\n| Discriminated records | `dictionary-types.ads` — `Entry_Result` as a lightweight Option |\n| Static dispatch routing | `dictionary-router.adb` — direct calls, no tagged types |\n\n## Three-Project Roadmap\n\n1. **This project** — standard library only (educational, protocol-level)\n2. **Crate-based version** — same API using Ada Web Server + JSON crates\n3. **Hybrid enterprise** — full DDD / Clean / Hexagonal architecture\n\n## API Reference\n\n| Method | Path | Purpose | Success | Errors |\n|--------|------|---------|---------|--------|\n| `POST` | `/entries` | Create an entry | 201 | 400, 409 |\n| `GET` | `/entries/{key}` | Retrieve one entry | 200 | 404 |\n| `GET` | `/entries` | List all (sorted by key) | 200 | — |\n| `PUT` | `/entries/{key}` | Update value (strict) | 200 | 400, 404 |\n| `DELETE` | `/entries/{key}` | Remove an entry | 204 | 404 |\n| `GET` | `/health` | Health check | 200 | — |\n\n### Key Rules\n\n- `[a-zA-Z0-9-]+`, max 50 characters, **case-insensitive** (stored lowercase)\n- Unique — duplicate keys return `409 Conflict`\n\n### Value Rules\n\n- Non-empty printable ASCII (space through tilde), max 200 characters\n\n### Design Decisions\n\n- **No PATCH** — With a single mutable field (value), PATCH and PUT would\n  be identical. PUT suffices. This is itself a teaching point: use PATCH\n  when a resource has multiple independently updatable fields.\n- **PUT is strict update** — Returns 404 if the key does not exist. POST\n  is the only way to create entries. This enforces clear REST semantics.\n- **Max 100 entries** — The store is bounded to teach resource-limit\n  awareness. A production service would use persistent storage.\n\n### Example Usage\n\n```bash\n# Health check\ncurl http://localhost:8080/health\n\n# Create\ncurl -X POST http://localhost:8080/entries \\\n  -d '{\"key\":\"hello\",\"value\":\"A common greeting\"}'\n\n# Read\ncurl http://localhost:8080/entries/hello\n\n# List all (sorted by key ascending)\ncurl http://localhost:8080/entries\n\n# Update\ncurl -X PUT http://localhost:8080/entries/hello \\\n  -d '{\"key\":\"hello\",\"value\":\"An updated greeting\"}'\n\n# Delete\ncurl -X DELETE http://localhost:8080/entries/hello\n```\n\n## Building\n\n### Prerequisites\n\n- Docker with the `dev-container-ada` image running\n- The project is mounted at `/workspace/dictionary` inside the container\n\n### Build Commands\n\nAll builds happen inside the dev container:\n\n```bash\nmake build           # Development build\nmake build-release   # Release build (optimized)\nmake run             # Build and start the server\nmake clean           # Clean build artifacts\nmake rebuild         # Clean + build\nmake help            # Show all available targets\n```\n\n### Docker (Production Image)\n\n```bash\nmake docker-build    # Multi-stage build (~93 MB image)\nmake docker-run      # Run on port 8080 (nonroot, read-only)\nmake docker-stop     # Stop the container\nmake docker-test     # Build, run, and exercise all endpoints\nmake docker-clean    # Remove the image\n```\n\nOr with docker-compose:\n\n```bash\ndocker compose up --build     # Build and start\ndocker compose down           # Stop\n```\n\nThe production image:\n- Runs as nonroot user `app` (UID 10000)\n- Uses a read-only root filesystem\n- Exposes port 8080\n- Includes a health check on `/health`\n- Is Kubernetes-ready (use `httpGet` liveness/readiness probes)\n\n## Project Structure\n\n![Project Structure](docs/diagrams/project_structure.svg)\n\n## HTTP-Only Scope\n\nThis service uses HTTP, not HTTPS. The Ada standard library and GNAT\nruntime do not include TLS support. Adding TLS would require C bindings\nto OpenSSL or GnuTLS, or a third-party Ada library — both outside the\nscope of a standard-library-only project.\n\nThis is an **intentional scope decision**, not a limitation of Ada itself.\nAda can and does bind to TLS libraries in production systems. The\ncrate-based version of this project will include HTTPS support.\n\n## Intentional Simplifications\n\nThis project prioritizes **clarity and learning** over production\nreadiness. The following are known limitations, not oversights:\n\n| Area | Simplification | Production Alternative |\n|------|---------------|----------------------|\n| **TLS** | HTTP only | TLS via OpenSSL bindings or Ada Web Server |\n| **Concurrency** | Tasks leak memory on termination | Bounded task pool with reuse |\n| **Shutdown** | No graceful shutdown; Ctrl+C terminates | Signal handler, drain connections |\n| **Timeouts** | No socket read/write timeouts | `SO_RCVTIMEO` / `SO_SNDTIMEO` or `select()` |\n| **Keep-alive** | `Connection: close` on every response | HTTP/1.1 persistent connections |\n| **Request size** | Fixed 8 KB buffer, no chunked encoding | Streaming parser, chunked transfer |\n| **JSON** | Hand-rolled, only `\\\"` and `\\\\` escapes | Production JSON library |\n| **HTTP parsing** | Simplified subset; version token not validated | Full HTTP/1.1 compliance |\n| **Persistence** | In-memory only; data lost on restart | Database or file-backed storage |\n| **Logging** | Minimal `Text_IO` to stderr | Structured logging with levels |\n| **Validation** | Basic character checks | Full URI decoding, content-type negotiation |\n| **CORS** | Not implemented | `Access-Control-*` headers |\n| **Rate limiting** | Not implemented | Token bucket or sliding window |\n| **Error recovery** | Basic exception handler per connection | Circuit breakers, retry logic |\n\n## License\n\nBSD-3-Clause — see LICENSE file.\n\n## AI Assistance \u0026 Authorship\n\nThis project was developed with AI coding assistance (Claude). All code\nwas reviewed, tested, and approved by a human developer. The AI served as\na tool to accelerate development — all architectural decisions, design\nchoices, and final code are the responsibility of the human maintainer.\n\nAI assistants are tools. Humans are accountable.\n\n## Author\n\nMichael Gardner\nA Bit of Help, Inc.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabitofhelp%2Fdictionary_stdlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabitofhelp%2Fdictionary_stdlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabitofhelp%2Fdictionary_stdlib/lists"}