AI-powered satellite crop monitoring for agriculture and forestry
AtlasField is a SaaS platform that leverages satellite imagery (Sentinel-1 & Sentinel-2) and AI to help farmers and foresters monitor their fields, predict yields, and receive actionable insights.
- πΊοΈ Interactive Map - Draw and manage field boundaries with MapLibre GL
- π Satellite Analysis - NDVI, RVI, and multi-sensor fusion from Sentinel Hub
- π€ AI Assistant - Get personalized agricultural advice powered by Google Gemini
- π Smart Alerts - Automated notifications for crop health issues
- π Yield Predictions - Machine learning-based harvest forecasting
- π± Biomass Estimation - Carbon sequestration monitoring
AtlasField/
βββ backend/ # FastAPI Backend
β βββ app/
β β βββ routers/ # API endpoints
β β βββ services/ # Business logic
β β βββ config.py # Settings
β β βββ database.py # PostgreSQL connection
β β βββ models.py # SQLAlchemy models
β β βββ schemas.py # Pydantic schemas
β βββ .env # Backend environment
β βββ Dockerfile
β βββ requirements.txt
βββ frontend/ # Next.js Frontend
β βββ app/ # App router pages
β βββ components/ # React components
β βββ lib/ # Utilities & API client
β βββ .env.local # Frontend environment
β βββ Dockerfile # Production
β βββ Dockerfile.dev # Development
βββ docker-compose.yml # Production setup
βββ docker-compose.dev.yml # Development setup
- Docker & Docker Compose
- Or for local development:
- Node.js 20+
- Python 3.11+
- PostgreSQL 15+
1. Clone the repository
git clone https://github.com/yourusername/atlasfield.git
cd atlasfield2. Configure environment variables
Copy the example files and edit them:
# Backend
cp backend/.env.example backend/.env
# Frontend
cp frontend/.env.example frontend/.env.local3. Start with Docker Compose
For development (with hot reload):
docker-compose -f docker-compose.dev.yml up --buildFor production:
docker-compose up --build4. Access the application
- π Frontend: http://localhost:3000
- π Backend API: http://localhost:8000
- π API Docs: http://localhost:8000/docs
1. Start PostgreSQL
You can use Docker just for the database:
docker run -d \
--name atlasfield-db \
-e POSTGRES_USER=atlasfield \
-e POSTGRES_PASSWORD=atlasfield \
-e POSTGRES_DB=atlasfield \
-p 5432:5432 \
postgres:15-alpine2. Setup Backend
cd backend
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # Linux/Mac
# or: .venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Configure environment
cp .env.example .env
# Edit .env and set DATABASE_URL to localhost:
# DATABASE_URL=postgresql+asyncpg://atlasfield:atlasfield@localhost:5432/atlasfield
# Start the server
uvicorn app.main:app --reload --port 80003. Setup Frontend
cd frontend
# Install dependencies
npm install
# Configure environment
cp .env.example .env.local
# Edit .env.local if needed
# Start development server
npm run dev| Variable | Description | Required |
|---|---|---|
DATABASE_URL |
PostgreSQL connection string | β |
SECRET_KEY |
JWT signing key (min 32 chars) | β |
SENTINEL_HUB_CLIENT_ID |
Copernicus Data Space client ID | β |
SENTINEL_HUB_CLIENT_SECRET |
Copernicus Data Space secret | β |
GEMINI_API_KEY |
Google Gemini API key | β |
CORS_ORIGINS |
Allowed origins (comma-separated) | β |
| Variable | Description | Required |
|---|---|---|
NEXT_PUBLIC_API_URL |
Backend API URL | β |
NEXTAUTH_URL |
Frontend URL for NextAuth | β |
NEXTAUTH_SECRET |
NextAuth encryption key | β |
NEXT_PUBLIC_MAPTILER_KEY |
MapTiler API key for maps | β |
- Sentinel Hub: Register at Copernicus Data Space
- Gemini: Get your key at Google AI Studio
- MapTiler: Register at MapTiler (100k free tiles/month)
AtlasField uses Alembic for database migrations. Migrations run automatically on application startup, but you can also manage them manually.
When the backend starts, it automatically runs any pending migrations. This ensures the database schema is always up-to-date with the code.
# Run inside the backend container
docker compose exec backend bash
# Check current migration status
alembic current
# Run all pending migrations
alembic upgrade head
# Rollback one migration
alembic downgrade -1
# View migration history
alembic historyWhen you modify the models in app/models.py, create a new migration:
# Auto-generate migration from model changes
docker compose exec backend alembic revision --autogenerate -m "description_of_change"
# Or create an empty migration for custom SQL
docker compose exec backend alembic revision -m "description_of_change"Then edit the generated file in backend/alembic/versions/ if needed.
backend/
βββ alembic.ini # Alembic configuration
βββ alembic/
βββ env.py # Migration environment setup
βββ script.py.mako # Template for new migrations
βββ versions/ # Migration scripts
βββ 001_initial.py # Initial schema
βββ 002_add_complete_enum.py # Example migration
For a completely fresh database, migrations will create all tables automatically:
# Start only the database
docker compose up -d db
# Run migrations
docker compose exec backend alembic upgrade headOnce the backend is running, visit:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/v1/auth/register |
Create account |
POST |
/api/v1/auth/login |
Get JWT token |
GET |
/api/v1/fields |
List user's fields |
POST |
/api/v1/fields |
Create a field |
POST |
/api/v1/analysis/{id} |
Run satellite analysis |
POST |
/api/v1/chat |
Chat with AI assistant |
GET |
/api/v1/alerts |
Get user alerts |
Backend:
cd backend
pytestFrontend:
cd frontend
npm test# Build and start in detached mode
docker-compose up -d --build
# View logs
docker-compose logs -f
# Stop
docker-compose downMake sure to set secure values:
- Generate
SECRET_KEY:openssl rand -base64 32 - Generate
NEXTAUTH_SECRET:openssl rand -base64 32 - Use a managed PostgreSQL database
- Set proper
CORS_ORIGINS
This project was created for the ESA ActInSpace Challenge.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request