feat: Farm-to-Fork Batch Traceability - #1891
Merged
omroy07 merged 1 commit intoSep 27, 2026
Merged
Conversation
|
@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. |
Thanks for creating a PR for your Issue!
|
Contributor
Author
|
🎉 Congrats @Aditya8369 on getting your PR merged! 🙌 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #1886
Key Components Implemented
backend/models/traceability.py$\rightarrow$ block_hash $\rightarrow$ digital_signature) using SHA-256.$0.00\text{ ppm}$ residue safe, Heavy metal free).$\text{CO}_2\text{e}$ sequestered/saved per batch ($2.45\text{ kg CO}_2\text{e}/\text{kg}$ produce).
)
FarmLifecycleLog Audit Model:
Implements cryptographic block hash chaining (previous_hash
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 (
PACKAGING & COLD_CHAIN: Biodegradable cornstarch packaging and IoT temperature monitoring.
Carbon Accounting: Tracks kg
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.