Overview — Project 1: Brandforge
The fastest way to understand Rust and AI together is to make something you can inspect. In this project you will build Brandforge, a command-line product inspired by a small TypeScript experiment: give it business research, ask a model for a brand profile, reject unsupported advertising claims, and create a campaign pack.
The model is allowed to propose. Rust decides what is valid, what is supported by evidence, and what may become an artifact.
Beginner rule: the page must name the file
Section titled “Beginner rule: the page must name the file”You are never expected to decide where a lesson’s code belongs. Project 1 uses two separate copies:
rust/rust-ai-engineering/crates/brandforge/ # finished reference answerrust/rust-ai-engineering/learning/brandforge/ # your private working copyEvery day begins with an edit map. Every code block that you should paste is labeled CREATE, REPLACE, or ADD, followed by the exact path. Explanatory snippets are labeled READ ONLY.
Start by creating the working copy with Before Day 1 — Make Your Working Copy. Do not edit the finished reference crate while following the lesson.
What Brandforge does
Section titled “What Brandforge does”Run the finished reference crate:
cd rust/rust-ai-engineeringcargo run -p brandforge -- build \ --source fixtures/brandforge/site.md \ --profile fixtures/brandforge/business-profile.json \ --output target/brandforgeIt writes:
target/brandforge/├── business-profile.json # typed model output├── claim-audit.json # evidence result for every proposed claim├── image-prompt.txt # compiled only from approved information├── ad-preview.svg # visible preview you can open in a browser└── run-report.json # input hashes and artifact inventoryNow run the dangerous case:
cargo run -p brandforge -- build \ --source fixtures/brandforge/site.md \ --profile fixtures/brandforge/business-profile-unsupported.json \ --output target/brandforge-badThe model profile claims 98% client satisfaction, but the website snapshot never says that. The
program exits unsuccessfully, preserves claim-audit.json, and refuses to create an ad preview.
That failure is part of the product.
The five days
Section titled “The five days”| Day | Product slice | Rust that the slice forces | AI lesson |
|---|---|---|---|
| Setup | separate working copy | paths, Cargo project layout, edit loop | keep the runnable answer separate |
| 1 | CLI plus website snapshot | Cargo, modules, PathBuf, String, borrowing | freeze model input |
| 2 | typed business profile | structs, enums, Serde, Option, validation | structured output is still untrusted |
| 3 | replaceable profile producer | traits, errors, configuration | scripted first, live provider second |
| 4 | evidence gate | iterators, normalization, exhaustive state | prompts do not verify facts |
| 5 | campaign pack and preview | bytes, files, hashing, unit and CLI tests | artifact provenance and evals |
The pipeline you will own
Section titled “The pipeline you will own”website snapshot ───────┐ ├─▶ claim audit ─▶ verified prompt ─▶ preview / imagemodel business profile ┘ │ └─▶ reject unsupported campaignThere are two important boundaries:
- The model output is decoded into
BusinessProfile, but decoding only proves its shape. - Every promotional claim must point to a quote present in the frozen source before generation.
The live-provider extension may use an API, but the required build is offline. You can learn the software, rerun the tests, and diagnose failures without a key, network, GPU, or paid request.
Code layout
Section titled “Code layout”crates/brandforge/├── src/│ ├── main.rs # CLI and exit status│ ├── lib.rs # public product boundary│ ├── model.rs # scripted model and live-provider trait boundary│ ├── profile.rs # model-facing data and claim audit│ ├── pipeline.rs # read, validate, compile, write│ ├── render.rs # image prompt and SVG preview│ └── error.rs # named failure modes└── tests/cli.rs # run the real executableThe reference crate is the finished answer. The setup page creates a separate starter with fixtures and dependencies already in place, so the remaining pages can tell you exactly which file to edit.
Start with Before Day 1 — Make Your Working Copy →.