A voice-first AI farming assistant designed specifically for blind and visually impaired farmers in South Africa. Manage livestock, get farming advice, and track vaccinations β all through voice commands and audio feedback.
- Voice-First Interface: Fully accessible via voice commands and audio feedback
- PIN Authentication: Secure 4-digit PIN login
- Livestock Management: Add, track, and manage multiple animal categories
- AI Assistant: Ask farming questions powered by Google Gemini AI
- Vaccination Tracking: Get alerts for upcoming vaccination schedules
- Image Recognition: Identify animal breeds from photos
- Offline Support: Works offline with service worker caching
- Data Backup: Export and import farm data
- Frontend: Vanilla JavaScript (no frameworks)
- Backend: Node.js + Express
- Storage: Browser LocalStorage + Service Workers
- AI: Google Gemini 2.0 Flash API
- Speech APIs: Web Speech API for voice input/output
- Node.js 14+ installed
- Google Gemini API key (Get one here)
- Modern browser with Speech API support (Chrome, Edge, Safari)
# Clone the repository
git clone <repository-url>
cd cloud-farmvoice-ai
# Install dependencies (only dotenv is needed)
npm install dotenvCreate a .env file from the template:
cp .env.example .envEdit .env and add your API key:
PORT=8080
GEMINI_API_KEY=your_api_key_here
NODE_ENV=developmentNever commit .env to Git! It's already in .gitignore.
# Development mode (with logging)
npm start
# or
node server.js
# Access at http://localhost:8080- First Visit: Click "Create Account" or say "register"
- Provide Details: Say your name, surname, and choose a 4-digit PIN
- Confirm: Verify your PIN to complete registration
Available anywhere in the app:
| Command | Action |
|---|---|
| "menu" | Return to home screen |
| "go back" | Return to previous screen |
| "repeat" | Repeat last spoken message |
| "logout" | Exit application |
- Add animals by voice or photo
- Organize by category (cattle, goats, sheep, etc.)
- Track breeds, colors, and ages
- Add health notes
- Ask farming questions
- Get health advice
- Livestock management tips
- Vaccination information
- Schedule vaccinations
- Receive alerts when due
- Track vaccination history
- Take photos of animals
- Auto-detect breed and color
- Save photo with animal profile
POST /api/ask
Content-Type: application/json
{
"question": "How do I prevent foot rot in cattle?"
}
Response:
{
"response": "Keep hooves dry and clean. Use hoof baths regularly..."
}
POST /api/analyze-image
Content-Type: application/json
{
"image": "base64_encoded_image_data"
}
Response:
{
"response": "This appears to be a brown Bonsmara cow."
}
-
API Key Protection
- API keys are kept in backend
.envfile - Frontend never exposes credentials
- Backend proxies all API requests
- API keys are kept in backend
-
Input Validation
- All user inputs are sanitized
- Names limited to 50 characters
- PIN strictly validated (4 digits only)
- HTML tags and special characters removed
-
Data Storage
- PIN hashing before storage
- No sensitive data in logs
- LocalStorage used securely for user data
-
Server Security
- CORS properly configured
- HTTP security headers enabled
- Request size limits (1MB max)
- Comprehensive error logging
- Service Worker caches static assets
- Works offline for all core features
- API requests show offline error gracefully
- Automatic cache updates when online
// In browser console
const backup = FarmStorage.exportData();
FarmStorage.downloadBackup();// Select a backup file
const file = document.querySelector('input[type="file"]').files[0];
FarmStorage.uploadBackup(file);| Browser | Support | Notes |
|---|---|---|
| Chrome | β Full | Best support for all APIs |
| Edge | β Full | Chromium-based, full support |
| Firefox | Speech Recognition not supported | |
| Safari | Limited Speech API support | |
| Safari iOS | Some voice features unavailable |
- Voice Recognition: Say "menu" to test speech recognition
- API Connectivity: Add an animal by voice to test AI
- Offline Mode: Disconnect internet and try using app
- Backup/Restore: Export data and import it
// Check if Speech APIs are supported
VoiceEngine.init() // Returns true/false
// Export data
console.log(FarmStorage.exportData())
// Verify PIN hashing
FarmStorage.hashPin('1234')- Update your browser (Speech API requires modern browser)
- Try Chrome or Edge for best compatibility
- Enable microphone permissions
- Verify
.envfile exists withGEMINI_API_KEY - Restart the server after changing
.env - Check server logs for API key validation
- Check browser console for errors
- Clear browser cache and reload
- Ensure HTTPS in production (required for Service Workers)
- Export backup before clearing
- Clear old data:
FarmStorage.clearAll() - Consider smaller image sizes for animals
cloud-farmvoice-ai/
βββ index.html # Main app shell
βββ styles.css # Styling
βββ server.js # Backend server
βββ sw.js # Service worker
βββ .env.example # Environment template
βββ .env # Local config (secret)
βββ .gitignore # Git ignore rules
βββ js/
β βββ app.js # App navigation
β βββ auth.js # Authentication
β βββ storage.js # Data persistence
β βββ voice-engine.js # Speech APIs
β βββ claude-api.js # AI integration
β βββ livestock.js # Livestock mgmt
β βββ animal.js # Animal details
β βββ vaccine.js # Vaccination tracking
β βββ vision.js # Image recognition
β βββ home.js # Home screen
β βββ assistant.js # Chat interface
βββ README.md
- Create new
.jsfile injs/folder - Add voice command handling in
VoiceEngine.checkGlobal() - Add screen in
index.html - Add navigation in
App.goTo() - Test with browser console
- Use vanilla JS (no frameworks)
- Validate all inputs
- Add try-catch for API calls
- Comment complex logic
- Test voice functionality
- Keep responses under 2 sentences
# Install PM2 for production
npm install -g pm2
# Start with PM2
pm2 start server.js --name "farmvoice"
# Logs
pm2 logs farmvoice
# Restart on reboot
pm2 startup
pm2 savePORT=8080
NODE_ENV=production
GEMINI_API_KEY=your_production_key# Using Let's Encrypt with Certbot
sudo certbot certonly --standalone -d yourdomain.com
# Update server.js to use HTTPS
# Load certificate files and use https.createServer()- Reduce Image Sizes: Limit animal photos to 1MB
- Enable Compression: Gzip static assets
- Cache Aggressively: Service worker caches 15s by default
- Lazy Load: Load animals on demand, not all at once
- Batch Operations: Group animal updates together
- Voice-First: All operations can be done by voice
- Audio Feedback: Every action produces clear voice feedback
- No Visuals Required: Works with screen readers
- Contact Information: For accessibility issues, file an issue
- Fork the repository
- Create a feature branch
- Make your changes
- Add appropriate tests
- Submit a pull request
[Add your license here]
- Bug Reports: File an issue on GitHub
- Feature Requests: Open a discussion
- Questions: Check existing issues first
- Built with Web Speech APIs
- Powered by Google Gemini AI
- Designed for South African smallholder farmers
- Voice interaction best practices from accessibility standards
- Multi-language support (Zulu, Xhosa, Sotho)
- SMS alerts for vaccination reminders
- Integration with veterinary services
- Offline image recognition
- Community farm data sharing
- Mobile app wrapper
- WhatsApp integration
Made with β€οΈ for farmers who rely on their hearing
Last Updated: March 28, 2026