_____ _ ____ _ _ _ _ _
| ___|__ ___ __| |/ ___| ___ ___ _ _ _ __(_) |_ _ _| \ | | ___| |_
| |_ / _ \ / _ \/ _` | | _ / __|/ _ \ | | | '__| | __| | | | \| |/ _ \ __|
| _| (_) | (_) | (_| | |_| | \__ \ __/ |_| | | | | |_| |_| | |\ | __/ |_
|_| \___/ \___/ \__,_|\____| |___/\___|\__,_|_| |_|\__|\__, |_| \_|\___|\__|
|___/
Empowering Global Food Security Through Data-Driven Intelligence
- Project Overview
- Features
- Tech Stack
- Architecture
- Getting Started
- Installation
- Usage
- Authentication & Authorization
- MBTI Personalization
- Deployment
- Development
- API Documentation
- Monitoring & Observability
- Security
- Troubleshooting
- Compatibility
- Cost Estimates
- Impact on Humanity
- Acknowledgments
- License
- Support
FoodSecurityNet is a production-ready, modular, full-stack web application designed to address global food insecurity by integrating agricultural, environmental, and socio-economic data to provide:
- Personalized farming recommendations powered by AI
- Interactive 3D agricultural visualizations using Three.js
- Natural language queries through LLM integration
- Real-time collaboration tools for farmers, policymakers, and NGOs
- Data-driven insights for sustainable food systems
According to the Food and Agriculture Organization (FAO), approximately 700 million people face hunger annually. Climate change, inadequate agricultural practices, limited market access, and socio-economic barriers exacerbate this crisis, particularly in vulnerable regions like Sub-Saharan Africa and South Asia.
FoodSecurityNet bridges the gap between data and actionable insights by:
- Aggregating multi-source data from FAO, USDA, NOAA, and local surveys
- Applying AI/ML models to predict optimal farming strategies
- Visualizing complex data in intuitive 3D maps and dashboards
- Enabling collaboration among stakeholders in real-time
- Personalizing experiences for diverse user types (MBTI-based)
Unlike traditional tools like QGIS (geospatial analysis) or FAO databases (agricultural data repositories), FoodSecurityNet:
- Integrates agricultural, environmental, and socio-economic data in one platform
- Predicts farming outcomes using AI/ML models
- Visualizes data in interactive 3D environments
- Collaborates with real-time multi-user sessions
- Personalizes based on 16 MBTI personality types
- Exports in multiple formats (PNG, SVG, STL, CSV, JSON)
- Farmers: Receive personalized crop recommendations and farming strategies
- Policymakers: Access data-driven insights for policy interventions
- NGOs: Coordinate relief efforts and food security programs
- Researchers: Analyze agricultural trends and environmental impacts
- Enterprise: Deploy at scale with SSO, MFA, and role-based access
- Agricultural Data: Crop yields, soil quality, irrigation data (CSV/JSON from FAO, USDA)
- Environmental Data: Climate conditions, temperature, rainfall, humidity (CSV/JSON from NOAA)
- Socio-Economic Data: Market access, income levels, food prices (CSV surveys)
- Format Support: CSV, JSON, GeoJSON for QGIS compatibility
- Data Validation: Automated input validation and error reporting
- Interactive Maps: Crop yield distributions, soil health zones, climate patterns
- Three.js Rendering: High-performance WebGL-based 3D graphics
- User Controls: Zoom, pan, rotate, layer toggling
- MBTI Customization: Visual styles tailored to personality types
- Export Options: PNG, SVG, STL (for 3D printing)
- Farming Strategies: Crop selection, irrigation methods, fertilizer usage
- PyTorch Models: Pre-trained models for yield prediction and optimization
- Individual & Community: Personalized and regional recommendations
- Real-time Predictions: Sub-second inference times
- Multi-threading: Optimized for high-performance computing
- Intuitive Interface: Ask questions in plain language
- MBTI-Tailored Responses: Strategic for ENTJ, creative for INFP, actionable for ESTP
- Example Queries:
- "What crops should I plant this season?"
- "How can I improve soil health sustainably?"
- "Quick farming tips for my region!"
- Troubleshooting Support: Automated debugging assistance
- WebSocket Integration: Live multi-user sessions
- Shared Dashboards: Synchronized visualizations and annotations
- Role-Based Access: Different permissions for farmers, moderators, admins
- MBTI Features: Leadership tools for ENTJ, empathy for INFJ
- Local Authentication: Email/password with bcrypt hashing
- Single Sign-On (SSO): Google, Microsoft, Okta, SAML 2.0
- Multi-Factor Authentication (MFA): TOTP, SMS, email verification
- Role-Based Access Control: USER, MODERATOR, ADMIN, ENTERPRISE
- JWT Tokens: Secure, stateless authentication
- 16 Personality Types: ENTJ, INFP, INFJ, ESTP, INTJ, INTP, ISTJ, ESFJ, ISFP, ENTP, ISFJ, ESFP, ENFJ, ESTJ, ISTP, ENFP
- UI Customization: Dashboards, visualizations, and workflows
- LLM Response Styles: Strategic, creative, actionable, empathetic
- Collaboration Tools: Tailored features for each type
- Images: PNG, SVG for reports and presentations
- 3D Models: STL for 3D printing and CAD integration
- Data: CSV, JSON for analysis in Excel, Python, R
- QGIS Compatibility: GeoJSON export for geospatial analysis
| Layer | Technology | Version |
|---|---|---|
| Frontend | React | 18.2.0 |
| Three.js | 0.160.0 | |
| Tailwind CSS | 3.4.0 | |
| Vite | 5.0.8 | |
| Axios | 1.6.0 | |
| Socket.IO Client | 4.6.0 | |
| Backend | Java | 17 |
| Spring Boot | 3.2.0 | |
| Spring Cloud Gateway | 2023.0.0 | |
| Spring Security | (included) | |
| Spring WebSocket | (included) | |
| AI/ML | Python | 3.10 |
| FastAPI | 0.109.0 | |
| PyTorch | 2.1.2 | |
| NumPy | 1.26.3 | |
| Pandas | 2.1.4 | |
| GeoPandas | 0.14.2 | |
| Scikit-learn | 1.4.0 | |
| LLM | Hugging Face Transformers | (latest) |
| xAI API | (optional) | |
| Database | PostgreSQL | 15-alpine |
| Redis | 7-alpine | |
| Authentication | JWT (JJWT) | 0.12.3 |
| OAuth2 | (via Spring Security) | |
| SAML 2.0 | (via Spring Security) | |
| Infrastructure | Docker | (latest) |
| Docker Compose | 3.8 | |
| Kubernetes | (compatible) | |
| NGINX | alpine | |
| Monitoring | Prometheus | (via Micrometer) |
| Grafana | (via Docker) | |
| Loki | (for logging) | |
| Testing | JUnit | 5 |
| Jest | (frontend) | |
| Pytest | (Python) | |
| Security | OWASP ZAP | (for audits) |
| Helmet.js | 7.1.0 | |
| Sanitize-HTML | 2.11.0 |
react,react-dom- UI frameworkthree,@react-three/fiber,@react-three/drei- 3D graphicsaxios- HTTP clientsocket.io-client- WebSocket communicationreact-plotly.js- Data visualizationstailwindcss- Utility-first CSSsanitize-html,helmet- Security
spring-cloud-starter-gateway- API Gatewayspring-boot-starter-security- Authentication/Authorizationspring-boot-starter-data-jpa- Database ORMspring-boot-starter-websocket- WebSocket supportspring-boot-starter-data-redis-reactive- Cachingresilience4j- Circuit breakerjjwt- JWT tokensmicrometer-registry-prometheus- Metrics
fastapi- REST API frameworktorch,torchvision- Deep learningnumpy,pandas- Data manipulationgeopandas- Geospatial datascikit-learn- Machine learning utilitiesuvicorn- ASGI serverprometheus-client- Metrics
┌─────────────────────────────────────────────────────────────────────┐
│ NGINX (Reverse Proxy) │
│ Port 80/443 (HTTPS/SSL) │
└────────────────────────┬────────────────────────────────────────────┘
│
┌───────────────┴────────────────┐
│ │
┌────────▼────────┐ ┌───────▼────────┐
│ Frontend │ │ API Gateway │
│ React + 3D │ │ Port 8080 │
│ Port 3000 │ │ Spring Cloud │
└─────────────────┘ └───────┬────────┘
│
┌────────────────────┼────────────────────┐
│ │ │
┌──────────▼──────────┐ ┌──────▼──────┐ ┌────────▼────────┐
│ Auth Service │ │ Agri │ │ LLM Service │
│ Port 8081 │ │ Integrator │ │ Port 8085 │
│ SSO/MFA/JWT │ │ Port 8082 │ │ Natural Lang. │
└─────────────────────┘ └──────┬──────┘ └────────┬────────┘
│ │
┌───────────────────────────────┼───────────────────┘
│ │
┌────────▼────────┐ ┌───────────▼──────────┐ ┌──────────────┐
│ Agri Visualizer│ │ User Session │ │ Collaboration│
│ Port 8083 │ │ Port 8084 │ │ Port 8086 │
│ 3D Generation │ │ Sessions/Bookmarks │ │ WebSocket │
└────────┬────────┘ └──────────────────────┘ └──────────────┘
│
│
┌────────▼────────┐ ┌──────────────────────┐
│ AI Model │ │ LLM Python │
│ Port 8000 │ │ Port 8001 │
│ PyTorch/FastAPI│ │ Transformers/xAI │
└─────────────────┘ └──────────────────────┘
│ │
└───────────────┬───────────────┘
│
┌───────────────┴────────────────┐
│ │
┌────────▼────────┐ ┌───────▼────────┐
│ PostgreSQL │ │ Redis │
│ Port 5432 │ │ Port 6379 │
│ Data Storage │ │ Caching │
└─────────────────┘ └────────────────┘
| Service | Purpose | Port | Technology |
|---|---|---|---|
| NGINX | Reverse proxy, SSL termination, load balancing | 80/443 | NGINX Alpine |
| Frontend | User interface, 3D visualization, forms | 3000 | React + Vite |
| API Gateway | Request routing, authentication, rate limiting | 8080 | Spring Cloud Gateway |
| Auth Service | Authentication, SSO, MFA, user management | 8081 | Spring Boot + Spring Security |
| Agri Integrator | Data ingestion, parsing, validation | 8082 | Spring Boot + JPA |
| Agri Visualizer | 3D model generation, export | 8083 | Spring Boot + Three.js data |
| User Session | Session management, annotations, bookmarks | 8084 | Spring Boot + Redis |
| LLM Service | Natural language processing, queries | 8085 | Spring Boot + Python bridge |
| Collaboration | Real-time WebSocket communication | 8086 | Spring Boot + WebSocket |
| AI Model | Farming predictions, ML inference | 8000 | FastAPI + PyTorch |
| LLM Python | LLM inference, Hugging Face/xAI | 8001 | FastAPI + Transformers |
| PostgreSQL | Relational data storage | 5432 | PostgreSQL 15 |
| Redis | Caching, session storage, rate limiting | 6379 | Redis 7 |
- User Authentication: Frontend → API Gateway → Auth Service → PostgreSQL
- Data Upload: Frontend → API Gateway → Agri Integrator → PostgreSQL
- AI Prediction: Frontend → API Gateway → Agri Visualizer → AI Model → PostgreSQL
- LLM Query: Frontend → API Gateway → LLM Service → LLM Python → Response
- 3D Visualization: Frontend → API Gateway → Agri Visualizer → Three.js data
- Collaboration: Frontend ↔ Collaboration Service (WebSocket) → Redis
Before you begin, ensure you have the following installed:
| Tool | Version | Purpose |
|---|---|---|
| Docker | 20.10+ | Container runtime |
| Docker Compose | 2.0+ | Multi-container orchestration |
| Node.js | 18.x+ | Frontend development |
| Java JDK | 17+ | Backend development |
| Python | 3.10+ | AI/ML development |
| Git | 2.x+ | Version control |
| Maven | 3.8+ | Java dependency management |
| NVIDIA GPU | (optional) | GPU acceleration for AI models |
Get FoodSecurityNet running in under 5 minutes:
# 1. Clone the repository
git clone https://github.com/sekacorn/FoodSecurityNet.git
cd FoodSecurityNet
# 2. Copy environment variables
cp .env.example .env
# 3. Edit .env file with your configuration
nano .env # or use your preferred editor
# 4. Start all services
docker-compose up --build
# 5. Access the application
# Frontend: http://localhost:3000
# API Gateway: http://localhost:8080
# API Documentation: http://localhost:8080/swagger-ui.htmlThat's it! The application should now be running with all services.
Edit the .env file to configure:
# Database
POSTGRES_PASSWORD=your_secure_password
# JWT Secret
JWT_SECRET=your-very-secure-jwt-secret-key
# OAuth2 for SSO
OAUTH2_CLIENT_ID=your-google-client-id
OAUTH2_CLIENT_SECRET=your-google-client-secret
# SAML for Enterprise SSO
SAML_ENTITY_ID=foodsecuritynet
SAML_IDP_METADATA_URL=https://your-idp.com/metadata
# LLM API Keys
HF_API_KEY=your-huggingface-api-key
XAI_API_KEY=your-xai-api-key
LLM_MODEL_NAME=gpt2
# External Data Sources
FAO_API_KEY=your-fao-api-key
NOAA_API_KEY=your-noaa-api-key
USDA_API_KEY=your-usda-api-keygit clone https://github.com/sekacorn/FoodSecurityNet.git
cd FoodSecurityNet# Start PostgreSQL container
docker run -d \
--name foodsec-postgres \
-e POSTGRES_DB=foodsecuritynet \
-e POSTGRES_USER=foodsec_user \
-e POSTGRES_PASSWORD=changeme \
-p 5432:5432 \
postgres:15-alpine
# Initialize schema
docker exec -i foodsec-postgres psql -U foodsec_user -d foodsecuritynet < database/postgres/schema.sqldocker run -d \
--name foodsec-redis \
-p 6379:6379 \
redis:7-alpine# Build all backend services
cd backend
# Auth Service
cd auth-service
mvn clean install
mvn spring-boot:run &
cd ..
# API Gateway
cd api-gateway
mvn clean install
mvn spring-boot:run &
cd ..
# Agri Integrator
cd agri-integrator
mvn clean install
mvn spring-boot:run &
cd ..
# Agri Visualizer
cd agri-visualizer
mvn clean install
mvn spring-boot:run &
cd ..
# User Session Service
cd user-session
mvn clean install
mvn spring-boot:run &
cd ..
# LLM Service
cd llm-service
mvn clean install
mvn spring-boot:run &
cd ..
# Collaboration Service
cd collaboration-service
mvn clean install
mvn spring-boot:run &
cd ..
cd ..cd ai-model
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Start AI Model Service
uvicorn agri_predictor:app --host 0.0.0.0 --port 8000 &
# Start LLM Service
cd llm-service
pip install -r requirements.txt
uvicorn llm_service:app --host 0.0.0.0 --port 8001 &
cd ..
cd ..cd frontend
# Install dependencies
npm install
# Start development server
npm run dev- Frontend: http://localhost:3000
- API Gateway: http://localhost:8080
- Auth Service: http://localhost:8081
- Agri Integrator: http://localhost:8082
- Agri Visualizer: http://localhost:8083
- API Documentation: http://localhost:8080/swagger-ui.html
cd backend/auth-service
mvn test
cd ../api-gateway
mvn test
cd ../agri-integrator
mvn test
# Run all backend tests
cd backend
mvn testcd frontend
npm testcd ai-model
pytest
cd llm-service
pytest# Run integration tests with Docker Compose
docker-compose -f docker-compose.test.yml up --abort-on-container-exitOnce the application is running, you can access it at:
- Frontend Application: http://localhost:3000
- API Gateway: http://localhost:8080
- API Documentation (Swagger): http://localhost:8080/swagger-ui.html
- Health Check: http://localhost:8080/actuator/health
Local Authentication:
# Register a new user
curl -X POST http://localhost:8081/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "farmer@example.com",
"password": "SecurePassword123!",
"firstName": "John",
"lastName": "Farmer",
"mbtiType": "ENTJ"
}'
# Login
curl -X POST http://localhost:8081/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "farmer@example.com",
"password": "SecurePassword123!"
}'SSO Authentication:
- Navigate to http://localhost:3000/login
- Click "Sign in with Google" or "Sign in with Microsoft"
- Complete OAuth2 flow
- Get redirected back with JWT token
# Upload CSV data
curl -X POST http://localhost:8082/api/data/upload \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-F "file=@crop_yield_data.csv" \
-F "dataType=AGRICULTURAL"
# Upload JSON data
curl -X POST http://localhost:8082/api/data/upload \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-F "file=@climate_data.json" \
-F "dataType=ENVIRONMENTAL"# Request 3D visualization
curl -X POST http://localhost:8083/api/visualize/3d \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"dataType": "CROP_YIELD",
"region": "Sub-Saharan Africa",
"timeRange": {
"start": "2023-01-01",
"end": "2023-12-31"
},
"mbtiType": "ENTJ"
}'# Request AI predictions
curl -X POST http://localhost:8083/api/predict \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"location": {
"latitude": -1.2921,
"longitude": 36.8219
},
"soilType": "CLAY_LOAM",
"currentCrop": "MAIZE",
"season": "RAINY"
}'# Natural language query
curl -X POST http://localhost:8085/api/llm/query \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"query": "What crops should I plant this season in Kenya?",
"mbtiType": "INFJ",
"context": {
"location": "Kenya",
"season": "RAINY"
}
}'# Export as PNG
curl -X POST http://localhost:8083/api/export/png \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d "visualizationId=12345" \
-o crop_yield_map.png
# Export as STL for 3D printing
curl -X POST http://localhost:8083/api/export/stl \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d "visualizationId=12345" \
-o terrain_model.stl
# Export data as CSV
curl -X POST http://localhost:8082/api/export/csv \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d "datasetId=67890" \
-o agricultural_data.csvcurl -X GET http://localhost:8081/api/users/me \
-H "Authorization: Bearer YOUR_JWT_TOKEN"curl -X GET http://localhost:8082/api/data/list \
-H "Authorization: Bearer YOUR_JWT_TOKEN"// Frontend JavaScript (WebSocket)
import io from 'socket.io-client';
const socket = io('http://localhost:8086', {
auth: {
token: 'YOUR_JWT_TOKEN'
}
});
socket.emit('join-session', { sessionId: '12345' });
socket.on('user-joined', (data) => {
console.log('User joined:', data);
});
socket.on('annotation-added', (annotation) => {
console.log('New annotation:', annotation);
});FoodSecurityNet supports multiple authentication methods to accommodate different user types and security requirements.
- Registration: POST
/api/auth/register - Login: POST
/api/auth/login - Password Hashing: bcrypt with 12 rounds
- Token Type: JWT with 24-hour expiration
- Refresh Tokens: 7-day expiration, stored in HttpOnly cookies
Supported Providers:
| Provider | Protocol | Configuration |
|---|---|---|
| OAuth2 | Set OAUTH2_CLIENT_ID and OAUTH2_CLIENT_SECRET |
|
| Microsoft | OAuth2 | Configure Azure AD application |
| Okta | SAML 2.0 | Set SAML_ENTITY_ID and SAML_IDP_METADATA_URL |
| Generic SAML | SAML 2.0 | Custom IdP metadata URL |
SSO Endpoints:
- Google: GET
/api/sso/google - Microsoft: GET
/api/sso/microsoft - Okta: GET
/api/sso/okta - SAML: POST
/api/sso/saml
Configuration Example:
# backend/auth-service/src/main/resources/application.yml
spring:
security:
oauth2:
client:
registration:
google:
client-id: ${OAUTH2_CLIENT_ID}
client-secret: ${OAUTH2_CLIENT_SECRET}
scope: profile,email
microsoft:
client-id: ${MS_CLIENT_ID}
client-secret: ${MS_CLIENT_SECRET}
scope: openid,profile,emailSupported MFA Methods:
| Method | Description | Setup Endpoint |
|---|---|---|
| TOTP | Time-based One-Time Password (Google Authenticator, Authy) | POST /api/mfa/setup/totp |
| SMS | SMS verification code | POST /api/mfa/setup/sms |
| Email verification code | POST /api/mfa/setup/email |
|
| Backup Codes | One-time use backup codes | GET /api/mfa/backup-codes |
MFA Setup Flow:
- Enable MFA: POST
/api/mfa/enable - Setup TOTP: Scan QR code with authenticator app
- Verify Setup: POST
/api/mfa/verifywith first code - Generate Backup Codes: GET
/api/mfa/backup-codes - Login with MFA: POST
/api/auth/login→ POST/api/mfa/verify
MFA Configuration:
# .env
MFA_ISSUER=FoodSecurityNet
MFA_ENABLED=true
# Email for MFA codes
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your-email@example.com
SMTP_PASSWORD=your-email-passwordFoodSecurityNet implements role-based access control (RBAC) with four roles:
| Role | Description | Permissions |
|---|---|---|
| USER | Standard farmer/researcher | View data, upload own data, generate visualizations, use LLM |
| MODERATOR | Community leader/NGO worker | All USER permissions + moderate collaboration sessions, review user submissions |
| ADMIN | System administrator | All MODERATOR permissions + manage users, configure system settings, access audit logs |
| ENTERPRISE | Enterprise client | All ADMIN permissions + SSO configuration, custom branding, advanced analytics |
Role Assignment:
# Assign role via API (Admin only)
curl -X PUT http://localhost:8081/api/users/123/role \
-H "Authorization: Bearer ADMIN_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"role": "MODERATOR"}'{
"sub": "user@example.com",
"userId": "123",
"roles": ["USER", "MODERATOR"],
"mbtiType": "ENTJ",
"iat": 1640000000,
"exp": 1640086400
}- HTTPS Only: All authentication endpoints require HTTPS in production
- Token Storage: Store JWT in memory or secure HttpOnly cookies, never localStorage
- Token Refresh: Refresh tokens before expiration to avoid session disruption
- Password Policy: Minimum 8 characters, uppercase, lowercase, number, special character
- Rate Limiting: 5 failed login attempts → 15-minute lockout
- Audit Logging: All authentication events logged for security monitoring
FoodSecurityNet provides a unique personalization layer based on the Myers-Briggs Type Indicator (MBTI), tailoring the user experience to 16 personality types.
| Type | Name | Characteristics |
|---|---|---|
| ENTJ | The Commander | Strategic, leadership-focused, results-driven |
| INTJ | The Mastermind | Analytical, strategic, long-term planning |
| ENTP | The Debater | Innovative, exploratory, idea-driven |
| INTP | The Thinker | Logical, detail-oriented, problem-solving |
| INFJ | The Advocate | Intuitive, empathetic, holistic |
| INFP | The Mediator | Creative, value-driven, narrative-focused |
| ENFJ | The Protagonist | Inspirational, visionary, community-focused |
| ENFP | The Campaigner | Enthusiastic, creative, people-oriented |
| ISTJ | The Logistician | Structured, organized, rule-based |
| ISFJ | The Defender | Supportive, practical, nurturing |
| ESTJ | The Executive | Authoritative, task-oriented, organized |
| ESFJ | The Consul | Warm, community-focused, supportive |
| ISTP | The Virtuoso | Practical, hands-on, problem-solving |
| ISFP | The Adventurer | Creative, sensory-driven, flexible |
| ESTP | The Entrepreneur | Actionable, dynamic, fast-paced |
| ESFP | The Entertainer | Vibrant, engaging, energetic |
ENTJ (The Commander):
- Dashboard: Strategic metrics, crop yield forecasts, policy recommendations
- Visualizations: Clean, professional 3D maps with performance metrics
- Workflow: Fast, results-focused navigation with executive summaries
INFP (The Mediator):
- Dashboard: Artistic, narrative-driven interfaces with storytelling elements
- Visualizations: Colorful, creative 3D maps with aesthetic appeal
- Workflow: Flexible, value-aligned workflows with inspirational prompts
ESTP (The Entrepreneur):
- Dashboard: Dynamic, real-time updates with instant feedback
- Visualizations: Interactive, fast-loading 3D maps
- Workflow: Quick-action buttons, concise information, minimal clicks
ENTJ Query: "What crops should I plant?"
- Response: "Based on your region's climate and soil data, I recommend planting drought-resistant maize and sorghum. This strategy will maximize yield by 23% and reduce water usage by 30%. Implement within 2 weeks for optimal results."
INFJ Query: "How can I improve soil health?"
- Response: "Nurturing your soil is about creating a sustainable ecosystem that honors the land. Consider incorporating organic compost and cover crops like clover, which will enrich nutrients naturally and support biodiversity. This holistic approach aligns with long-term environmental stewardship."
ESTP Query: "Quick farming tips!"
- Response: "1. Plant maize now. 2. Use drip irrigation. 3. Apply fertilizer in 2 weeks. 4. Harvest in 90 days. Done!"
| MBTI Type | Collaboration Style |
|---|---|
| ENTJ | Leadership tools, decision-making dashboards, strategy planning |
| INFJ | Empathy tools, conflict resolution, community harmony |
| ESTP | Fast-paced, live updates, action-oriented collaboration |
| ISTJ | Structured task lists, organized workflows, clear protocols |
curl -X POST http://localhost:8081/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "SecurePassword123!",
"mbtiType": "ENTJ"
}'curl -X PUT http://localhost:8081/api/users/me \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"mbtiType": "INFP"
}'INTJ: "Detailed soil analysis shows nitrogen deficiency at 15ppm. Implement precision fertilization strategy with controlled-release urea at 120kg/ha. Expected yield increase: 18-22% over 120 days."
ESFJ: "Your community would benefit from planting beans together! This crop improves soil health and provides nutritious food for everyone. Let's coordinate with neighboring farms for a group harvest celebration."
INTP: "Error trace: NullPointerException at line 247. Root cause: CSV header mismatch. Solution: Validate column names ['crop', 'yield', 'region'] against schema. Detailed logs attached."
ISFJ: "Don't worry, we can fix this together! It looks like your CSV file has a small formatting issue. Let's check the column names step-by-step. I'll guide you through it."
Create docker-compose.prod.yml:
version: '3.8'
services:
# All services as defined in docker-compose.yml
# Add production-specific configurations:
api-gateway:
environment:
SPRING_PROFILES_ACTIVE: prod
JWT_SECRET: ${JWT_SECRET}
restart: always
deploy:
resources:
limits:
cpus: '2'
memory: 2G
reservations:
cpus: '1'
memory: 1G
# Enable SSL/TLS
nginx:
volumes:
- ./infra/nginx/nginx.prod.conf:/etc/nginx/conf.d/default.conf
- /etc/letsencrypt:/etc/nginx/ssl:ro
ports:
- "443:443"Deploy:
docker-compose -f docker-compose.prod.yml up -d- Kubernetes cluster (GKE, EKS, AKS, or on-premise)
- kubectl configured
- Docker images pushed to registry
# Apply all deployments
kubectl apply -f infra/kubernetes/
# Check status
kubectl get pods -n foodsecuritynet
# Expose services
kubectl apply -f infra/kubernetes/ingress.yml# infra/kubernetes/api-gateway-deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-gateway
namespace: foodsecuritynet
spec:
replicas: 3
selector:
matchLabels:
app: api-gateway
template:
metadata:
labels:
app: api-gateway
spec:
containers:
- name: api-gateway
image: foodsecuritynet/api-gateway:latest
ports:
- containerPort: 8080
env:
- name: SPRING_PROFILES_ACTIVE
value: "kubernetes"
- name: JWT_SECRET
valueFrom:
secretKeyRef:
name: foodsec-secrets
key: jwt-secret
resources:
limits:
cpu: "2"
memory: "2Gi"
requests:
cpu: "1"
memory: "1Gi"
livenessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 60
periodSeconds: 10
readinessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 30
periodSeconds: 5Services Used:
- ECS/EKS: Container orchestration
- RDS: PostgreSQL database
- ElastiCache: Redis caching
- ALB: Load balancing
- S3: Data storage
- CloudWatch: Monitoring
Deployment:
# Create EKS cluster
eksctl create cluster --name foodsecuritynet --region us-east-1 --nodes 3
# Deploy application
kubectl apply -f infra/kubernetes/
# Create RDS instance
aws rds create-db-instance \
--db-instance-identifier foodsec-postgres \
--db-instance-class db.t3.medium \
--engine postgres \
--master-username foodsec_user \
--master-user-password ${DB_PASSWORD}Services Used:
- AKS: Kubernetes service
- Azure Database for PostgreSQL: Database
- Azure Cache for Redis: Caching
- Application Gateway: Load balancing
- Blob Storage: Data storage
- Azure Monitor: Monitoring
Deployment:
# Create AKS cluster
az aks create \
--resource-group foodsecuritynet \
--name foodsec-aks \
--node-count 3 \
--enable-managed-identity
# Get credentials
az aks get-credentials --resource-group foodsecuritynet --name foodsec-aks
# Deploy
kubectl apply -f infra/kubernetes/Services Used:
- GKE: Kubernetes service
- Cloud SQL: PostgreSQL database
- Memorystore: Redis caching
- Cloud Load Balancing: Load balancing
- Cloud Storage: Data storage
- Cloud Monitoring: Monitoring
Deployment:
# Create GKE cluster
gcloud container clusters create foodsecuritynet \
--num-nodes=3 \
--machine-type=n1-standard-2 \
--zone=us-central1-a
# Get credentials
gcloud container clusters get-credentials foodsecuritynet
# Deploy
kubectl apply -f infra/kubernetes/# Horizontal Pod Autoscaler
kubectl autoscale deployment api-gateway \
--cpu-percent=70 \
--min=3 \
--max=10# Create Kubernetes secrets
kubectl create secret generic foodsec-secrets \
--from-literal=jwt-secret=${JWT_SECRET} \
--from-literal=postgres-password=${POSTGRES_PASSWORD} \
--from-literal=oauth2-client-secret=${OAUTH2_CLIENT_SECRET}# Using cert-manager for automatic SSL
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.13.0/cert-manager.yaml
# Create ClusterIssuer
kubectl apply -f infra/kubernetes/cert-issuer.yml# Automated PostgreSQL backups
kubectl create cronjob postgres-backup \
--image=postgres:15-alpine \
--schedule="0 2 * * *" \
-- pg_dump -h postgres -U foodsec_user foodsecuritynet > backup.sql# Deploy Prometheus and Grafana
helm install prometheus prometheus-community/kube-prometheus-stack \
--namespace monitoring \
--create-namespaceFoodSecurityNet/
├── backend/ # Spring Boot microservices
│ ├── api-gateway/ # API Gateway (Port 8080)
│ ├── auth-service/ # Authentication & SSO (Port 8081)
│ ├── agri-integrator/ # Data integration (Port 8082)
│ ├── agri-visualizer/ # 3D visualization (Port 8083)
│ ├── user-session/ # Session management (Port 8084)
│ ├── llm-service/ # LLM queries (Port 8085)
│ └── collaboration-service/ # WebSocket collaboration (Port 8086)
├── frontend/ # React + Three.js
│ ├── public/ # Static assets
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── pages/ # Page components
│ │ ├── services/ # API clients
│ │ ├── hooks/ # Custom hooks
│ │ ├── utils/ # Utilities
│ │ └── App.jsx # Main app
│ ├── package.json
│ └── vite.config.js
├── ai-model/ # Python AI/ML services
│ ├── agri_predictor.py # FastAPI + PyTorch
│ ├── llm-service/ # LLM Python service
│ ├── model.pt # Pre-trained model
│ └── requirements.txt
├── database/
│ ├── postgres/
│ │ └── schema.sql # Database schema
│ └── redis/
│ └── config.yaml # Redis configuration
├── infra/
│ ├── kubernetes/ # Kubernetes manifests
│ │ ├── deployments/
│ │ ├── services/
│ │ └── ingress.yml
│ └── nginx/
│ ├── default.conf # NGINX config
│ └── ssl/ # SSL certificates
├── docker-compose.yml # Local development
├── .env.example # Environment variables template
├── .gitignore
└── README.md
- Style: Google Java Style Guide
- Formatting: 4 spaces, 120 character line limit
- Naming: CamelCase for classes, camelCase for methods/variables
- Documentation: Javadoc for public methods and classes
- Testing: Minimum 80% code coverage (JUnit 5)
Example:
/**
* Service for managing agricultural data integration.
*/
@Service
public class DataIntegrationService {
/**
* Parses and validates uploaded CSV data.
*
* @param file the uploaded CSV file
* @return parsed agricultural data
* @throws DataValidationException if validation fails
*/
public AgriData parseAndValidate(MultipartFile file) throws DataValidationException {
// Implementation
}
}- Style: Airbnb JavaScript Style Guide
- Formatting: 2 spaces, 100 character line limit
- Naming: PascalCase for components, camelCase for functions/variables
- Documentation: JSDoc for complex functions
- Testing: Minimum 80% code coverage (Jest + React Testing Library)
Example:
/**
* Component for displaying 3D agricultural visualizations.
*
* @param {Object} props - Component props
* @param {string} props.dataType - Type of data to visualize
* @param {string} props.mbtiType - User's MBTI personality type
*/
const AgriViewer = ({ dataType, mbtiType }) => {
// Implementation
};- Style: PEP 8
- Formatting: 4 spaces, 120 character line limit
- Naming: snake_case for functions/variables, PascalCase for classes
- Documentation: Docstrings for all functions and classes
- Testing: Minimum 80% code coverage (Pytest)
Example:
def predict_crop_yield(
soil_data: pd.DataFrame,
climate_data: pd.DataFrame,
model: torch.nn.Module
) -> np.ndarray:
"""
Predict crop yield based on soil and climate data.
Args:
soil_data: DataFrame containing soil properties
climate_data: DataFrame containing climate metrics
model: Trained PyTorch model
Returns:
Predicted crop yields as numpy array
"""
# Implementation# Backend
mvn test
# Frontend
npm test
# Python
pytest# API integration tests
mvn verify -P integration-tests
# E2E tests
npm run test:e2e# Backend coverage report
mvn jacoco:report
# Frontend coverage report
npm run test:coverage
# Python coverage report
pytest --cov=. --cov-report=htmlgit clone https://github.com/YOUR_USERNAME/foodsecuritynet.git
cd FoodSecurityNet
git remote add upstream https://github.com/sekacorn/FoodSecurityNet.gitgit checkout -b feature/your-feature-name- Follow coding standards
- Write tests for new features
- Update documentation
# Run all tests
docker-compose -f docker-compose.test.yml up --abort-on-container-exitgit add .
git commit -m "feat: add new feature description"Commit Message Format:
feat:New featurefix:Bug fixdocs:Documentation changesstyle:Code formattingrefactor:Code refactoringtest:Test additions/changeschore:Build/tooling changes
git push origin feature/your-feature-nameThen create a Pull Request on GitHub.
main (production)
↑
└── develop (integration)
↑
├── feature/feature-1
├── feature/feature-2
├── bugfix/bug-1
└── hotfix/critical-fix
Branch Naming:
feature/- New featuresbugfix/- Bug fixeshotfix/- Critical production fixesrefactor/- Code refactoringdocs/- Documentation updates
Access interactive API documentation:
- Swagger UI: http://localhost:8080/swagger-ui.html
- OpenAPI JSON: http://localhost:8080/v3/api-docs
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register |
Register new user |
| POST | /api/auth/login |
Login with email/password |
| POST | /api/auth/refresh |
Refresh JWT token |
| POST | /api/auth/logout |
Logout user |
| GET | /api/sso/google |
Google OAuth2 login |
| GET | /api/sso/microsoft |
Microsoft OAuth2 login |
| POST | /api/mfa/enable |
Enable MFA |
| POST | /api/mfa/verify |
Verify MFA code |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/data/upload |
Upload CSV/JSON data |
| GET | /api/data/list |
List available datasets |
| GET | /api/data/{id} |
Get dataset by ID |
| DELETE | /api/data/{id} |
Delete dataset |
| POST | /api/export/csv |
Export data as CSV |
| POST | /api/export/json |
Export data as JSON |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/visualize/3d |
Generate 3D visualization |
| GET | /api/visualize/{id} |
Get visualization by ID |
| POST | /api/export/png |
Export as PNG image |
| POST | /api/export/svg |
Export as SVG image |
| POST | /api/export/stl |
Export as STL 3D model |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/predict |
Get AI farming recommendations |
| GET | /api/predictions/history |
Get prediction history |
| GET | /api/models/info |
Get model information |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/llm/query |
Natural language query |
| POST | /api/llm/troubleshoot |
Troubleshooting assistance |
| GET | /api/llm/history |
Query history |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/users/me |
Get current user profile |
| PUT | /api/users/me |
Update user profile |
| PUT | /api/users/{id}/role |
Update user role (Admin) |
| GET | /api/users/{id} |
Get user by ID (Admin) |
| WebSocket Event | Description |
|---|---|
join-session |
Join collaboration session |
leave-session |
Leave collaboration session |
add-annotation |
Add annotation to visualization |
cursor-move |
Share cursor position |
chat-message |
Send chat message |
Client Auth Service Database
| | |
|-- POST /api/auth/login --> | |
| (email, password) | |
| |-- Query user -------> |
| |<- User data ----------|
| |-- Verify password |
| |-- Generate JWT |
|<- JWT token --------------| |
| | |
|-- GET /api/data/list ----> | |
| (Authorization: Bearer) | |
| |-- Validate JWT |
| |-- Check permissions |
| |-- Query data -------> |
|<- Data list --------------|<- Data --------------|
FoodSecurityNet exposes Prometheus-compatible metrics at /actuator/prometheus.
Key Metrics:
| Metric | Type | Description |
|---|---|---|
http_server_requests_seconds |
Histogram | HTTP request duration |
jvm_memory_used_bytes |
Gauge | JVM memory usage |
system_cpu_usage |
Gauge | System CPU usage |
database_connections_active |
Gauge | Active DB connections |
ai_model_inference_seconds |
Histogram | AI inference time |
llm_query_duration_seconds |
Histogram | LLM query duration |
websocket_connections_active |
Gauge | Active WebSocket connections |
Prometheus Configuration:
# prometheus.yml
scrape_configs:
- job_name: 'foodsecuritynet'
metrics_path: '/actuator/prometheus'
static_configs:
- targets:
- 'api-gateway:8080'
- 'auth-service:8081'
- 'agri-integrator:8082'
- 'agri-visualizer:8083'Access Grafana dashboards at http://localhost:3001 (default credentials: admin/admin).
Pre-configured Dashboards:
- System Overview: CPU, memory, disk, network metrics
- API Performance: Request rates, latency, error rates
- Database Metrics: Connection pool, query performance
- AI/ML Metrics: Inference time, model accuracy, GPU usage
- User Activity: Active users, session duration, feature usage
Import Dashboard:
# Import from Grafana.com
Dashboard ID: 12345 # FoodSecurityNet DashboardLog Levels:
ERROR: Application errors, exceptionsWARN: Warnings, deprecationsINFO: General application flowDEBUG: Detailed debugging informationTRACE: Fine-grained trace logs
Structured Logging:
{
"timestamp": "2024-01-15T10:30:00Z",
"level": "INFO",
"service": "agri-visualizer",
"traceId": "abc123",
"spanId": "def456",
"message": "Generated 3D visualization",
"metadata": {
"userId": "123",
"visualizationId": "viz-789",
"duration": "2.3s"
}
}Query Logs in Loki:
# All errors in last hour
{service="agri-visualizer"} |= "ERROR" | json | __error__="" | level="ERROR"
# Slow AI predictions
{service="ai-model"} | json | duration > 5s
Each service exposes health check endpoints:
Endpoints:
/actuator/health- Overall health status/actuator/health/liveness- Liveness probe/actuator/health/readiness- Readiness probe
Example Response:
{
"status": "UP",
"components": {
"db": {
"status": "UP",
"details": {
"database": "PostgreSQL",
"validationQuery": "isValid()"
}
},
"redis": {
"status": "UP",
"details": {
"version": "7.0.0"
}
},
"diskSpace": {
"status": "UP",
"details": {
"total": 499963174912,
"free": 123456789012
}
}
}
}Prometheus Alert Rules:
# alerts.yml
groups:
- name: foodsecuritynet
interval: 30s
rules:
- alert: HighErrorRate
expr: rate(http_server_requests_seconds_count{status=~"5.."}[5m]) > 0.05
for: 5m
labels:
severity: critical
annotations:
summary: "High error rate detected"
description: "Error rate is {{ $value }} requests/sec"
- alert: HighMemoryUsage
expr: jvm_memory_used_bytes / jvm_memory_max_bytes > 0.9
for: 5m
labels:
severity: warning
annotations:
summary: "High memory usage"
description: "Memory usage is {{ $value | humanizePercentage }}"FoodSecurityNet follows OWASP Top 10 security guidelines:
| Vulnerability | Mitigation |
|---|---|
| Injection | Parameterized queries, input validation, sanitization |
| Broken Authentication | JWT, MFA, password hashing (bcrypt), rate limiting |
| Sensitive Data Exposure | HTTPS/TLS, data encryption at rest (AES-256) |
| XML External Entities | Disable XML external entity processing |
| Broken Access Control | RBAC, JWT validation, permission checks |
| Security Misconfiguration | Secure defaults, regular updates, minimal privileges |
| Cross-Site Scripting (XSS) | Content Security Policy, sanitize-html, React auto-escaping |
| Insecure Deserialization | Validate serialized data, avoid untrusted sources |
| Using Components with Known Vulnerabilities | Dependency scanning, automated updates |
| Insufficient Logging & Monitoring | Structured logging, audit trails, alerting |
In Transit:
- TLS 1.3 for all HTTPS connections
- WebSocket Secure (WSS) for real-time communication
- Certificate pinning for mobile apps
At Rest:
- AES-256 encryption for database fields (PII, passwords)
- Encrypted backups
- Key rotation every 90 days
Implementation:
// Spring Security TLS configuration
@Configuration
public class SecurityConfig {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.requiresChannel()
.anyRequest()
.requiresSecure(); // Force HTTPS
return http.build();
}
}API Gateway Configuration:
# application.yml
spring:
cloud:
gateway:
routes:
- id: auth-service
uri: http://auth-service:8081
predicates:
- Path=/api/auth/**
filters:
- name: RequestRateLimiter
args:
redis-rate-limiter.replenishRate: 10
redis-rate-limiter.burstCapacity: 20
redis-rate-limiter.requestedTokens: 1Rate Limits:
| Endpoint | Limit | Window |
|---|---|---|
/api/auth/login |
5 requests | 15 minutes |
/api/data/upload |
100 requests | 1 hour |
/api/visualize/** |
50 requests | 1 hour |
/api/llm/query |
30 requests | 1 hour |
@Configuration
public class CorsConfig {
@Bean
public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration config = new CorsConfiguration();
config.setAllowedOrigins(Arrays.asList(
"https://foodsecuritynet.org",
"https://app.foodsecuritynet.org"
));
config.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE"));
config.setAllowedHeaders(Arrays.asList("Authorization", "Content-Type"));
config.setMaxAge(3600L);
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", config);
return source;
}
}Backend Validation:
@PostMapping("/api/data/upload")
public ResponseEntity<AgriData> uploadData(
@Valid @RequestBody DataUploadRequest request
) {
// @Valid triggers Hibernate Validator
}
public class DataUploadRequest {
@NotNull(message = "Data type is required")
@Pattern(regexp = "AGRICULTURAL|ENVIRONMENTAL|SOCIOECONOMIC")
private String dataType;
@NotBlank(message = "File content is required")
@Size(max = 10485760, message = "File size must not exceed 10MB")
private String fileContent;
}Frontend Sanitization:
import sanitizeHtml from 'sanitize-html';
const sanitizeInput = (input) => {
return sanitizeHtml(input, {
allowedTags: [],
allowedAttributes: {}
});
};// Helmet.js configuration
import helmet from 'helmet';
app.use(helmet({
contentSecurityPolicy: {
directives: {
defaultSrc: ["'self'"],
scriptSrc: ["'self'", "'unsafe-inline'"],
styleSrc: ["'self'", "'unsafe-inline'"],
imgSrc: ["'self'", "data:", "https:"],
connectSrc: ["'self'", "wss:", "https:"]
}
},
hsts: {
maxAge: 31536000,
includeSubDomains: true,
preload: true
}
}));# Backend (Maven)
mvn org.owasp:dependency-check-maven:check
# Frontend (npm)
npm audit
# Python
pip-auditRun OWASP ZAP Scan:
docker run -v $(pwd):/zap/wrk/:rw -t owasp/zap2docker-stable \
zap-baseline.py -t http://localhost:8080 -r zap-report.htmlAudit Logging:
All security-relevant events are logged:
- User authentication/logout
- Failed login attempts
- Permission denials
- Data access (read/write/delete)
- Configuration changes
Symptoms:
docker-compose upfails- Containers exit immediately
Solutions:
# Check logs
docker-compose logs
# Remove old volumes and rebuild
docker-compose down -v
docker-compose up --build
# Check port conflicts
netstat -an | grep 8080Symptoms:
Connection refusederrorUnable to acquire JDBC Connection
Solutions:
# Verify PostgreSQL is running
docker ps | grep postgres
# Check database credentials in .env
cat .env | grep POSTGRES
# Test connection
docker exec -it foodsec-postgres psql -U foodsec_user -d foodsecuritynet
# Reset database
docker-compose down
docker volume rm foodsecuritynet_postgres_data
docker-compose up -d postgresSymptoms:
401 UnauthorizederrorsToken expiredmessage
Solutions:
# Refresh token
curl -X POST http://localhost:8081/api/auth/refresh \
-H "Content-Type: application/json" \
-d '{"refreshToken": "YOUR_REFRESH_TOKEN"}'
# Increase token expiration (development only)
# Edit backend/auth-service/src/main/resources/application.yml
jwt:
expiration: 86400000 # 24 hours in millisecondsSymptoms:
Invalid CSV formaterror- Data not appearing after upload
Solutions:
# Verify CSV format
# Required headers: crop,yield,region,year
# Example valid CSV:
crop,yield,region,year
maize,2.5,Kenya,2023
wheat,3.2,Ethiopia,2023
# Check file size (max 10MB)
ls -lh your_file.csv
# Validate with API
curl -X POST http://localhost:8082/api/data/validate \
-F "file=@your_file.csv"Symptoms:
- Blank screen where visualization should appear
- WebGL errors in console
Solutions:
// Check WebGL support
const canvas = document.createElement('canvas');
const gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
console.log('WebGL supported:', !!gl);
// Enable hardware acceleration (Chrome)
// chrome://settings/system
// Toggle "Use hardware acceleration when available"
// Clear browser cache
// Ctrl+Shift+Delete (Windows/Linux)
// Cmd+Shift+Delete (Mac)Symptoms:
- QR code not displaying
- TOTP codes not accepted
Solutions:
# Verify time synchronization
date # Should match current time
# Regenerate MFA secret
curl -X POST http://localhost:8081/api/mfa/reset \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
# Use backup codes
curl -X POST http://localhost:8081/api/mfa/verify-backup \
-H "Content-Type: application/json" \
-d '{"backupCode": "ABC123DEF456"}'Q: How do I reset my password?
A: Use the password reset endpoint:
curl -X POST http://localhost:8081/api/auth/reset-password \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com"}'Q: Can I use FoodSecurityNet offline?
A: No, FoodSecurityNet requires an internet connection for API calls, AI predictions, and LLM queries. However, cached visualizations can be viewed offline.
Q: How do I export data to QGIS?
A: Export your data as GeoJSON:
curl -X POST http://localhost:8082/api/export/geojson \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d "datasetId=123" \
-o data.geojsonThen import the .geojson file into QGIS: Layer → Add Layer → Add Vector Layer.
Q: What MBTI type should I choose?
A: Choose your authentic MBTI type based on personality assessments. If unsure, take a free test at 16personalities.com.
Q: How do I report a security vulnerability?
A: Email security@foodsecuritynet.org with details. Do not disclose publicly until patched.
Enable debug logging for troubleshooting:
# backend/*/src/main/resources/application.yml
logging:
level:
root: INFO
com.foodsec: DEBUG
org.springframework.security: DEBUG# Frontend (Vite)
VITE_DEBUG=true npm run devFoodSecurityNet provides QGIS-compatible data formats for geospatial analysis.
Export to QGIS:
- Export GeoJSON:
curl -X POST http://localhost:8082/api/export/geojson \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-o agricultural_data.geojson- Import to QGIS:
- Open QGIS
- Layer → Add Layer → Add Vector Layer
- Select
agricultural_data.geojson - Click "Add"
Supported Formats:
- GeoJSON (recommended)
- CSV with latitude/longitude columns
- Shapefile (coming soon)
QGIS Styling: FoodSecurityNet exports include style information compatible with QGIS:
{
"type": "FeatureCollection",
"features": [...],
"style": {
"fillColor": "#00FF00",
"strokeColor": "#000000"
}
}FoodSecurityNet can ingest data from FAO databases:
FAO Data Sources:
- FAOSTAT (crop production, trade, prices)
- AQUASTAT (water resources, irrigation)
- GIEWS (food security alerts)
Import FAO CSV:
# Download FAO data
wget http://www.fao.org/faostat/en/data/QC/download -O fao_crops.csv
# Upload to FoodSecurityNet
curl -X POST http://localhost:8082/api/data/upload \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-F "file=@fao_crops.csv" \
-F "dataType=AGRICULTURAL" \
-F "source=FAO"FAO API Integration:
# Configure FAO API key in .env
FAO_API_KEY=your-fao-api-key
# Sync data automatically
curl -X POST http://localhost:8082/api/integrations/fao/sync \
-H "Authorization: Bearer YOUR_JWT_TOKEN"Standard CSV Format:
crop,yield,region,year,latitude,longitude
maize,2.5,Kenya,2023,-1.2921,36.8219
wheat,3.2,Ethiopia,2023,9.1450,40.4897Standard JSON Format:
{
"data": [
{
"crop": "maize",
"yield": 2.5,
"region": "Kenya",
"year": 2023,
"location": {
"latitude": -1.2921,
"longitude": 36.8219
}
}
],
"metadata": {
"source": "FAO",
"timestamp": "2024-01-15T10:30:00Z"
}
}| Tool | Format | Import | Export |
|---|---|---|---|
| QGIS | GeoJSON, CSV | Yes | Yes |
| FAO Databases | CSV, JSON | Yes | No |
| NOAA Climate Data | JSON, NetCDF | Yes | No |
| USDA AgData | CSV, JSON | Yes | No |
| Excel | CSV | Yes | Yes |
| Python/R | CSV, JSON | Yes | Yes |
| Power BI | CSV | Yes | Yes |
| Tableau | CSV | Yes | Yes |
| Item | Estimated Cost | Notes |
|---|---|---|
| Claude Pro Subscription | $20/month/developer | For AI-assisted development |
| Claude Max (Team) | $100/month | Higher limits for team collaboration |
| Developer Time | $50,000 - $150,000 | 3-6 months, 2-4 developers |
| Design/UX | $10,000 - $30,000 | UI/UX design and user testing |
| Testing/QA | $15,000 - $40,000 | End-to-end testing, security audits |
| Total Development | $75,000 - $220,000 |
| Service | Provider | Configuration | Cost |
|---|---|---|---|
| Kubernetes Cluster | GKE/EKS/AKS | 3 nodes, n1-standard-2 | $150 |
| Database | Cloud SQL/RDS | db.t3.medium, 100GB | $100 |
| Redis Cache | Memorystore/ElastiCache | 4GB memory | $50 |
| Storage | S3/GCS/Blob | 500GB + data transfer | $30 |
| Load Balancer | Cloud LB | Standard tier | $20 |
| SSL Certificates | Let's Encrypt | Free | $0 |
| Monitoring | Cloud Monitoring | Standard metrics | $50 |
| Backups | Automated backups | Daily snapshots | $30 |
| Total Monthly | ~$430 |
| Service | Provider | Configuration | Cost |
|---|---|---|---|
| Kubernetes Cluster | GKE/EKS/AKS | 10 nodes, n1-standard-4 | $800 |
| Database | Cloud SQL/RDS | db.m5.xlarge, 500GB | $500 |
| Redis Cache | Memorystore/ElastiCache | 16GB memory | $200 |
| Storage | S3/GCS/Blob | 5TB + data transfer | $200 |
| Load Balancer | Cloud LB | Premium tier | $50 |
| CDN | CloudFront/Cloud CDN | 2TB data transfer | $100 |
| Monitoring | Prometheus + Grafana Cloud | Advanced metrics | $150 |
| Backups | Automated backups | Hourly snapshots | $100 |
| Total Monthly | ~$2,100 |
| Service | Provider | Configuration | Cost |
|---|---|---|---|
| Kubernetes Cluster | GKE/EKS/AKS | 50 nodes, n1-standard-8 | $5,000 |
| Database | Cloud SQL/RDS | db.m5.4xlarge, 2TB HA | $2,500 |
| Redis Cache | Memorystore/ElastiCache | 64GB memory, HA | $800 |
| Storage | S3/GCS/Blob | 50TB + data transfer | $1,500 |
| Load Balancer | Cloud LB | Premium tier, HA | $200 |
| CDN | CloudFront/Cloud CDN | 20TB data transfer | $800 |
| AI/ML GPU | Cloud GPU | 4x NVIDIA T4 | $1,200 |
| Monitoring | Full observability stack | Prometheus, Grafana, Loki | $500 |
| Backups | Automated backups | Continuous backup | $300 |
| Security | WAF, DDoS protection | Enterprise tier | $500 |
| Support | Cloud provider support | Business/Enterprise | $1,000 |
| Total Monthly | ~$14,300 |
| Data Source | Cost | Frequency |
|---|---|---|
| FAO Data | Free | Public datasets |
| NOAA Climate Data | Free | Public datasets |
| USDA AgData | Free | Public datasets |
| Commercial Satellite Imagery | $10,000 - $100,000/year | Depends on resolution/coverage |
| Soil Testing Labs | $50 - $200/sample | One-time per region |
| Weather API | $0 - $1,000/month | Depends on calls |
| Market Price Data | $500 - $5,000/month | Commercial providers |
| Total Annual | $10,000 - $500,000 | Highly variable |
| Item | Cost | Frequency |
|---|---|---|
| GDPR Compliance Audit | $10,000 - $50,000 | Annually |
| Security Penetration Testing | $5,000 - $20,000 | Quarterly |
| OWASP ZAP Scans | Free | Automated CI/CD |
| Legal Review | $5,000 - $15,000 | One-time |
| Insurance (Cyber) | $2,000 - $10,000 | Annually |
| Total Annual | $22,000 - $95,000 |
| Deployment Size | Year 1 | Year 2-3 (Annual) | Total (3 Years) |
|---|---|---|---|
| Small | $80,000 + $5,160 | $5,160 | $90,320 |
| Medium | $100,000 + $25,200 | $25,200 | $150,600 |
| Large | $150,000 + $171,600 | $171,600 | $493,200 |
Note: Year 1 includes development costs
FoodSecurityNet directly tackles one of humanity's most pressing challenges:
The Problem:
- 700 million people face hunger annually (FAO, 2023)
- 2.3 billion people experience moderate or severe food insecurity
- Climate change threatens crop yields by up to 30% by 2050
- Smallholder farmers (80% of food producers) lack access to data-driven tools
Our Solution:
- Optimize Crop Yields: AI-driven recommendations can increase yields by 15-30%
- Reduce Food Waste: Better planning and distribution cut waste by 20%
- Climate Adaptation: Predictive models help farmers adapt to changing conditions
- Market Access: Data on prices and demand improves farmer incomes by 10-25%
- Policy Impact: Evidence-based insights enable effective government interventions
- Increased Income: Optimized farming strategies boost profits
- Reduced Risk: Weather predictions and crop insurance recommendations
- Knowledge Sharing: Learn from successful practices in similar regions
- Market Power: Access to price data prevents exploitation
- Evidence-Based Decisions: Data-driven policy interventions
- Resource Allocation: Target aid where it's most needed
- Impact Measurement: Track outcomes of food security programs
- Early Warning: Identify food crises before they escalate
- Coordination: Real-time collaboration across organizations
- Efficiency: Optimize resource distribution and reduce duplication
- Impact Reporting: Demonstrate outcomes to donors
- Scalability: Replicate successful interventions globally
- Data Access: Aggregated datasets for agricultural research
- Trend Analysis: Identify long-term patterns and correlations
- Model Development: Train better AI models with diverse data
- Publication: Share findings to advance the field
Current Deployment:
- Pilot programs in Kenya, Ethiopia, India (2024)
- 5,000+ farmers using the platform
- 50+ NGO partnerships
Scaling Plan:
- Phase 1 (2024-2025): Sub-Saharan Africa and South Asia (100,000 users)
- Phase 2 (2026-2027): Latin America, Southeast Asia (500,000 users)
- Phase 3 (2028-2030): Global deployment (5 million users)
Projected Impact by 2030:
- 10 million farmers empowered with data-driven tools
- 15-20% increase in crop yields in target regions
- $2-3 billion in additional farmer income annually
- 30 million people lifted out of food insecurity
FoodSecurityNet promotes sustainable farming practices:
- Water Conservation: Optimize irrigation to reduce water use by 20-30%
- Soil Health: Recommendations for crop rotation and organic fertilizers
- Carbon Sequestration: Encourage practices that capture atmospheric CO2
- Biodiversity: Promote intercropping and habitat preservation
- Pesticide Reduction: Integrated pest management reduces chemical use
By making FoodSecurityNet open-source:
- Global Accessibility: Free for NGOs, governments, and farmers
- Community Innovation: Developers worldwide can contribute improvements
- Transparency: Auditable algorithms build trust with users
- Localization: Communities can adapt the platform to their needs
- No Vendor Lock-In: Users retain control and ownership of their data
FoodSecurityNet directly supports:
- SDG 1: No Poverty (increase farmer incomes)
- SDG 2: Zero Hunger (improve food production and distribution)
- SDG 8: Decent Work and Economic Growth (empower farmers)
- SDG 9: Industry, Innovation, and Infrastructure (AI/ML for agriculture)
- SDG 13: Climate Action (climate-adaptive farming)
- SDG 17: Partnerships for the Goals (collaboration across stakeholders)
FoodSecurityNet is built on data from:
- Food and Agriculture Organization (FAO): Crop yield, soil quality, agricultural statistics
- National Oceanic and Atmospheric Administration (NOAA): Climate data, weather patterns
- United States Department of Agriculture (USDA): Agricultural research, market data
- NASA Earth Observations: Satellite imagery, vegetation indices
- World Bank: Socio-economic indicators, poverty data
- Local Agricultural Surveys: Ground-truth data from farmer cooperatives
We gratefully acknowledge:
- React Team: Frontend framework
- Three.js Contributors: 3D visualization library
- Spring Team: Backend microservices framework
- PyTorch Contributors: Machine learning framework
- PostgreSQL Global Development Group: Database system
- Redis Labs: In-memory data store
- Docker Inc.: Containerization platform
- Kubernetes Contributors: Container orchestration
- Hugging Face: LLM models and Transformers library
- OpenStreetMap Contributors: Geospatial data
This project was inspired by:
- FAO's "State of Food Security and Nutrition in the World" reports
- Research on climate-smart agriculture from CGIAR
- Open-source GIS tools like QGIS
- Precision agriculture research from leading universities
FoodSecurityNet is developed by a global community of:
- Software Engineers: Building robust, scalable systems
- Data Scientists: Developing AI/ML models
- Agricultural Experts: Ensuring practical applicability
- UX Designers: Creating accessible, personalized interfaces
- Community Managers: Supporting users and gathering feedback
Development supported by:
- Open-source grants from technology foundations
- Partnership with agricultural NGOs
- Cloud credits from major cloud providers
- Community donations and sponsorships
Copyright 2024 Sekacorn / FoodSecurityNet Contributors
FoodSecurityNet is dual-licensed to support both non-profit and commercial use:
-
Non-Profit License (FREE) - See LICENSE-NONPROFIT
- For NGOs, governments, educational institutions, individual farmers
- 100% FREE, no fees or royalties
- Based on MIT License for non-commercial use
-
Commercial License (4% Gross Revenue) - See LICENSE-COMMERCIAL
- For for-profit companies and businesses
- 4% revenue share on gross revenue derived from this software
- $10,000 minimum threshold (below that = FREE)
- 90-day free trial period
- Non-Profit License ensures free access for those fighting hunger
- Commercial License creates sustainable funding while keeping costs reasonable
- Revenue sharing aligns success of the project with success of commercial users
Contact: sekacorn@gmail.com for licensing questions.
Choose the license that matches your organization type. Full license texts and FAQ available in the repository.
FoodSecurityNet is an original work developed using open-source libraries and public datasets. This project:
- Does NOT include proprietary code from QGIS, FAO databases, or other commercial tools
- Uses only open-source libraries with compatible licenses (Apache, MIT, BSD)
- Provides compatibility with industry-standard formats (CSV, JSON, GeoJSON) for interoperability
- Respects data licenses from FAO, NOAA, USDA, and other sources
- Complies with attribution requirements for all third-party components
All dependencies are licensed under permissive open-source licenses:
| Component | License | Link |
|---|---|---|
| React | MIT | https://github.com/facebook/react/blob/main/LICENSE |
| Three.js | MIT | https://github.com/mrdoob/three.js/blob/dev/LICENSE |
| Spring Boot | Apache 2.0 | https://www.apache.org/licenses/LICENSE-2.0 |
| PyTorch | BSD 3-Clause | https://github.com/pytorch/pytorch/blob/master/LICENSE |
| PostgreSQL | PostgreSQL License | https://www.postgresql.org/about/licence/ |
| Redis | BSD 3-Clause | https://redis.io/docs/about/license/ |
Full dependency licenses available in THIRD_PARTY_LICENSES.md.
Report bugs and feature requests:
- GitHub Issues: https://github.com/sekacorn/FoodSecurityNet.git/issues
- Bug Template: Provide steps to reproduce, expected vs. actual behavior
- Feature Request Template: Describe use case and proposed solution
Join the community:
- GitHub Discussions: https://github.com/sekacorn/FoodSecurityNet.git/discussions
- Discord Server: https://discord.gg/foodsecuritynet
- Mailing List: community@foodsecuritynet.org
Primary Contact: Sekacorn
- Email: sekacorn@gmail.com
- General Inquiries: sekacorn@gmail.com (Subject: General Inquiry)
- Licensing Questions: sekacorn@gmail.com (Subject: License Inquiry)
- Security Issues: sekacorn@gmail.com (Subject: SECURITY - [Issue])
- Partnership Opportunities: sekacorn@gmail.com (Subject: Partnership)
- Commercial Licensing: sekacorn@gmail.com (Subject: Commercial License)
- User Guide: https://docs.foodsecuritynet.org/user-guide
- API Reference: https://api.foodsecuritynet.org/docs
- Developer Guide: https://docs.foodsecuritynet.org/developer-guide
- Video Tutorials: https://youtube.com/@foodsecuritynet
For enterprise deployments, custom integrations, and SLA-backed support:
- Enterprise Support: enterprise@foodsecuritynet.org
- Consulting Services: Available for deployment, training, and customization
- Training Programs: On-site and remote training for teams
Q1 2024:
- Mobile apps (iOS, Android)
- Offline mode with data sync
- Voice commands for LLM queries
- Expanded MBTI customization
Q2 2024:
- Satellite imagery integration (Sentinel-2, Landsat)
- Blockchain for supply chain traceability
- Multi-language support (Spanish, French, Swahili, Hindi)
- Advanced analytics dashboard
Q3 2024:
- Drone integration for aerial surveys
- IoT sensor data ingestion (soil moisture, temperature)
- Marketplace for farmers (buy/sell crops)
- Weather insurance recommendations
Q4 2024:
- AR/VR visualization for immersive 3D maps
- Social network features (farmer forums, knowledge sharing)
- Government API for policy integration
- Climate risk modeling
Together, we can build a world where everyone has access to safe, nutritious, and sufficient food.
Get Started | Join the Community | Contribute
Made with dedication by the FoodSecurityNet community