Documentation
Draft (v1) of Seed Tracker — traceability for seed lots moving between farms.
Idea and goals
This is the first minimal version of a seed tracker for Kernza seeds. While the applications and potential build-outs are many, this first version is targeted on fullfilling the requirements for commercial sales of Kernza seeds within Sweden. The tool should enable tracing of Kernza seed lots and simplify the reporting to TLI regarding the usage of Kernza seeds.
Entities
| Entity | What it represents | Key fields |
|---|---|---|
| Farm | A farm that owns seed lots and takes part in transactions. | name, location (region/municipality) |
| Seed lot | A quantity of seed of one species/variety, owned by one farm. A lot can have a parent lot if it was created by splitting another lot. | farm (owner), species, variety, harvest year, quantity, unit (kg or t), license, parent lot |
| Transaction | Movement of a quantity of a lot from one farm to another: sale, transfer, gift, or self-use. | lot, from farm, to farm, type, quantity, date |
| Split (child lot) |
Dividing a lot into a new child lot. The parent lot is never modified; the child
gets parent lot set and inherits species, variety, harvest year,
unit and license unless overridden.
| parent lot, quantity split off, receiving farm (optional) |
Concepts
- Ownership follows the seed. When a transaction is recorded, the lot's current owner becomes the receiving farm, and the "from farm" must be the current owner.
- Capacity rule. The sum of outgoing quantities of a lot — transactions plus quantities split into child lots — can never exceed the lot's own quantity. The API rejects anything larger, and a database trigger enforces it as a backstop.
- Lineage. The full history of a lot: its ancestors (via parent lots) and descendants (child lots plus all transactions on any related lot), shown as a flow diagram and exportable as CSV.
- Units. Quantities are entered in kilograms (
kg) or tonnes (t) only, so amounts stay comparable.
Usage
- Log in with the shared password. Every page requires a valid session.
- Overview lists all lots and farms. Create a farm first if none exists.
- New farm — register a farm with a name and a location.
- New lot — register a seed lot on a farm: harvest year, quantity and
unit. Species, variety, license and unit are picked from lists served by the backend
(
GET /options, stored in the database): currently Kernza with the varieties TLI cycle 5, TLI cycle 8 and Minnesota Clearwater; licenses TLI and University of Minnesota; units kg and t. - New transaction — record a sale/transfer/gift/self-use of part of a lot to another farm.
- Split (from the overview, per lot) — split off a quantity into a child lot, optionally at another farm.
- Lineage — enter a lot ID to see its full ancestry and descendants as a diagram. Green square = lot, blue circle = farm, solid edge = split, dashed edge = transaction. Download CSV exports the same edges.
API
The backend is a plain REST API (FastAPI) with interactive OpenAPI docs at
/docs on the API host (default http://localhost:8000/docs).
All data endpoints require an Authorization: Bearer token issued by
POST /auth/login. In this draft the login is a single shared password, not
per-user accounts. Notable endpoints: GET /lots/{id}/lineage (nested JSON
for the diagram), GET /lots/{id}/lineage.csv, and GET /options
(the allowed species/variety/license/unit values).