Climate-smart Approach for Reducing Antimicrobial resistance
IoT-enabled mobile platform for Vietnamese shrimp farmers
Features β’ Quick Start β’ Architecture β’ Development β’ Roadmap
CARA is a research-grade mobile application designed for monitoring and reducing antimicrobial use in Vietnamese aquaculture systems. Built for Oxford University Clinical Research Unit (OUCRU) under ICARS Global funding.
| Goal | Metric | Target |
|---|---|---|
| π¬ Reduce antimicrobial use | mg/kg biomass | -30% |
| π Mitigate greenhouse gas | CHβ, NβO emissions | -20% |
| π¦ Decrease AMR genes | qPCR abundance | -40% |
| π Maintain production | FCR, survival rate | Stable |
| π° Economic viability | ROI | Positive |
Home Dashboard IoT monitoring priority |
Real-time Monitoring DO, pH, Temperature |
Health Recording Photo + Voice capture |
Research Dashboard Comprehensive data view |
AMU Recording Automatic mg/kg calculation |
Data Collection Triangulation validation |
Key UI Features:
- β Glassmorphism design with semi-transparent cards
- β Network status indicator (green/red cloud icon)
- β Offline sync badge (shows pending records count)
- β Role-based interfaces (Farmer simple, Researcher comprehensive)
- β Vietnamese/English bilingual support
- β Real-time IoT data visualization
|
π‘οΈ Real-time IoT Monitoring
|
π± Simple Data Recording
|
|
π Smart Alerts
|
π Production Tracking
|
|
π Data Collection
|
β Quality Control
|
|
π€ Participatory Evaluation
|
π Data Export
|
Backend
FastAPI (Python 3.11) β PostgreSQL 15 + TimescaleDB
β MinIO (S3-compatible storage)
β EMQX MQTT (IoT broker)
β Redis (cache + Celery)
Mobile App
Flutter 3.x β Provider (state management)
β Hive (offline storage)
β Dio (HTTP client)
β Firebase Cloud Messaging
Infrastructure
Docker Compose β 9 containers
β Nginx reverse proxy
β Let's Encrypt SSL
β Prometheus + Grafana
CARA_APP/
βββ backend/ # FastAPI backend services
β βββ app/
β β βββ api/v1/ # REST API endpoints
β β βββ models/ # SQLAlchemy ORM models
β β βββ services/ # Business logic layer
β β βββ core/ # Config, security, database
β βββ Dockerfile
β βββ requirements.txt
β
βββ mobile_app/ # Flutter mobile application
β βββ lib/
β β βββ main.dart # Application entry point
β β βββ core/ # Core services & utilities
β β βββ features/ # Feature modules (home, auth, etc.)
β β βββ shared/ # Reusable widgets & themes
β βββ ios/ # iOS platform configuration
β βββ android/ # Android platform configuration
β βββ pubspec.yaml # Flutter dependencies
β
βββ infra/
β βββ docker/ # Docker Compose setup
β β βββ docker-compose.yml
β β βββ init-db.sql
β βββ nginx/ # Nginx reverse proxy config
β
βββ scripts/ # Development automation
β βββ quickstart.sh # One-command startup
β βββ run.sh # Mobile app launcher
β βββ verify_sprint1.sh
β
βββ docs/
βββ images/ # UI screenshots for README
Core Tables (10 tables)
farmers -- Farmer profiles (name, phone, consent)
ponds -- Pond metadata (species, volume, density)
amu_records -- AMU tracking (auto mg/kg calculation)
biomass_estimates -- Fish sampling data
production_parameters -- FCR, survival, yield
costs -- Economic tracking
alerts -- AI risk alerts
lab_results -- qPCR AMR gene data
interviews -- Participatory evaluation
audit_logs -- Complete audit trailKey Features:
- β Automatic mg/kg calculation (PostgreSQL computed column)
- β Multi-language enums (Vietnamese/English)
- β Complete audit trail for compliance
- β TimescaleDB for IoT time-series data
π Development Environment (Click to expand)
Already installed and verified:
- β Docker 27.4.0 & Docker Compose 2.30.3
- β Flutter 3.35.5 / Dart 3.9.0
- β Xcode 16.4 + CocoaPods 1.16.2
- β Android Studio Ladybug 2024.2.1
- β Ruby 3.4.0 + ffi 1.17.0
- β Homebrew 4.4.14
# Clone repository
git clone https://github.com/ChaokunHong/CARA.git
cd CARA
# Start all backend services (9 Docker containers)
./scripts/quickstart.sh
# Run mobile app
./run.sh # Auto-detects available devicesThat's it! The script will:
- β Start PostgreSQL, TimescaleDB, MinIO, EMQX, Redis
- β Initialize database schema with sample data
- β Verify all services are healthy
- β Launch Flutter app on selected device
| Service | URL | Credentials |
|---|---|---|
| API Documentation | http://localhost:8000/docs | - |
| MinIO Console | http://localhost:9001 | minioadmin / minioadmin123 |
| EMQX Dashboard | http://localhost:18083 | admin / cara_admin123 |
| PostgreSQL | localhost:5432 | cara_user / cara_password |
| Backend API | http://localhost:8000 | - |
# Copy example environment file
cp backend/.env.example backend/.env
# Edit configuration (optional)
nano backend/.envKey variables:
# Database
POSTGRES_URI=postgresql://cara_user:cara_password@localhost:5432/cara_db
# MinIO (S3-compatible storage)
MINIO_ENDPOINT=localhost:9000
MINIO_ACCESS_KEY=minioadmin
MINIO_SECRET_KEY=minioadmin123
# JWT Authentication
JWT_SECRET=your-secret-key-here
JWT_ALGORITHM=HS256
JWT_ACCESS_TOKEN_EXPIRE_MINUTES=30
# EMQX MQTT Broker
EMQX_URL=mqtt://localhost:1883cd backend
# Install dependencies
pip install -r requirements.txt
# Run database migrations
alembic upgrade head
# Start development server
uvicorn app.main:app --reload --port 8000
# Run tests
pytest tests/ -v --cov=app
# Check API health
curl http://localhost:8000/healthcd mobile_app
# Install dependencies
flutter pub get
# Generate Hive type adapters
flutter pub run build_runner build --delete-conflicting-outputs
# Run on iOS simulator
flutter run -d "iPhone 15 Pro"
# Run on Android emulator
flutter run -d "Pixel 8"
# Code analysis
flutter analyze
# Run tests
flutter test{
"farmer": {
"phone": "+84901234567",
"name": "Nguyen Van A",
"role": "farmer"
},
"researcher": {
"phone": "+84903456789",
"name": "Tran Thi B",
"role": "researcher"
}
}View Sprint 1 details
Infrastructure Setup
- Monorepo project structure
- Docker Compose environment (9 containers)
- PostgreSQL + TimescaleDB database
- MinIO object storage
- EMQX MQTT broker
- FastAPI backend with JWT auth
- Complete database schema (10 tables)
- iOS & Android platform setup
View Sprint 2 details
User Interface & Offline Foundation
- Dual role system (Farmer/Researcher)
- Glassmorphism UI design
- Photo capture + preview
- Offline queue system (Hive + connectivity_plus)
- Auto-sync when network recovers
- Network status indicator with sync badge
- AudioService & FileUploadService preparation
IoT Real-time Monitoring
- EMQX MQTT integration
- DO, pH, temperature, conductivity display
- TimescaleDB time-series storage
- Pond dashboard with live data
- AI risk scoring (0-100 scale)
- Smart alert triggers (<2min push)
| Sprint | Focus | Key Deliverables |
|---|---|---|
| 4 | Alert System | Push notifications, alert history, acknowledgment |
| 5 | AMU & Biomass | Full AMU workflow, biomass sampling, mg/kg auto-calc |
| 6 | Participatory Evaluation | Interview recording, acceptability scoring |
| 7 | Data Export | CSV export, lab results, sample tracking |
| 8 | Security & QA | Triangulation validation, audit logging |
| 9 | Performance | Load testing, production deployment, monitoring |
| 10 | Pilot Launch | 6 farmers onboarding, training materials |
# Unit tests with coverage
pytest tests/ -v --cov=app --cov-report=html
# Integration tests
pytest tests/integration/ -v
# Load testing (Apache Bench)
ab -n 1000 -c 10 http://localhost:8000/health# Unit tests
flutter test
# Widget tests
flutter test test/widget_test.dart
# Integration tests
flutter test integration_test/
# Code coverage
flutter test --coverage
genhtml coverage/lcov.info -o coverage/html# Full workflow test
./scripts/test_e2e.sh
# Performance benchmarks
flutter drive --target=test_driver/perf_test.dart| Metric | Target | Current |
|---|---|---|
| API Response Time (P95) | <500ms | ~100ms β |
| Mobile App Launch | <3s | ~2s β |
| Offline Queue Capacity | 100+ records | 200+ β |
| IoT Data Latency | <2min | TBD π§ |
| Photo Upload Time | <5s | TBD π§ |
| Test Coverage | >80% | ~70% π‘ |
- Authentication: JWT with refresh tokens
- Password Hashing: Bcrypt (cost factor 12)
- Transport Security: TLS 1.2+ enforced
- Rate Limiting: 100 requests/minute per IP
- Audit Logging: Complete CRUD trail
- Row-Level Security: Farmer data isolation
- Secret Management: Environment variables only
- CORS: Whitelist origins only
| Resource | Description |
|---|---|
| API Documentation | Interactive Swagger UI (FastAPI) |
| API ReDoc | Alternative API documentation |
| MinIO Console | Object storage management |
| EMQX Dashboard | MQTT broker monitoring |
This is a research project under active development. For development guidelines:
- Follow existing code patterns and project structure
- Write tests for new features (>80% coverage)
- Use English for all code, comments, and commit messages
- Ensure all tests pass before submitting changes
- Update README.md if adding new features
This is a research project under Oxford University Clinical Research Unit (OUCRU). Not for commercial use without permission.
Research Team
- Lead Researcher: Sonia Lewycka (slewycka@oucru.org)
- Project: CARA - Climate-smart AMR Reduction in Aquaculture
- Funding: ICARS Global
Technical Team
- Technical Lead: Chaokun Hong
- Backend: FastAPI + PostgreSQL + TimescaleDB
- Mobile: Flutter + Dart
- Infrastructure: Docker + Nginx + Let's Encrypt
- Oxford University Clinical Research Unit (OUCRU)
- ICARS Global Funding Program
- Vietnamese Aquaculture Farmers (Pilot Participants)
- Open Source Community (Flutter, FastAPI, PostgreSQL)
Built with β€οΈ for sustainable aquaculture





