How aws-samples/sample-geospatial-foundation-models-on-aws works
Project Type and Purpose
• This is a full‐stack, cloud‐native web application demonstrating Geospatial Foundation Models (GeoFMs) for ecosystem monitoring.
• It combines a Solara‐based frontend, serverless backend Lambdas (API surface for tile serving, similarity search, and change detection), asynchronous SageMaker pipelines (for embedding generation and model fine‐tuning), and several AWS managed services (ElastiCache, OpenSearch, S3, Cognito, Fargate, CloudFront).
File Structure Analysis
• Top‐level
• sagemaker_pipelines/ – Jupyter notebooks and Python scripts to build Docker images, instantiate SageMaker pipelines for embedding generation (prerequisites & embedding_generation).
• ui/geofm-demo-stack/ – AWS CDK stack (TypeScript) with subfolders:
◦ bin/ and lib/ – CDK entrypoints and stack definitions (auth, backend, frontend stacks).
◦ lambdas/ – three Lambda functions: API‐auth, tile server (TiTiler), Cognito signup, similarity search, change detection.
◦ solara-fe/ – Python Solara app, Dockerfile, UI pages for home, similarity search, change detection.
◦ ui-assets/ – index.html, CSS.
◦ CDK config files (cdk.json, tsconfig.json).
• Presence of Dockerfiles under prerequisites and solara-fe indicates containerized compute for SageMaker jobs and Fargate.
• CDK test folder shows unit tests for stack.
README Insights
• Three-tier architecture: Frontend (Solara on Fargate via CloudFront + Cognito), AI/ML & Analytics Tier (SageMaker pipelines + Lambdas), Data Tier (S3 for imagery, ElastiCache for tile caching, OpenSearch & LanceDB for vector search).
• Two asynchronous SageMaker pipelines: embedding generation (preprocessing + model inference + load to LanceDB) and fine‐tuning (not in file tree but implied).
Main Components
a. Frontend Tier
• CloudFront CDN → Fargate container running Solara FE
• Amazon Cognito User Pool for authentication
b. Backend / AI & Analytics Tier
• API Gateway or direct Lambda endpoints:
• Tile server Lambda (TiTiler) → ElastiCache (tile cache) → S3 Sentinel‐2 imagery
• Search Lambda → OpenSearch Service & LanceDB vector DB
• Change‐detection Lambda → OpenSearch time‐series queries
• SageMaker Pipelines:
• Prerequisite Docker builds (Clay GPU image, geo‐processing image) → ECR
• Embedding Generation Pipeline (S3 data fetch, preprocessing, inference with GeoFM from HuggingFace, output to LanceDB & S3 config.json)
• (Optionally) Fine‐tuning Pipeline
c. Data Tier
• S3 buckets (raw imagery, pipeline outputs, config files)
• Amazon ElastiCache Redis (tile caching)
• Amazon OpenSearch Service (vector index & time‐series data)
• LanceDB (vector DB, potentially on SageMaker or VPC)
Relationships and Data Flow
• User → CloudFront → Solara FE (via HTTPS, authenticated by Cognito)
• Solara FE → API endpoints (tile server, search, change‐detect)
• Tile server Lambda: reads from S3 / Redis cache, returns map tiles
• Search Lambda: queries OpenSearch & LanceDB, returns nearest embeddings
• Change‐detect Lambda: fetches historical embeddings from OpenSearch, computes anomalies
• SageMaker Pipeline jobs: triggered manually or via SDK, read from S3, run on managed instances with custom Docker images in ECR, write embeddings to LanceDB & metadata to S3
Architectural Patterns & Design Principles
• Three‐tier separation (frontend, compute, data)
• Serverless microservices (AWS Lambda, API Gateway)
• Asynchronous batch processing (SageMaker Pipelines)
• Infrastructure‐as‐Code (CDK) for reproducibility
• Containerization for portability (Docker images for SageMaker & Fargate)
• Security & auth via Cognito