Skip to content
iVega123Public

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

 

History

287 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ProjectY

A case study in turning an audited distributed system into evidence-based architecture.

ProjectY started as four .NET microservices for motorcycle rentals: identity, fleet, rider management, and rental operations. A manual review of the code, containers, and delivery pipeline found 42 issues: 5 critical security flaws, 11 high-risk findings, 14 architectural gaps, and 12 delivery or code-quality problems. This repository preserves that real baseline and documents the decisions used to redesign it.

Start with the evidence: read the architecture and security audit, then the architecture decision records that answer it, or browse the modernization program. The accompanying article series turns the same work into public technical narratives.

The five decisions that shape the redesign

Decision What was rejected Why Decision trail
Put rental correctness in the database and use an outbox/inbox around events Application-only pre-checks, in-memory locks, and claims of transport-level "exactly once" Those approaches do not protect concurrent writers or the gap between committing data and publishing an event ADR 0001, ADR 0003
Establish one edge trust boundary Four editable copies of token and role validation inside domain services The copies had already diverged and produced an authorization bypass ADR 0008
Optimize the local feedback loop before adding cloud infrastructure Premature Kubernetes, manual setup steps, and sleep-based startup ordering A demonstrable system must start predictably and make source changes cheap ADR 0002
Treat failure tolerance as an observable behavior Generic retry policies and dashboards that cannot be traced back to a request Failure claims are credible only when they can be injected, observed, and reproduced ADR 0003
Keep deployment variants in overlays and choose dependencies by protocol Long-lived environment branches and vendor-specific contracts in workloads Branches drift; protocol boundaries preserve a credible self-hosted path and an ephemeral cloud path ADR 0004, ADR 0005

Each row links to the record that argues it, including what was rejected and at what cost. The full set is indexed in docs/adr/, beginning with the audit as ADR 0000.

What the audit changed

The service boundaries looked reasonable on paper, but the review found that the system had no effective perimeter. Anyone could register an administrator; one service accepted any valid token on an admin path; secrets and a shared JWT key were committed; rental ownership was not enforced; and queue payloads were trusted as authenticated input.

The important outcome was not the list of findings. It was the correction order: close the open entry points, rotate and externalize secrets, establish a single trust boundary, make messaging durable and idempotent, and then remove the duplicated security and messaging code. The full evidence, impact, and source locations are in the audit.

Repository state

