Skip to content
ambrosia2024Public

About

Ambrosia dashboard: climate-driven food-safety risk assessment for crops by region, built on Django, PostGIS and model outputs

Topics

Resources

Stars

0 stars

Watchers

2 watching

Forks

Latest commit

Β 

History

251 Commits

Folders and files

Repository files navigation

πŸš€ Ambrosia Dashboard

Django Python PostgreSQL PostGIS Docker


πŸ“‹ Table of Contents


πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                              Browser / Client                               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                β”‚ HTTP :80
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         Nginx reverse proxy                                 β”‚
β”‚  /static/ β†’ shared staticfiles volume                                       β”‚
β”‚  /       β†’ ambrosia_dashboard:8000                                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   Django / Gunicorn app (container :8000)                  β”‚
β”‚  Dashboard + view modes        Risk charts + chart pages                   β”‚
β”‚  Climate data API              Pathogen concentration API                  β”‚
β”‚  Vocabulary / NUTS / models    User auth + admin                           β”‚
β”‚  Ambra chart assistant         Health endpoint (/status)                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚               β”‚                  β”‚
        β”‚ SQL/PostGIS   β”‚ broker/result    β”‚ HTTPS
        β”‚               β”‚                  β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ PostgreSQL 16  β”‚ β”‚ Redis 7       β”‚ β”‚ External services                     β”‚
β”‚ + PostGIS      β”‚ β”‚ broker/result β”‚ β”‚ SCiO vocabulary / NUTS / models APIs  β”‚
β”‚ Climate data   β”‚ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ SCiO pathogen concentration API       β”‚
β”‚ Pathogen data  β”‚      β”‚            β”‚ LLM chat completions endpoint         β”‚
β”‚ Vocabularies   β”‚      β”‚            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ Users / admin  β”‚      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β”‚ Celery broker/result
        β”‚               β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ pgAdmin :5050  β”‚ β”‚ Celery worker + embedded beat                          β”‚
β”‚ DB management  β”‚ β”‚ Auto-resumes pending pathogen sync every 5 minutes     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Prerequisites

1. Clone the Repository

git clone https://github.com/ambrosia2024/dashboard.git
cd dashboard

2. Configure Environment

cp .env.sample .env

Edit .env with your configuration:

# Django
DJANGO_SECRET_KEY=your-secure-secret-key-here

# Database (PostgreSQL + PostGIS)
POSTGRES_DB=ambrosia
POSTGRES_USER=amb_admin
POSTGRES_PASSWORD=your-secure-db-password
POSTGRES_HOST=ambrosia_postgres
POSTGRES_PORT=5432

# pgAdmin (optional)
PGADMIN_DEFAULT_EMAIL=admin@yourdomain.com
PGADMIN_DEFAULT_PASSWORD=your-secure-password

# Feature Flags
EMAIL_VERIFICATION_ENABLED=false

# External APIs (optional)
SCIO_VOCAB_API_BASE=

# Ambra (Scaleway Serverless API)
SCW_SECRET_KEY=your-scaleway-iam-api-key

⚠️ Security Note: Generate a strong DJANGO_SECRET_KEY using:

python -c "import secrets; print(secrets.token_urlsafe(50))"

3. Launch the Application

docker compose up -d

This will:

  • 🐳 Pull and build required Docker images
  • πŸ—„οΈ Initialize PostgreSQL with PostGIS extensions
  • πŸ”§ Run Django migrations automatically
  • πŸ“¦ Collect static files
  • 🌐 Start Nginx reverse proxy

4. Access the Application

Service URL Description
Dashboard http://localhost/ Main web application
Admin Panel http://localhost/admin/ Django admin interface
pgAdmin http://localhost:5050/ Database management (optional)
Health Check http://localhost/status Service health endpoint

5. Create Admin User

docker compose exec ambrosia_dashboard python manage.py createsuperuser

βš™οΈ Configuration

Environment Variables

Variable Required Default Description
DJANGO_SECRET_KEY Yes - Django security key
POSTGRES_DB Yes ambrosia Database name
POSTGRES_USER Yes amb_admin Database user
POSTGRES_PASSWORD Yes - Database password
POSTGRES_HOST Yes ambrosia_postgres Database host
POSTGRES_PORT No 5432 Database port
EMAIL_VERIFICATION_ENABLED No false Enable email verification
SCIO_VOCAB_API_BASE No dev.api... Vocabulary API endpoint
SCW_SECRET_KEY For Ambra - Scaleway IAM API key
SCW_AI_BASE_URL No api.scaleway.ai/.../v1 Scaleway Serverless API base URL
SCW_AI_MODEL No qwen3.5-397b-a17b Model used by Ambra
SCW_AI_REASONING_EFFORT No none none skips the model's hidden reasoning pass; raise to low/medium/high for deeper (slower) answers
SCW_AI_MAX_TOKENS No 1024 Answer length cap
ALLOWED_HOSTS No localhost Comma-separated allowed hosts

Dashboard View Modes

The application supports customizable dashboard layouts:

  1. Access Django Admin: http://localhost/admin/
  2. Navigate to Lumenix β†’ Dashboard view modes
  3. Create modes like "Farmer View", "Policy Advisor View", "Distributor View"
  4. Assign charts to each mode via Dashboard view charts

πŸ› οΈ Development

Local Development (Without Docker)

Use the helper script to create or synchronize the local virtual environment from requirements.txt:

# Recreate .venv from scratch
scripts/sync_env.sh recreate

# Or synchronize an existing .venv exactly to requirements.txt
scripts/sync_env.sh sync
# Create virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Setup local PostgreSQL with PostGIS
# Then configure DATABASES in config/settings.py

# Run migrations
python manage.py migrate

# Collect static files
python manage.py collectstatic

# Start development server
python manage.py runserver

Running Tests

docker compose exec ambrosia_dashboard python manage.py test

Database Migrations

# Create migration
docker compose exec ambrosia_dashboard python manage.py makemigrations

# Apply migration
docker compose exec ambrosia_dashboard python manage.py migrate

Vocabulary Synchronization

To sync plant and pathogen vocabularies from SCiO API:

docker compose exec ambrosia_dashboard python manage.py sync_vocabulary plants
docker compose exec ambrosia_dashboard python manage.py sync_vocabulary pathogens

πŸ› Troubleshooting

Common Issues

Issue: Database connection failed

# Check database health
docker compose ps
docker compose logs ambrosia_postgres

Issue: Static files not loading

# Rebuild and collect static
docker compose down
docker compose up -d --build

Issue: Permission denied on volumes

# Fix volume permissions
docker compose down -v
docker volume prune  # ⚠️ Warning: Deletes all unused volumes
docker compose up -d

Logs

# View all logs
docker compose logs -f

# View specific service
docker compose logs -f ambrosia_dashboard

About

Ambrosia dashboard: climate-driven food-safety risk assessment for crops by region, built on Django, PostGIS and model outputs

Topics

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages