import React, { useState, useRef } from 'react'; import { Upload, DNA, Search, BarChart3, MapPin, Download, Share2, Microscope } from 'lucide-react'; const BioStreamAI = () => { const [selectedFile, setSelectedFile] = useState(null); const [analysis, setAnalysis] = useState(null); const [loading, setLoading] = useState(false); const [dragActive, setDragActive] = useState(false); const [sampleLocation, setSampleLocation] = useState(''); const [waterSource, setWaterSource] = useState(''); const fileInputRef = useRef(null); const handleFileUpload = (event) => { const file = event.target.files[0]; if (file) { setSelectedFile(file); } }; const analyzeDNA = async (dnaFile) => { setLoading(true); setAnalysis(null); // It's good practice to clear old results // FormData will package the file for sending const formData = new FormData(); formData.append('dnaFile', dnaFile); try { // This is the new code that calls your server const response = await fetch('http://localhost:5000/api/analyze-dna', { method: 'POST', body: formData, }); if (!response.ok) { const errorData = await response.json(); throw new Error(errorData.message || `Server error: ${response.status}`); } const analysisData = await response.json(); console.log("Frontend: Received analysis from backend:", analysisData); // Update the screen with the real data from the backend const finalReport = { ...analysisData, fileName: dnaFile.name, fileSize: (dnaFile.size / 1024 / 1024).toFixed(2) + ' MB', }; setAnalysis(finalReport); } catch (error) { console.error('Failed to fetch DNA analysis:', error); } finally { // This part always runs to make sure the spinner stops setLoading(false); } }; const handleDrop = (e) => { e.preventDefault(); e.stopPropagation(); setDragActive(false); const files = e.dataTransfer.files; if (files && files[0]) { setSelectedFile(files[0]); } }; const handleDragOver = (e) => { e.preventDefault(); e.stopPropagation(); setDragActive(true); }; const handleDragLeave = (e) => { e.preventDefault(); e.stopPropagation(); setDragActive(false); }; const getAbundanceColor = (abundance) => { switch (abundance) { case 'Very High': return '#f44336'; case 'High': return '#FF9800'; case 'Medium': return '#4CAF50'; case 'Low': return '#2196F3'; default: return '#666'; } }; const getStatusColor = (status) => { if (status.includes('Invasive') || status.includes('Pathogen')) return '#f44336'; if (status.includes('Concern')) return '#FF9800'; return '#4CAF50'; }; const getHealthColor = (health) => { switch (health) { case 'Excellent': return '#4CAF50'; case 'Good': return '#8BC34A'; case 'Fair': return '#FF9800'; case 'Poor': return '#f44336'; default: return '#666'; } }; return (
Revolutionary genetic-level ecosystem monitoring from a single drop of water
We have no idea what's truly living in our water systems. Traditional surveys are slow, expensive, and miss 99% of life (especially microbial). We are blind to the true state of our biodiversity.
Every living creature sheds DNA into its environment. This eDNA is a "genetic barcode" floating in the water. Our AI analyzes raw DNA sequences to create a complete, species-level census of an ecosystem from a single water sample.
Single drop of water contains all DNA
Extract and sequence environmental DNA
Match DNA to species database
Complete biodiversity analysis
{dragActive ? 'Drop DNA sequence file here!' : 'Drag & drop DNA sequence file'}
Supports: FASTA, FASTQ, TXT • Raw sequencer output from MinION, Illumina, etc.
Selected File: {selectedFile.name}
Size: {(selectedFile.size / 1024 / 1024).toFixed(2)} MB
🧬 Analyzing environmental DNA with AI...
Sequencing DNA fragments, matching to species database, calculating biodiversity metrics...
ID: {species.blastId || 'N/A'}
{species.confidence || 'N/A'}% Confidence
{analysis.error ? `Analysis Error: ${analysis.error}` : "No species from the database were detected in this sample."}
)}