Repository navigation
refactor: organise code by domain with a service layer - #3
Merged
Merged
Conversation
Split HTTP handling from business logic. Each domain (datapoints, recall, webhooks) now holds its model, a service with the use cases, and an http module that only parses requests, calls the service and shapes responses. Services return domain results and a transport-agnostic ServiceError, which the shared http module maps to the error envelope. No change to the HTTP contract or storage layout.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The API handlers were doing everything: parsing requests, validating, running the use case (locks, idempotency markers, embedding, write order) and building responses. This PR separates HTTP handling from business logic and organises the code by domain instead of by layer.
*/http.rs) only parse the request, call the service and shape the response. Each domain registers its ownroutes(), andhttp::routermerges them.DeleteCommand,RecallQuery,ListQuery, …) and return domain results, e.g.Ingestedwith an outcome ofCreated,DeduplicatedorReplaced. The handler turns that into a status code and response flags.ApiErrorwrapsServiceError, plus the errors that only exist over HTTP (malformed request, body too large). Error codes, statuses and the envelope are unchanged.authenticateand thenreceive, so a wrong id or token still returns 404 before the body is checked.CONTRIBUTING.mdcode layout updated.No change to the HTTP contract or storage layout. The tests only needed import and path changes.