Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
71 lines
6.6 KiB
Markdown
71 lines
6.6 KiB
Markdown
# Design
|
||
|
||
## Context
|
||
|
||
See proposal.md for the motivation. The phase 1 design is in `docs/superpowers/specs/2026-11-26-co-lite-foundation-and-leads-design.md`.
|
||
|
||
What Tastefully looks like today (commit `8bd93d15`):
|
||
|
||
- There is no root pom. Each module is a standalone Spring Boot 3.2.8 app with its own parent and pulls `com.solvway.core:solvway-core-libs:${core-project.version}` (`tastefully-v1`) from `~/.m2`. Babyboo uses `babyboo-v1` at the same coordinates.
|
||
- Every service listens on port 80. The gateway resolves services by hostname from `app.services.name.*`: `service-auth`, `service-system`, `service-counter` and so on. These are the k8s service names.
|
||
- MySQL holds one schema per service (`service-system`, `service-counter`, `service-member`, `service-log`, `service-email`). Tables are managed by hand-written DDL; there is no `ddl-auto` and no Flyway. No full DDL exists in the repo.
|
||
- Config comes from environment variables: `MYSQLHOST`, `MYSQLPORT`, `MYSQLUSER`, `MYSQLPWD`, `REDISHOST`, `GCP_PROJECT`, `GCP_CREDENTIAL_FILE`, `APIGATEWAYURL` and `AES_SECRET_KEY`.
|
||
- Pub/Sub inbound adapters are declared in each service's `PubSubConfig` (system 7, counter 12, member 12, log 3, email 3). Some serve flows Co-Lite drops (stockist, Jumio, Camunda). They stay, so each subscription must exist in the emulator.
|
||
- The Dockerfiles use the base image `gitea.containerverse.dev/solvway/docker-java-21`, `ADD target/*.jar` and `-Dspring.profiles.active=$BUILD_PROFILE`.
|
||
|
||
## Goals / Non-Goals
|
||
|
||
**Goals:**
|
||
- Bring the stack up from a clean clone with two commands: build, then up.
|
||
- Use the same hostnames and ports as k8s, so change 5 reuses the images and env contract unchanged.
|
||
|
||
**Non-Goals:**
|
||
- Any admin API, lead table or portal trimming. Those belong to changes 2–4.
|
||
- Removing dead code inside kept modules beyond what stops compilation or startup.
|
||
- Running the Next.js apps inside compose. They run with `npm run dev`.
|
||
|
||
## Decisions
|
||
|
||
1. **Copy with `git archive` at pinned commits.** Tastefully `8bd93d15` and babyboo `f64d096ea`. Only tracked files come across: no `node_modules`, `target` or stray files.
|
||
- Alternative: `cp -r`. Rejected because it drags in untracked junk and possibly local secrets.
|
||
|
||
2. **Root aggregator pom.** Add a `pom.xml` with `<packaging>pom</packaging>` that lists the kept modules, with `solvway-core-libs` and `solvway-core-session` first. Module poms keep their own Spring Boot parent. The aggregator only orders the reactor, so `mvn -T 1C verify` at the root builds everything.
|
||
- Alternative: a shared parent. Rejected because it would rewrite every module pom for no phase-1 gain.
|
||
|
||
3. **core-libs version `colite-v1`.** Set it in `solvway-core-libs/pom.xml`, and set `core-project.version` in every kept module. The same applies to `solvway-core-session` if it is versioned the same way.
|
||
|
||
4. **Compose mirrors k8s.** Compose service names equal the k8s names (`service-auth`, `service-system`, `service-counter`, `service-member`, `service-log`, `service-email`, `api-gateway`, `mobile-api`). Each service listens on port 80 inside its container. Only `mobile-api` and `api-gateway` are published to the host, on 8080 and 8081.
|
||
- Images are built from the existing Dockerfiles with `BUILD_PROFILE=local`.
|
||
|
||
5. **`local` Spring profile per module.** Add an `application-local.yml` that sets `spring.cloud.gcp.pubsub.emulator-host: pubsub:8085` and `spring.cloud.gcp.project-id: co-lite-local`. It also disables the credentials-file requirement where the emulator needs that. All other values still come from the env file `local/.env.example`, with dev-only values; a copied `.env` is git-ignored.
|
||
|
||
6. **Pub/Sub emulator plus an init job.** A one-shot container creates every topic and subscription from `local/pubsub/topics.txt`, one `topic subscription` pair per line, before the services start (`depends_on: condition: service_completed_successfully`). The list is extracted from the kept modules' `PubSubConfig` classes and resolved property values.
|
||
|
||
7. **Seed from the user's Tastefully dump.** MySQL runs its official image's `/docker-entrypoint-initdb.d`. It runs only on an empty volume, which gives first-start seeding for free.
|
||
- Files, in run order:
|
||
1. `01-schema.sql`: schema-only dump of the five schemas.
|
||
2. `02-reference.sql`: reference-table rows (roles, modules/menus, system_property, location_hierarchy and other lookup tables, chosen per table).
|
||
3. `03-colite.sql`: one company and one admin user, with a bcrypt hash of a dev-only password documented in `local/README.md`.
|
||
- Reset is `docker compose down -v`.
|
||
- **Location:** `local/seed/`. Decided by the user: runnable dev seed files are a documented exception to the SQL-placement rule (see `CLAUDE.md`), because the change folder moves when the change is archived and would break the compose mount.
|
||
- **Source:** the user supplies a schema-only dump and a reference-table data dump, not a full dump. Customer data from Tastefully never enters this repo or the local database.
|
||
|
||
8. **Smoke check is `local/smoke.sh`.** It runs `curl -fsS` against `http://localhost:8080/api/event/upcomingEvent` (mobile-api → gateway → service-counter → MySQL), prints the status code, and exits non-zero on failure. The task confirms the endpoint is public; if it is not, the task picks another public counter-backed endpoint and records the choice here.
|
||
|
||
9. **Dropped-service references.** HTTP calls to dropped services are strings; they compile and only fail if called, so they stay. Remove only these:
|
||
- gateway routes whose `uri` points at a dropped service (bonus, payment, inventory, stockist, wallet and similar);
|
||
- any bean or config that fails at startup without a dropped service.
|
||
- Each removal is listed in the task's commit message.
|
||
|
||
## Risks / Trade-offs
|
||
|
||
- [The base image `gitea.containerverse.dev/solvway/docker-java-21` needs registry access] → The README documents `docker login gitea.containerverse.dev`. If access is a blocker, use `eclipse-temurin:21-jre` locally only.
|
||
- [The dump may contain customer data in tables thought to be reference data] → Reference rows are dumped per table from an allow-list, and the diff is reviewed before commit (spec scenario "Seed contains no customer data").
|
||
- [The schema dump drifts from the entity mappings] → The smoke check and service startup catch it, and change 2–4 tests run against the seeded schema.
|
||
- [Subscriptions are missed in the emulator] → The services fail at startup. The "stack starts healthy" scenario checks the logs.
|
||
- [Six JVMs plus MySQL use about 6 GB of RAM] → Set `JAVA_OPTS=-Xmx384m` per service in compose.
|
||
|
||
## Migration Plan
|
||
|
||
None. This is a new repo with nothing deployed. Rollback is reverting the commits.
|