Inspiration
Traditional water quality monitoring is reactive, slow, and relies on outdated chemical testing that misses the broader biological picture. We were inspired to bridge the gap between advanced genomics and actionable environmental policy. We wanted to build a system that doesn't just say "the water is dirty," but actively identifies specific industrial or agricultural pollutants, calculates extinction risks, and instantly alerts the authorities turning raw eDNA into an automated early-warning system.
What it does
RiverSense AI is an automated backend decision engine for aquatic conservation. When raw eDNA sample data (Kraken2 reports) is uploaded to our API, the engine parses the genomic trail and evaluates it against our custom Ecological Map.
It calculates a Biodiversity Health Score (0-100) and automatically triggers targeted alerts:
Critical Collapse: Notifies the Jal Shakti Ministry if the health score plummets below 30. Heavy Contamination: Flags toxic blooms (e.g., Pseudomonas aeruginosa) and notifies the CPCB of industrial discharge. Extinction Risk: Alerts the Wildlife Crime Control Bureau if critical habitat breakdown threatens localized species.
Simultaneously, the system generates a comprehensive PDF report and dispatches it directly to the designated authorities via an automated SMTP email pipeline.
How we built it
We engineered a robust, high-performance backend using Python and FastAPI.
Data Ingestion: We built a custom parser to process raw TSV outputs from Kraken2 classification, extracting species diversity and read percentages. Ecological Decision Engine: We mapped specific taxonomic groups to pollution multipliers (heavy pollution, agricultural runoff). We implemented a custom scoring algorithm to calculate the final biodiversity metric: Score = max (0,100 - (W_heavy * 4) - (W_mid * 2) - (W_ag * 1.5)
(Where W represents the weighted percentage of the pollution indicator and P_{diversity} is the ecosystem penalty for low species count).
Database & ORM: We utilized SQLAlchemy to store historical upload records, analysis results, and active alert states in a relational database.
Asynchronous Alerting: We leveraged FastAPI's BackgroundTasks alongside Python's email.message and smtplib to silently generate PDF reports and transmit SMTP emails without blocking the main API thread.
Challenges we ran into
Building a production-ready backend in a hackathon timeframe pushed us to our limits:
- The Git Crucible: Mid-development, a Git merge sequence scrambled our Python file encodings, causing the system to read our source code as corrupted binary files. We had to execute emergency terminal restorations to recover our logic.
- Asynchronous Ghost Bugs: While wiring up the background email pipeline, we encountered silent ASGI application crashes. Tracing the bug required deep debugging of how FastAPI passes keyword arguments into background thread pools, eventually leading us to isolate and fix a rogue placeholder variable overriding our global configurations.
- Algorithm Balancing: Calibrating the math behind the Biodiversity Score was tough. Initially, highly toxic samples were driving the score deep into the negatives. We had to implement strict mathematical floors and balance our ecological weights so the score accurately reflected the severity of the contamination.
Accomplishments that we're proud of
We are incredibly proud of achieving a fully integrated, zero-click reporting pipeline. The moment an eDNA file hits our /analyze endpoint, the system autonomously parses the biology, runs the math, saves the telemetry, generates the PDF, and successfully lands a critical alert in a real email inbox in under 3 seconds.
What we learned
FastAPI Architecture: We mastered the use of BackgroundTasks to keep API response times lightning fast while executing heavy I/O operations in the background.
Resilience in Debugging: We learned not to panic when the terminal throws a TypeError or when version control acts up, but to systematically trace the data flow from the endpoint all the way down to the SMTP server.
What's next for RiverSense AI
Deep ML Integration: Fully activating our PyTorch/DNABERT sequence classification models to analyze raw .fasta reads dynamically.
Geospatial Dashboarding: Building out a frontend Next.js map interface to visualize the database's latitude/longitude metrics, allowing researchers to watch contamination plumes spread in real-time.
Built With
- and-seamless-integration-between-advanced-machine-learning-models-and-web-technologies.-backend-framework:-python
- bioinformatics
- dnabert
- fasta
- fastapi
- fastapi-(leveraging-asynchronous-asgi-and-backgroundtasks-for-non-blocking-i/o)-machine-learning-&-ai:-pytorch
- hugging-face-transformers
- json
- kraken2
- ml
- next.js
- pandas
- python
- react
- scalability
- smtplib
- sqlalchemy
- uvicorn
Log in or sign up for Devpost to join the conversation.