Skip to content

feat: Farm-to-Fork Batch Traceability - #1891

Merged
omroy07 merged 1 commit into
omroy07:mainfrom
Aditya8369:feat/Farm-to-Fork-Batch-Traceability
Sep 27, 2026
Merged

omroy07 merged 1 commit into
omroy07:mainfrom
Aditya8369:feat/Farm-to-Fork-Batch-Traceability

Conversation

@Aditya8369

Copy link
Copy Markdown
Contributor

closes #1886

Key Components Implemented

  1. Immutable Farm Lifecycle Ledger (

backend/models/traceability.py
)
FarmLifecycleLog Audit Model:
Implements cryptographic block hash chaining (previous_hash $\rightarrow$ block_hash $\rightarrow$ digital_signature) using SHA-256.
Records granular farm-to-fork activities:
SEED_SOWING: Seed variety, ICAR certification, non-GMO status, bio-priming.
SOIL_HEALTH: pH, Organic Carbon %, NPK balance, NABL lab accreditation.
BIO_FERTILIZER / BIOPESTICIDE: Neemastra, vermicompost, zero chemical residue verification.
IRRIGATION: FAO-56 solar micro-drip telemetry, water conserved vs flood irrigation.
HARVEST: Selective morning hand-harvesting, Brix sugar index, Grade A+ sorting.
LAB_CERTIFICATION: NABL chemical residue clearance ($0.00\text{ ppm}$ residue safe, Heavy metal free).
PACKAGING & COLD_CHAIN: Biodegradable cornstarch packaging and IoT temperature monitoring.
Carbon Accounting: Tracks kg $\text{CO}_2\text{e}$ sequestered/saved per batch ($2.45\text{ kg CO}_2\text{e}/\text{kg}$ produce).
2. Dynamic QR Code Engine & REST Endpoints (

backend/api/v1/traceability.py
&

backend/services/traceability_service.py
)
GET /api/v1/traceability/generate-qr/<batch_id> – Generates high-resolution, printable packaging QR sticker labels (image/png) complete with batch ID, crop name, farm origin, and organic verification badges.
GET /api/v1/traceability/batches/<batch_id> – Public consumer endpoint fetching verified lifecycle logs, farmer profile, carbon metrics, and lab test reports.
GET /api/v1/traceability/verify/<batch_id> – Cryptographic verification endpoint validating the entire SHA-256 block chain from genesis to store dispatch.
POST /api/v1/traceability/log-event – Appends an immutable lifecycle event to an active batch ledger.
POST /api/v1/traceability/create-batch – Initializes a new farm produce batch and generates the genesis block.

@vercel

vercel Bot commented Sep 25, 2026

Copy link
Copy Markdown

@Aditya8369 is attempting to deploy a commit to the Om Roy's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown

Thanks for creating a PR for your Issue! ☺️

We'll review it as soon as possible.
In the meantime, please double-check the file changes and ensure that all commits are accurate.

If there are any unresolved review comments, feel free to resolve them. 🙌🏼

@Aditya8369

Copy link
Copy Markdown
Contributor Author

@omroy07 closes #1886

@omroy07
omroy07 merged commit 9c632b9 into omroy07:main Sep 27, 2026
1 of 4 checks passed
@github-actions

Copy link
Copy Markdown

🎉 Congrats @Aditya8369 on getting your PR merged! 🙌
Thanks for the contribution — looking forward to more from you 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Farm-to-Fork Batch Traceability & Dynamic QR Verification

2 participants