# crown-commercial-service/crown-marketplace-legacy architecture

> Architecture diagram of the GitHub repository crown-commercial-service/crown-marketplace-legacy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/crown-commercial-service/crown-marketplace-legacy
- Repository: https://github.com/crown-commercial-service/crown-marketplace-legacy

## Overview

Crown Marketplace is a Rails application for Supply Teachers, Legal Services, and Management Consultancy procurement frameworks. Buyers answer framework-specific questions and are directed toward suitable suppliers; Supply Teachers also offers branch search and pricing calculations. Separate admin routes support framework and supplier management, uploads, reports, and change logs. The README documents journeys as question steps leading to outcomes. Source excerpts show routing and shared authentication, but not every journey controller or data interaction, so unverified links are omitted.

Main entry points: [`config/routes.rb`](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/config/routes.rb) (Framework routes), [`app/javascript/src/ccs.ts`](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/javascript/src/ccs.ts) (Browser interactions), [`app/controllers/legal_services/rm6374/suppliers_controller.rb`](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/controllers/legal_services/rm6374/suppliers_controller.rb) (Supplier results), [`app/controllers/supply_teachers/branches_controller.rb`](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/controllers/supply_teachers/branches_controller.rb) (Supply routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_journeys["Buyer journeys"]
  node_journey_control["Journey controller"]
  node_journey_models["Journey steps<br/>[select_lot.rb]"]
  node_supplier_results["Supplier results"]
  node_supplier_data[("Supplier records<br/>[service.rb]")]
  node_frameworks[("Framework catalogue<br/>[framework.rb]")]
end

subgraph group_supply["Supply Teachers"]
  node_supply_routes["Supply routes"]
  node_branch_search["Branch search"]
  node_teacher_calculations["Pricing calculations"]
  node_calculator["Pricing rules<br/>[calculator.rb]"]
  node_teacher_js["Teacher tools"]
end

subgraph group_admin["Administration"]
  node_admin_routes["Admin routes<br/>[routes.rb]"]
  node_admin_framework["Framework management"]
  node_admin_supplier["Supplier management"]
  node_uploads["Data uploads"]
  node_reports["Reports and logs<br/>[report_actions.rb]"]
end

subgraph group_platform["Shared platform"]
  node_routes["Framework routes<br/>[routes.rb]"]
  node_auth["Authentication"]
  node_login["Login providers<br/>[dfe_login.rb]"]
  node_database[("Marketplace database")]
  node_frontend["Browser interactions<br/>[ccs.ts]"]
  node_admin_upload_js["Upload interface<br/>[adminUpload.ts]"]
  node_basket_js["Supplier basket<br/>[basket.ts]"]
end

node_buyer(("Buyer"))

node_buyer -->|"requests pages"| node_routes
node_routes -->|"routes journey"| node_journey_control
node_routes -->|"routes suppliers"| node_supplier_results
node_routes -->|"routes service"| node_supply_routes
node_routes -->|"routes admin"| node_admin_routes
node_journey_control -.->|"uses steps"| node_journey_models
node_supplier_results -.->|"loads suppliers"| node_supplier_data
node_journey_models -.->|"selects framework"| node_frameworks
node_supply_routes -.->|"handles search"| node_branch_search
node_supply_routes -->|"routes calculations"| node_teacher_calculations
node_teacher_calculations -.->|"calculates rates"| node_calculator
node_admin_routes -->|"routes framework"| node_admin_framework
node_admin_routes -->|"routes suppliers"| node_admin_supplier
node_admin_routes -->|"routes uploads"| node_uploads
node_admin_routes -->|"routes reports"| node_reports
node_routes -->|"authenticates requests"| node_auth
node_auth -.->|"authorizes login"| node_login
node_supplier_results -.->|"reads records"| node_database
node_admin_supplier -.->|"manages records"| node_database
node_uploads -.->|"imports data"| node_database
node_frontend -->|"initializes"| node_admin_upload_js
node_frontend -->|"initializes"| node_basket_js
node_frontend -->|"initializes"| node_teacher_js
node_buyer -.->|"uses interface"| node_frontend

click node_routes "https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/config/routes.rb"
click node_journey_control "https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/controllers/legal_services/journey_controller.rb"
click node_journey_models "https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/models/legal_services/rm6374/journey/select_lot.rb"
click node_supplier_results "https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/controllers/legal_services/rm6374/suppliers_controller.rb"
click node_supplier_data "https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/models/supplier/framework/lot/service.rb"
click node_frameworks "https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/models/framework.rb"
click node_supply_routes "https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/controllers/supply_teachers/branches_controller.rb"
click node_branch_search "https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/controllers/supply_teachers/branches_controller.rb"
click node_teacher_calculations "https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/controllers/supply_teachers/calculations_controller.rb"
click node_calculator "https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/calculators/supply_teachers/temp_to_perm_calculator/calculator.rb"
click node_admin_routes "https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/config/routes.rb"
click node_admin_framework "https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/controllers/concerns/admin/framework_actions.rb"
click node_admin_supplier "https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/controllers/concerns/admin/supplier_actions.rb"
click node_uploads "https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/workers/supply_teachers/admin/data_upload_worker.rb"
click node_reports "https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/controllers/concerns/admin/report_actions.rb"
click node_auth "https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/controllers/application_controller.rb"
click node_login "https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/models/login/dfe_login.rb"
click node_database "https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/models/application_record.rb"
click node_frontend "https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/javascript/src/ccs.ts"
click node_admin_upload_js "https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/javascript/src/shared/adminUpload.ts"
click node_basket_js "https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/javascript/src/shared/basket.ts"
click node_teacher_js "https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/javascript/src/supplyTeachers/supplierMarkupCalculator.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_journey_control,node_journey_models,node_supplier_results,node_supplier_data,node_frameworks toneBlue
class node_supply_routes,node_branch_search,node_teacher_calculations,node_calculator,node_teacher_js toneAmber
class node_admin_routes,node_admin_framework,node_admin_supplier,node_uploads,node_reports toneMint
class node_routes,node_auth,node_login,node_database,node_frontend,node_admin_upload_js,node_basket_js toneRose
class node_buyer toneIndigo
```

## Components

### Buyer journeys

- [Journey controller](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/controllers/legal_services/journey_controller.rb): `app/controllers/legal_services/journey_controller.rb`
- [Journey steps](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/models/legal_services/rm6374/journey/select_lot.rb): `app/models/legal_services/rm6374/journey/select_lot.rb`
- [Supplier results](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/controllers/legal_services/rm6374/suppliers_controller.rb): `app/controllers/legal_services/rm6374/suppliers_controller.rb`
- [Supplier records](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/models/supplier/framework/lot/service.rb): `app/models/supplier/framework/lot/service.rb`
- [Framework catalogue](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/models/framework.rb): `app/models/framework.rb`

### Supply Teachers

- [Supply routes](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/controllers/supply_teachers/branches_controller.rb): `app/controllers/supply_teachers/branches_controller.rb`
- [Branch search](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/controllers/supply_teachers/branches_controller.rb): `app/controllers/supply_teachers/branches_controller.rb`
- [Pricing calculations](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/controllers/supply_teachers/calculations_controller.rb): `app/controllers/supply_teachers/calculations_controller.rb`
- [Pricing rules](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/calculators/supply_teachers/temp_to_perm_calculator/calculator.rb): `app/calculators/supply_teachers/temp_to_perm_calculator/calculator.rb`
- [Teacher tools](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/javascript/src/supplyTeachers/supplierMarkupCalculator.ts): `app/javascript/src/supplyTeachers/supplierMarkupCalculator.ts`

### Administration

- [Admin routes](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/config/routes.rb): `config/routes.rb`
- [Framework management](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/controllers/concerns/admin/framework_actions.rb): `app/controllers/concerns/admin/framework_actions.rb`
- [Supplier management](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/controllers/concerns/admin/supplier_actions.rb): `app/controllers/concerns/admin/supplier_actions.rb`
- [Data uploads](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/workers/supply_teachers/admin/data_upload_worker.rb): `app/workers/supply_teachers/admin/data_upload_worker.rb`
- [Reports and logs](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/controllers/concerns/admin/report_actions.rb): `app/controllers/concerns/admin/report_actions.rb`

### Shared platform

- [Framework routes](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/config/routes.rb): `config/routes.rb`
- [Authentication](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/controllers/application_controller.rb): `app/controllers/application_controller.rb`
- [Login providers](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/models/login/dfe_login.rb): `app/models/login/dfe_login.rb`
- [Marketplace database](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/models/application_record.rb): `app/models/application_record.rb`
- [Browser interactions](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/javascript/src/ccs.ts): `app/javascript/src/ccs.ts`
- [Upload interface](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/javascript/src/shared/adminUpload.ts): `app/javascript/src/shared/adminUpload.ts`
- [Supplier basket](https://github.com/crown-commercial-service/crown-marketplace-legacy/blob/main/app/javascript/src/shared/basket.ts): `app/javascript/src/shared/basket.ts`

### Other components

- **Buyer**

## Connections

- Buyer → Framework routes: requests pages (evidence: `config/routes.rb`)
- Framework routes → Journey controller: routes journey (evidence: `config/routes.rb`)
- Framework routes → Supplier results: routes suppliers (evidence: `config/routes.rb`)
- Framework routes → Supply routes: routes service (evidence: `config/routes.rb`)
- Framework routes → Admin routes: routes admin (evidence: `config/routes.rb`)
- Journey controller → Journey steps: uses steps
- Supplier results → Supplier records: loads suppliers
- Journey steps → Framework catalogue: selects framework
- Supply routes → Branch search: handles search (evidence: `app/controllers/supply_teachers/branches_controller.rb`)
- Supply routes → Pricing calculations: routes calculations
- Pricing calculations → Pricing rules: calculates rates
- Admin routes → Framework management: routes framework (evidence: `config/routes.rb`)
- Admin routes → Supplier management: routes suppliers (evidence: `config/routes.rb`)
- Admin routes → Data uploads: routes uploads (evidence: `config/routes.rb`)
- Admin routes → Reports and logs: routes reports (evidence: `config/routes.rb`)
- Framework routes → Authentication: authenticates requests (evidence: `app/controllers/application_controller.rb`)
- Authentication → Login providers: authorizes login
- Supplier results → Marketplace database: reads records
- Supplier management → Marketplace database: manages records
- Data uploads → Marketplace database: imports data
- Browser interactions → Upload interface: initializes (evidence: `app/javascript/src/ccs.ts`)
- Browser interactions → Supplier basket: initializes (evidence: `app/javascript/src/ccs.ts`)
- Browser interactions → Teacher tools: initializes (evidence: `app/javascript/src/ccs.ts`)
- Buyer → Browser interactions: uses interface
