{"id":28862670,"url":"https://github.com/30piraten/buddy-backend","last_synced_at":"2025-10-14T17:10:09.463Z","repository":{"id":291590182,"uuid":"977745084","full_name":"30Piraten/buddy-backend","owner":"30Piraten","description":"Building the backend for Buddy.me (RHIA). This is the core data phase and its connection to RHIA. ","archived":false,"fork":false,"pushed_at":"2025-05-17T13:36:37.000Z","size":73390,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-20T06:37:54.459Z","etag":null,"topics":["golang","grpc","postgresql","protobuf","sqlc"],"latest_commit_sha":null,"homepage":"https://rayvah.cc/buddy","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/30Piraten.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}},"created_at":"2025-05-04T21:51:27.000Z","updated_at":"2025-05-17T13:36:40.000Z","dependencies_parsed_at":"2025-06-20T06:43:18.901Z","dependency_job_id":null,"html_url":"https://github.com/30Piraten/buddy-backend","commit_stats":null,"previous_names":["30piraten/buddy-me","30piraten/buddy-backend"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/30Piraten/buddy-backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/30Piraten%2Fbuddy-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/30Piraten%2Fbuddy-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/30Piraten%2Fbuddy-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/30Piraten%2Fbuddy-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/30Piraten","download_url":"https://codeload.github.com/30Piraten/buddy-backend/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/30Piraten%2Fbuddy-backend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279020087,"owners_count":26086805,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"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":["golang","grpc","postgresql","protobuf","sqlc"],"created_at":"2025-06-20T06:31:06.483Z","updated_at":"2025-10-14T17:10:09.458Z","avatar_url":"https://github.com/30Piraten.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📘 Phase 1 Documentation: Backend Foundations\n\n## 🧭 Overview\n\nPhase 1 of buddy.me focused on building the **system of record**—the core backend foundation modeling users, roadmaps, and checkpoints. The priority was simplicity: to get records that work and are easily testable. Modifications can be applied at a later statge. Phase 1 will also lay the groundwork for RHIA and user-facing logic.\n\n![backend sample](new.gif)\n\n---\n\n## 🏗️ Architecture Summary\n\n| Layer     | Tools/Tech         | Notes                                                                 |\n| --------- | ------------------ | --------------------------------------------------------------------- |\n| Transport | gRPC               | Contract-based APIs with strict versioning via Protobuf               |\n| Database  | PostgreSQL         | Declarative schema management and migrations with `sqlc`              |\n| Queries   | SQLC               | Typed, compiled queries; Go bindings separate from SQL logic          |\n| Testing   | pgx.Tx             | Table-driven tests with rollback isolation for reliable state cleanup |\n| Logging   | Zerolog            | Fast, structured logging                                              |\n| Contracts | Protobuf v1        | Defined in `proto/*/v1`, backward compatible                          |\n| Dev UX    | grpcurl + Makefile | Reproducible gRPC calls, format/lint/test runners                     |\n\n---\n\n## 📦 Modules\n\n### 1. Users\n\n**Entity:**\n\n```protobuf\nmessage User {\n  string id = 1;\n  string username = 2;\n  string name = 3;\n  string email = 4;\n  google.protobuf.Timestamp created_at = 5;\n}\n```\n\n**Endpoints:**\n\n* `CreateUser`\n* `GetUser`\n* `ListUsers`\n* *(UpdateUser and DeleteUser: deferred to Phase 2)*\n\n**Testing:**\n\n* Full test coverage using `pgx.Tx` isolation\n* Table-driven format with multiple scenarios\n* grpcurl script validation (via `make \u0026 grpcurl`)\n\n---\n\n### 2. Roadmaps\n\n**Entity:**\n\n```protobuf\nmessage Roadmap {\n  string id = 1;\n  string title = 2;\n  string description = 3;\n  string type = 4;\n  string status = 5;\n  google.protobuf.Timestamp created_at = 6;\n}\n```\n\n**Endpoints:**\n\n* `CreateRoadmap`\n* `GetRoadmap`\n* `ListRoadmaps`\n* `DeleteRoadmap`\n\n**Design Notes:**\n\n* System-authored (admin-only)\n* Non-editable by users\n* Acts as curriculum scaffolding for shared progress\n\n---\n\n### 3. Checkpoints\n\n**Entity:**\n\n```protobuf\nmessage Checkpoint {\n  string id = 1;\n  string roadmap_id = 2;\n  string title = 3;\n  int32 sequence = 4;\n  string summary = 5;\n  google.protobuf.StringValue next_step = 6;\n}\n```\n\n**Endpoints:**\n\n* `CreateCheckpoint`\n* `GetCheckpoint`\n* `ListCheckpoints`\n* `DeleteCheckpoint`\n\n**Design Notes:**\n\n* Tied to roadmaps; each checkpoint is a sequence step\n* Not modifiable or deletable by users\n* Users can skip checkpoints, like optional modules\n\n---\n\n### 4. Events *(Stubbed for Phase 2)*\n\n* Placeholder schema for event logging (e.g., completed checkpoint)\n* Will be consumed by RHIA in Phase 2\n\n---\n\n## 🔍 Testing Strategy\n\n* **pgx.Tx Rollback:** Each test wrapped in a transaction rollback for isolation\n* **Timeout Contexts:** Prevents long-running tests and improves feedback loops\n* **Table-Driven Style:** Reusable helpers, clean assertions, edge case enumeration\n* **grpcurl Verification:** Ensures interface contracts hold under manual and scripted invocations\n\n---\n\n## 🖼️ Supplemental Docs \u0026 Artifacts\n\nTo be placed under `docs/`:\n\n* [`docs/users/README.md`](./docs/users/README.md) =\u003e (protobuf + handler + test breakdown)\n* `docs/roadmaps/README.md`\n* `docs/checkpoints/README.md`\n* ERD diagram\n* grpcurl screenshots / CLI examples\n* Test output + code snippets\n* Visual diagrams of entity relations and flows\n\n---\n\n## 🧾 Future Developer Articles (Draft Concepts)\n\n### 1. **Designing a System of Record in Go + PostgreSQL**\n\n* Why SQLC over ORMs\n* `pgx.Tx` testing methodology\n* How versioning and protobuf contracts provide stability\n\n### 2. **Why Roadmaps Aren’t Editable: Designing for Progress, not Preference**\n\n* Gamified structure vs. user agency\n* Avoiding overchoice: product philosophy\n* Like Duolingo, but for growth\n\n### 3. **Building Intent-first APIs with Protobuf and gRPC**\n\n* Designing for precision and clarity\n* Thinking from usage, not just data\n* Making endpoints reflect product intentions\n\n---\n\n## ✅ Phase 1 Completion Criteria (All Done)\n\n| Task                              | Status |\n| --------------------------------- | ------ |\n| Users CRUD via gRPC               | ✅      |\n| Roadmaps CRUD via gRPC (admin)    | ✅      |\n| Checkpoints CRUD via gRPC (admin) | ✅      |\n| pgx.Tx test coverage              | ✅      |\n| grpcurl interface tests           | ✅      |\n| Logging \u0026 migrations              | ✅      |\n| Structured Makefile               | ✅      |\n| Docs draft for Phase 1            | ✅      |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F30piraten%2Fbuddy-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F30piraten%2Fbuddy-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F30piraten%2Fbuddy-backend/lists"}