trainline-api
.NET 8 API that receives Trainline order-confirmation and refund-completed files, stores/archives them in MongoDB and publishes Trainline transaction events onto Redis streams for the Phenix estate.
Health score
0 to 100 across seven weighted factors; nothing is hidden. Green is 75 and above, amber 50 to 74, red below 50. How scoring works.
Facts
| Languages | csharp |
| Frameworks | ASP.NET Core 8, FluentValidation, FluentResults |
| Runtimes | .NET 8 |
| Tests / CI | good / CI in place |
| Last commit | 2025-12-02 |
| Owner | Owner unknown (mapping to be curated) |
| Domain | Selling and quoting (system generated; curate in repo-owners.json to override) |
| Product area | Phenix |
| Hosted | On-prem Deployed to our own machines
|
| Releases | 1 release pipeline(s): trainline-api |
| Integration | rest, redis-streams |
| Source | Open in Azure DevOps |
Risk flags
No risk flags recorded.
Each flag links to its glossary definition.
Dependencies in context
Entanglement
loose No binding mechanisms apply: this system needs no untangling work.
Migration playbooks
Generated from this repo's assessment data: what is feasible, what blocks it, and the steps in order. Ratings: green means actionable now, amber means sequence other work first, red means blocked, grey means not applicable.
ZDD adoption
No excuseNothing technical is holding this repo on the three-week release. It either already deploys without downtime (AWS) or is a modern, well-tested service the automated stealth path can carry today. Modern runtime, good tests, no hosted legacy transport: the automated stealth path can carry it today.
- 2 system(s) depend on this repo; during a rolling deploy they will talk to old and new versions at once, so responses must stay compatible
- Serialized state or messages in flight (Redis or queues): new code must deserialize objects written by the previous version
- Adopt the four-stage discipline from the ZDD engineering standard: pre-deployment compatibility, deployment, feature activation behind a flag, post-release cleanup.
- Make every change dual-version safe: backwards-compatible APIs (new major version for breaking wire changes), expand and contract for any schema change, and consumers tolerant of unknown fields.
- Audit serialized data: anything in Redis, queues or shared caches must deserialize cleanly across adjacent versions.
- Wrap behaviour changes in feature flags so code deploys dark and release becomes a business decision, not a deployment event.
- Route deployments through the Workflow Engine's automated drain, deploy, health-check, return cycle (the path proven by the first automated production run in mid-2026).
- Verify with area-scoped regression rather than the whole-platform cycle, and watch error rates after rollout with automated rollback on alert.
SQL Server exit
Not applicableNo SQL Server dependency is recorded for this repo. Nothing to migrate.
Containerisation
Ready to containeriseModern runtime, no hosted legacy transport: this service can follow the estate's proven container path (Dockerfile, shared pipeline template, ECS via Terraform).
- Add a Dockerfile and make the app read all configuration from environment variables and the secrets manager, never from machine-local files.
- Log to stdout and expose a health check endpoint so ECS can supervise it.
- Adopt the shared ci.yml pipeline template with the container parameters (awsRegion, containerAfterBuild, ecsTerraformRepo), which is exactly how the estate's existing AWS services deploy.
- Define the service in the Terraform repo, deploy to a non-production environment, then shift traffic and disarm the deployment-group release pipeline.
Recommended actions
No specific actions for this repo. It either needs only normal maintenance, or its work is covered by an estate-level action. See the full programme.
Assessment notes
trainline-api
Purpose
Ingestion point for rail bookings made through Trainline. Controllers accept order-confirmation and refund-completed JSON files plus an archive endpoint; services validate, persist and archive the files in MongoDB, and the companion TC.Phenix.Trainline.Events library maps them (resolving the owning sales person via the Phenix User API by branch number) into TrainlineTransactionEvent messages published on TC.Streams.
Tech stack
C# .NET 8 ASP.NET Core using TravelCounsellors.ApiTools, FluentValidation, FluentResults, MongoDB.Driver with TC.ScriptRunner.Mongo index scripts, TC.Streams over Redis, Swashbuckle, Nerdbank.GitVersioning. MSTest with AutoFixture/Moq.AutoMock/AwesomeAssertions.
Deployment
prod_application, release_count 1. Two YAML pipelines: build.yml for the API (shared templates, .NET 8, AWS eu-west-1 container parameters — containerAfterBuild: false, namespace trainline) and build-trainline-events-lib.yml publishing the events NuGet package. Build pipelines trainline-api and phenix-trainline-api feed the trainline-api release pipeline. Served under /API/TrainlineAPI.
Dependencies
Internal packages: TC.ConnectionBroker.* (Api, Mongo, Redis, HttpClient), TravelCounsellors.ApiTools, TC.Streams.*; the events library also uses TC.UserAccount.ServiceClient/ServiceContract (backoffice-useraccount-service) and calls the Phenix User API over HTTP (phenix-user-api). External: Trainline as the upstream file source.
Data stores
MongoDB database Trainline (order-confirmation files, refund files, archived files with scripted indexes on order reference and Phenix booking id). Redis is used for stream publishing, not caching.
Integration points
Inbound REST for file submission. Outbound REST to the Phenix User API and event publication over Redis streams consumed elsewhere in Phenix.
Code health
Two test projects covering the API (controllers, services, mappers, validators — with real Trainline sample payloads) and the events library. No README at all. Last commit 2025-12-02; low churn but healthy.
Modernisation risks
Low: modern .NET 8, YAML CI, decent tests, no SQL coupling. Gaps are documentation (no README) and a hard dependency on the Trainline file formats; the AWS container parameters in the pipeline suggest a partially adopted containerisation path (containerAfterBuild disabled).