Area Current state
Audited baseline Four ASP.NET Core services under services/: AuthGate, MotoHub, RiderManager, and RentalOperations. None of the four remains: they were merged into rental-core (#135) and identity (#136).
Data and messaging CockroachDB for rental-core, PostgreSQL for the rest, RabbitMQ, and MinIO
Active observability Application OTLP exporters, OpenTelemetry Collector, Prometheus, Tempo, Loki, and Grafana
Retired observability The unauthenticated Elasticsearch, Logstash, and Kibana stack
Platform integration Kustomize owns the shared Kubernetes topology with self-hosted and AWS overlays; Tilt provisions kind, Calico, ingress, External Secrets and signed-image admission
AWS cost profiles Low, Mid, and review-only High encode explicit RTO/RPO promises with dated fixed-cost arithmetic
Polyglot services Rust media-guard, Elixir live telemetry, asynchronous Python risk/pricing and Next.js operations console
Decision records The design and implementation trail is indexed under docs/adr/

The platform entrypoint imports the root Compose model, which builds the existing services behind the Rust gateway with the LGTM observability stack. The rental OTel resource is rental-core, and it runs on CockroachDB: motorcycles, rentals, outbox and inbox share one database, so a rental and the event that announces it are one transaction. No nonexistent application is declared.

Operate the polyglot flow

tilt up -- --full adds the four implemented services to the active stack. The console shows Phoenix positions, the real trace of a rental action, and bounded load batches beside queue depth, rate limits and p99. See the runbook for startup, identity requirements and the isolated test profile. Runtime and datastore costs are recorded in ADR 0022.

Live rental tracking

Trace x-ray · Load generator · Tracking stopped · Measured API trace

Branches

main carries every deployment variant as an overlay, so a fix lands once. Branches named article/NN-* are frozen citations cut when an article is published: they are never maintained and never accept pull requests. Epic work uses task/<issue>-* → epic/<issue>-* → main, with validated task PRs first. The reasoning is in ADR 0005.

The AWS roots are infra/envs/aws-low, layered infra/envs/aws-mid, and the mock-plan-only infra/envs/aws-high. Choose one by its recovery promise, not by its headline budget; the cost profile comparison states what each topology survives and which usage charges remain outside the estimate.

Run locally

See Running the audited baseline locally. This code contains known security flaws and development credentials; use it only in an isolated local environment.

Use the telemetry correlation runbook to verify metric-to-trace, trace-to-log, log-to-trace, and service-graph links in the running LGTM stack.

The rental creation SLO and error-budget policy defines the 30-day availability and latency objectives, paging thresholds, and the release decision made when the budget is exhausted.

Database-backed tests use the shared PostgreSQL Testcontainers pattern. State-changing API retries follow the shared Idempotency-Key contract.

Kubernetes development loop

The root Tiltfile now uses Kubernetes by default. It bootstraps a pinned kind cluster, a local registry, Calico, ingress-nginx, External Secrets, cert-manager and Kyverno before deploying the shared deploy/base topology through the selfhost Kustomize overlay. See the local Kubernetes runbook for prerequisites, resource sizing, security proofs and troubleshooting. Start everything with:

tilt up

On the first run, Tilt invokes scripts/New-LocalSecrets.ps1 to generate the ignored .env and .rabbitmq-definitions.json files with random local-only credentials. Existing files are never overwritten, so later starts preserve the same local data credentials.

The two files are one credential set. If exactly one is missing, Tilt stops instead of silently rotating the other and desynchronizing persistent volumes. To recover intentionally, stop the stack, remove volumes initialized with the old credentials, and run powershell -ExecutionPolicy Bypass -File scripts/New-LocalSecrets.ps1 -Force.

The Tilt UI is at http://localhost:10350; ingress serves the console and gateway over TLS at https://localhost:8443, and redirects http://localhost:8080 to it. The certificate is issued by a local authority cert-manager creates in the cluster, so it is not in your trust store and the first visit warns — that warning is the honest state of a certificate no public CA vouched for, and the runbook says how to verify the chain deliberately. tilt down removes the kind cluster and local registry, including their local data.

Compose remains an explicit migration fallback:

tilt up -- --orchestrator=compose --full

The release images built by CI use the Dockerfiles' final non-root stages. CI also renders both Kubernetes overlays and runs an ephemeral-cluster acceptance that captures unsigned-image rejection, Pod Security enforcement, datastore isolation, External Secrets synchronization and TLS at the ingress as downloadable evidence.

TLS terminates at the ingress and nowhere else: between services the traffic is plain HTTP, confined by network policy and authenticated by the signed identity envelope rather than by mTLS. The reasoning, and the integrity gap that decision accepts, are in ADR 0025.

There is not yet an honest cold-start time to publish. The first successful start must still be timed on a clean Docker cache with the hardware and network conditions recorded before a duration is presented as reproducible.

Verify published images

After a change reaches main, CI publishes each changed service to GHCR with the commit SHA and latest tags. Verification should use the immutable digest printed by the workflow or returned by docker buildx imagetools inspect:

IMAGE=ghcr.io/ivega123/projecty/identity
DIGEST=sha256:<published-digest>

cosign verify "$IMAGE@$DIGEST" \
  --certificate-identity="https://github.com/iVega123/ProjectY/.github/workflows/ci.yml@refs/heads/main" \
  --certificate-oidc-issuer="https://token.actions.githubusercontent.com"

gh attestation verify "oci://$IMAGE@$DIGEST" --repo iVega123/ProjectY

The same commands apply to rental-core, billing, media-guard and the rest under ghcr.io/ivega123/projecty/. The keyless signature binds the image to this repository's main workflow identity; the second command retrieves and verifies its GitHub-hosted SLSA build provenance. See the container image security gate for the scans that run before publication.

Follow the work

Dependency fault injection in the active development stack: commands and recovery contract.

Tilt chaos drills: injection, expected behavior and observation points. See the degradation contract for what each dependency failure stops, what continues, and the test and drill that prove it.

Measured load and chaos

Measured 2026-09-13 on the full polyglot stack with every dependency behind Toxiproxy: AMD Ryzen 9 9950X3D2, Docker 29.7.2 with 32 logical CPUs and 61.55 GiB RAM; 5 VUs for 30 seconds using one seeded rider and the default limiter.

Scenario Created Rate limited (429) Unexpected errors Successful p95 / p99 503 refusal median / p99
Normal 179 1,205 0% 42.1 / 50.1 ms —
Kafka down 179 1,206 0% 41.1 / 43.5 ms —
Bad network 177 1,139 0.15% 104.6 / 110.0 ms 92.6 / 102.2 ms
CockroachDB down 0 1,152 13.4% — 4.6 / 2,019.7 ms
CockroachDB +500 ms 135 0 0% 1,037.5 / 1,549.3 ms —
Redis down 0 0 100% — 252.2 / 252.9 ms

Reproduce: powershell -File scripts/Run-LoadTest.ps1 -Polyglot; append -Mode kafka-down, bad-network, db-down, slow-db or redis-down for fault runs. The database and Redis runs fail the unchanged k6 thresholds, and the table says why: without the database, rentals are refused — fast once the gateway breaker opens; without Redis, idempotent creation refuses closed by design. During the Kafka outage 80 rental events waited in the outbox and drained in 3 seconds after recovery. The slow-database run creates every rental in about a second — two database round trips at 500 ms each — and misses only the p95 < 800 ms threshold, which that latency cannot meet (#206). These measurements include rate limiting and do not estimate maximum capacity. Raw results and caveats; the first measurement, against MongoDB.

Tilt drill Injection Measured
Slow database CockroachDB +500 ms 135 created, no 5xx, breaker closed; median 1,028 ms
Database down CockroachDB timeout 503 with Retry-After; breaker opens, then refusals in milliseconds
Redis down Redis timeout Limiter open; idempotency and revocation closed
Kafka down Kafka timeout Rentals continue; outbox backlog drains on recovery
Bad network CockroachDB slicer + connection byte limit 2 errors in 1,318 requests
Service killed Stop telemetry Map freezes; rental creation and listing return 200
Cassandra down Cassandra timeout Live positions still accepted; history errors visible in spanmetrics
Risk-pricing stopped Stop risk-pricing Rentals priced on the base rate; fallback counted
Billing stopped Stop billing Rental list renders and names invoices as missing

Each Tilt drill has a clear button. Inject X, expect Y, observe at Z. Load and resilience dashboard uses port 13000 with the isolated load runner's -KeepStack option.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages