Organize backend into product executable and shared Go modules

This commit is contained in:
Stephan D committed 2026-09-12 14:14:08 +02:00
1 parent 981e84a4b4
commit f0720ec66b
382 files changed
+1944 -6989

No files matched your search

+32 -25
View File
@@ -15,26 +15,30 @@ and allowed to diverge within this repository.
Source: `S_I/sendico`, commit `8bb20dcd622dd8eb92d289b6b34411e7eccab083`.
The source checkout's unrelated dependency edits were not copied.
| Local component | Reused implementation |
| --- | --- |
| `backend/edge/shared` | Chi HTTP runtime, middleware, JWT login/pending sessions, refresh/rotation/logout, CSRF/cookies, rate limiting, Mongo verification and refresh-token stores |
| `backend/edge/product/interface/accountservice` | Account validation, bcrypt passwords, atomic customer creation, activation tokens, password reset and email-change token issuance, deletion |
| `backend/pkg` | Canonical local account/domain models, Mongo repositories/transactions, errors, structured logging, process bootstrap and health |
| `backend/internal/profile` | Small SXCHNGE composition layer selecting the copied local account service |
| `backend/contracts/sendico` | Separate snapshot of Sendico's public OpenAPI contract and its referenced schemas |
`backend/` groups Go modules. The implemented executable is `backend/product`,
with its own `main.go` and `go.mod`. `backend/shared` is a separate library module.
Backoffice will be a separate executable module (`backend/backoffice`) with its
own entry point, operator identity, configuration and deployment. Product's entry
point is not the entry point for every future backend.
Source provenance and the bounded adaptations are in
[PROVENANCE.md](../../backend/PROVENANCE.md). There is no sibling source import,
private Sendico module requirement, gRPC client, discovery subscription or broker
connection. Platform engines and Product's platform-provisioning bootstrap were
not copied. The original handwritten shell and tiny replacement helpers were removed.
| Owner | Retained implementation |
| --- | --- |
| `product/app` | HTTP runtime, startup, composition and health |
| `product/customers` | Local customer models, service and account repository |
| `product/auth` | Login/protected routes, local DTOs/mappers and auth configuration |
| `product/sessions` | Session/client models, refresh storage, cookies and token generation |
| `product/verification` | Verification models, configuration and storage |
| `shared` | Generic database/transaction/query code, errors, logging and HTTP helpers |
Shared infrastructure imports no executable module. Customer repositories are
constructed by the product module rather than the generic database factory.
There is no global customer/session model package or Sendico `edge/product`
source hierarchy. Source provenance follows the moved files across Go modules.
Local customers have no organization membership, roles, policies or tenant ID.
The account service validates and hashes passwords, creates an account and
activation token atomically, and deletes an account with session revocation.
Customer responses map to explicit local DTOs. Account, token and session collections and application client records belong only
to SXCHNGE. The runtime starts without any policy or tenant seed. Casbin,
invitations, financial models and provisioning machinery are excluded.
Creation validates/hashes passwords and commits the account and activation token
atomically. Deletion revokes that customer's sessions. The runtime starts without
any seed. Casbin, invitations and platform provisioning are absent.
## Identity and ownership
@@ -57,9 +61,11 @@ Confirm the deployed credential policy before configuring a provider client.
## Contract and service structure
The copied OpenAPI files are a pinned upstream wire contract, not SXCHNGE's app
API or domain model. Preserve them as an isolated snapshot. Changes require an
explicit contract update; do not follow Sendico source updates automatically.
The bootstrap has no Sendico runtime calls and therefore no copied public wire
snapshot. When implementing an adapter, keep only its consumed request/response
contracts within that adapter. Pin their upstream revision separately from local
customer DTOs/models; do not copy the entire platform contract or synchronize
source automatically.
When wiring a feature, keep the existing architecture:
@@ -73,13 +79,13 @@ or replace local account services with Sendico login/customer calls.
The next adapter will use a configured public HTTPS base URL, a fixed organization
reference, bounded request timeouts and an injected HTTP transport. It must reject
cross-origin credential redirects. Reuse the existing public contract and response
conventions; do not invent a parallel provider facade or call internal services.
cross-origin credential redirects. Use the public contract and response
conventions for each implemented operation; do not invent a parallel provider facade or call internal services.
## Required public Sendico capabilities
The snapshot is API version 4.2.37. Source routes and schemas establish available
shapes; they do not prove that a deployment enables every feature.
The source reviewed at the pinned revision describes API version 4.2.37. Its
public routes and schemas establish available shapes; they do not prove that a deployment enables every feature.
| Need | Existing public surface / work required |
| --- | --- |
@@ -120,7 +126,8 @@ operation details explain what has happened and what remains pending.
## Current delivery boundary
This task supplies the copied starting point and isolated public contracts.
This task supplies the selected copied starting point in independently buildable
Go modules and a public API integration plan.
The local runtime installs the existing authentication transport and account
service. Local signup/profile HTTP endpoints, verification delivery/completion,
application client setup, Flutter HTTP adapters and live Sendico calls
+31 -1
View File
@@ -379,7 +379,8 @@ Retained Sendico source is pinned to `8bb20dcd622dd8eb92d289b6b34411e7eccab083`:
HTTP runtime, local customer/password service and Mongo repository, customer
sessions and verification storage, generic repository/transaction code, errors,
logging and health. [Provenance](../backend/PROVENANCE.json) covers 232 retained
Go files and 112 isolated public OpenAPI files; every adaptation is flagged.
Go files at that cleanup stage; every adaptation is flagged. The later module
reorganization below removes the unused public OpenAPI snapshot.
The Sendico checkout remains unchanged.
Customer creation accepts a raw password, validates/hashes it and commits the
@@ -416,3 +417,32 @@ not been deployed. Existing experimental databases may retain unused tenancy
collections; this change does not delete external database records. Customer HTTP
responses now expose only ID, name, last name, login, locale and optional avatar.
The frontend still uses dummy services and is unchanged.
### Go module organization correction
`backend/` now groups two implemented Go modules: the runnable `product` BFF
(`main.go`, `go.mod`, configuration and feature packages) and the `shared` library
(its own `go.mod`, generic storage, errors, logging and HTTP helpers). Product uses
`replace git.sendico.io/tech/sxchnge/shared => ../shared`. A future backoffice BFF
belongs in its own `backend/backoffice` executable module; it is not implemented
or silently combined with product in this task.
Customer, session and verification models/storage now live with their features.
Shared database code no longer knows about customer repositories. Auth and
verification configurations belong to their feature packages. The inherited
`cmd`, `edge`, `internal`, `pkg`, `scripts` and `contracts` top-level folders are
removed. All 112 unused contract files are removed; future HTTP adapters will
own only consumed public wire definitions. Provenance retains the pinned upstream
source paths while recording the new local module paths.
Root Make targets validate both modules independently and run product with
`cd backend/product && go run .`. Source behavior remains the previously validated
local customer/auth/session bootstrap; frontend and Sendico source are untouched.
Validation passed after the module moves: `make test` (both Go modules with the
race detector and all frontend suites), `make lint-backend`, product executable
build and `-version` smoke check, and `go test -tags integration -run '^$' ./...`
in each Go module (compile-only for the additional tagged suites). All 233
provenance source blobs match the pinned revision. `git diff --check` passed.
No security scans were requested or run. The correction is delivered on `bff-34`
in [PR #35](https://git.sendico.io/tech/sxchnge/pulls/35), which remains unmerged.