Marge tells a Managed Service Provider what each of its clients actually earns. It crosses the three sources nobody reconciles — the ticketing tool's logged hours, the AWS bill, and the PDF contracts — and produces a dated, auditable margin per client per month, the hours that were worked but never billed, and a written monthly review an account manager can take into a renewal.
Built for the AWS MSP AI Hackathon, Track 1 — Run Your MSP Better (targeting the Best Amazon Quick Application prize).
Screenshot — Overview dashboard (described, no binary committed yet). The top band shows four tiles: total monthly margin, average margin rate, clients below the 20 % threshold (count in red), and a data-coverage badge at 96 %. Below them, a client ranking table sorted by margin rate — two rows highlighted in red (the seeded loss-makers, one of them with an abnormal ticket volume) — and a six-month margin trend line with the threshold drawn as a dashed horizontal rule. Every row links to the client sheet, which decomposes the margin into revenue by component and cost by nature, down to the source lines. Drop the real capture at
docs/img/overview.pngonce the Quick account is deployed (see RUNBOOK.md §2).
An MSP sells fixed-price managed-service contracts while real effort varies enormously from client to client. Almost no MSP knows its margin per client, because the data lives in three tools that never talk: time spent in the ITSM tool, AWS costs in the billing console, commitments in PDF contracts. Loss-making clients stay invisible, out-of-scope work is given away, renewals are negotiated blindly, and producing the number takes days of spreadsheets — so nobody does it.
- Nightly ingestion (Step Functions + Lambda) loads tickets, billing rows and contract PDFs into S3, stripping engineer names on the way in — only seniority levels survive.
- Three AI steps: Bedrock Data Automation reads contract clauses, a Bedrock model (Flex tier) classifies each intervention against the contract scope, Quick's chat agent answers questions on the numbers.
- A human validates each AI step in the validation portal — client matching, contract fields, out-of-scope work.
- Margin is computed by code (
src/marge/calc, pure Python,Decimal) and published to five Quick SPICE datasets with row-level security. - Quick delivers: dashboards, a semantic Topic, a scheduled monthly review Flow, and MCP actions that create the renegotiation task in the ITSM tool.
Full detail: HLD · ARCHITECTURE · DECISIONS · RUNBOOK.
The validation portal is live and open to everyone (fictional data only):
| Where | URL |
|---|---|
| Production demo (CloudFront, UI + API on one origin) | https://d3n1e2aqabg966.cloudfront.net |
| GitHub Pages mirror (static site of this repo) | https://tradoooo.github.io/marge-msp/ |
Demo identities. The login and the password are transmitted in the Devpost test-instructions form, and kept in AWS Secrets Manager — never in this repository. The portal signs the judges in with Amazon Cognito: one account per role of the specification, and one judge account that can read and validate.
The demo dataset was reloaded on 2026-11-17: twelve English client names
(the golden case is Calder Logistics, 19.4 % margin) and twelve English
contracts (legal form LTD).
| Login | Role | What it sees |
|---|---|---|
judge@marge.demo |
CONTROLLER | Every client, the hourly costs, and the three validation queues |
director-01@marge.demo |
EXECUTIVE | Every client, the review, the scenarios |
ops-01@marge.demo |
OPERATIONS_DIRECTOR | Every client, the effort by category and level |
am-01@marge.demo |
ACCOUNT_MANAGER | Only their own clients, and never an hourly cost |
controller-01@marge.demo |
CONTROLLER | Every client, the rate cards, the contract validation |
admin-01@marge.demo |
ADMINISTRATOR | Technical settings, the data coverage, the ingestion triggers |
The account manager sees only their own clients and never an hourly cost; the controller sees every client and the per-level rates. The GitHub Pages mirror cross-calls the CloudFront API, so both URLs serve the same live data.
git clone https://github.com/Tradoooo/marge-msp.git && cd marge-msp
python3 -m pip install --user -e ".[dev,api]"
make smoke # recompute the Annex D golden case offline — no AWS, no credentialsmake smoke prints and asserts the reference figures (revenue 4 620 €, cost 3 725 €, margin 895 € = 19.4 %, 9 h × 110 € = 990 €). make test runs the offline suite, make lint and make limits are what CI runs.
The full local walk-through — generate → load → match → contracts → classify → compute → portal → review → mcp, i.e. make demo — is wired by the pipeline, portal, MCP and data-generator modules; each of those commands is registered under src/marge/commands/; run python3 -m marge.cli --help for the full list (smoke, generate, eval, demo, serve, mcp, nightly, weekly, monthly, publish, assets, model-compare, …).
Step-by-step demo and judge credentials: docs/TEST-INSTRUCTIONS.md.
The authoritative requirements document is the French cahier des charges: docs/SPEC.fr.md (chapters 1–25 + annexes A–F). Every requirement id quoted in code (EF-*, ENF-*, R*) refers to it, and the traceability matrix maps each one to its implementation and test: docs/acceptance/MATRIX.md.
Interchange formats between the generator, the connectors and the evaluation harnesses: docs/DATA-FORMATS.md. Module ownership and public API: docs/CONTRACT.md.
marge-msp/
├── src/marge/
│ ├── domain/ # frozen pure dataclasses: money, periods, parties, work, results, settings, audit
│ ├── calc/ # margin model (spec ch.12): rates, hours, allocation, coverage, margin, effort, renewal, trace, versioning
│ ├── ingest/ # TicketSource / BillingSource / ContractSource Protocols, PII stripping
│ ├── store/ # Store Protocol: SQLite (local, CI) + DynamoDB (AWS)
│ ├── match/ contracts/ classify/ # AI steps: client identity, Annex B fields, Annex C classifications
│ ├── api/ # FastAPI validation portal API (spec ch.16), auth, row-level filtering
│ ├── mcp/ # MCP server: create_renegotiation_task, draft_extra_billing_proposal, get_margin_breakdown
│ ├── review/ # monthly review, Annex E template, SES/Bedrock fallback
│ ├── quicksight/ # datasets, topic, dashboards, RLS, scenarios, agent, flows, asset bundle
│ ├── pipeline/ # nightly / weekly / monthly orchestration
│ ├── eval/ # accuracy harnesses (R2, R3, R5, R11)
│ └── cli.py # one entry point
├── data/generator/ # fake MSP: 12 clients, 6 months, seeded situations, 12 PDF contracts
├── portal/ # static validation portal (vanilla HTML/CSS/JS, no build step)
├── infra/cdk/ # AWS CDK stacks
├── tests/ # offline deterministic tests, shared doubles in tests/fakes/
└── docs/ # spec, HLD, architecture, runbook, submission, acceptance matrix
ci(GitHub Actions): ruff check + format, size guard (< 500lines per file,< 50per function), offline pytest, Annex D smoke. 5-minute budget per job, enforced by theci-budgetworkflow; both checks are queue conditions.- Runner pool: every workflow reads
runs-on: ${{ fromJSON(vars.CI_RUNNER) }}. The default is the four self-hosted workers of the R630 (r630-marge-msp-01..04, labelmarge-msp-worker); the repository variableCI_RUNNERswitches the whole pool in one call, e.g. to["ubuntu-latest"]when the shared R630 is unreachable or overloaded. The value in force is the one the job actually used, visible in the run log. - Mergify: merge queue with rebase, batching 1–3,
urgent/priority-lowlabels.mainis protected — no direct pushes, the queue is the only merge pilot. - hermes-lite: freshness gate (
.github/workflows/hermes-lite.yml+.github/hermes/gate.py), running in dry-run (HERMES_LITE_DRY_RUN=1); it labels and evaluates, it does not merge.stale-base-guard: informative branch-lag check. deploy-check: CDK synth + Quick asset bundle, after merge onmainonly — never on a pull request, so the PR path stays inside the budget.
MIT — see pyproject.toml.
- Track 1 selected; AWS AI services declared (Amazon Quick, Amazon Bedrock, Bedrock Data Automation, AgentCore Gateway)
- English description: features, problem, measured efficiency gains — docs/SUBMISSION.md
- Architecture diagram — docs/ARCHITECTURE.md and docs/HLD.md (Mermaid, overview + nightly sequence)
- High-level design document — docs/HLD.md
- Test instructions with demo credentials for the portal and for Quick — docs/TEST-INSTRUCTIONS.md
- Private repository shared with
testing@devpost.comandaws-msp@amazon.com - Code calls real AWS AI services at runtime (Bedrock Data Automation, a Bedrock model, the Quick Sight API, an MCP server loaded by the agent)
- ~3-minute public YouTube video in English, no third-party branding or music — script and shot list in docs/ARCHITECTURE.md §5
- Public portal URL filled into the Devpost form after deployment (see RUNBOOK.md §2)