Architecture
Principles
AClimate v3 follows these architectural principles:
- Modularity: Each capability is a separate repository with clear boundaries
- Separation of Concerns: Frontend, API, ORM, and ETLs have distinct responsibilities
- Data Source of Truth: The ORM package (
aclimate_v3_orm) is the authoritative definition of the data model - API-First: All data access is mediated through the WebAPI layer
- Pipeline Isolation: ETL processes operate independently and communicate via the database
Logical Architecture (C4 Model)
Level 1: System Context
The AClimate v3 system sits at the center, interacting with:
- Users (via Frontend and Admin portals)
- Data Providers (climate data sources, spatial data feeds)
- External Systems (downstream consumers via API)
Level 2: Containers
┌─────────────────────────────────────────────────────────┐
│ AClimate v3 Platform │
├─────────────────┬──────────────────┬────────────────────┤
│ Frontend │ Admin Portal │ Documentation │
│ (TypeScript/ │ (HTML/Python/ │ (Docusaurus/MkDocs)│
│ Next.js) │ Flask) │ │
├────────┬────────┴─────────┬────────┴─────────┬──────────┤
│ WebAPI (Python/FastAPI) │ ORM Package │ │
│ │ (SQLAlchemy) │ │
├───────────────────────────┴──────────────────┤ │
│ PostgreSQL DB │ │
├─────────────────────┬────────────────────────┘ │
│ Historical Spatial │ Historical Location │ │
│ ETL (Python) │ ETL (Python) │ │
├─────────────────────┴────────────────────────┤ │
│ Cut Spatial Data (Python) │ │
└──────────────────────────────────────────────┘ │
Repositories Responsibility Map
| Repository | Layer | Tech Stack | Responsibility |
|---|---|---|---|
aclimate_v3_frontend | Presentation | TypeScript, Next.js | End-user web application |
aclimate_v3_admin | Presentation | HTML, Flask, JS | Administrative configuration |
aclimate_v3_webapi | Service/API | Python, FastAPI | RESTful API, business logic |
aclimate_v3_orm | Data/Model | Python, SQLAlchemy | Data model, migrations, schemas |
aclimate_v3_historical_spatial_etl | Data/ETL | Python | Spatial historical data processing |
aclimate_v3_historical_location_etl | Data/ETL | Python | Location-based historical processing |
aclimate_v3_cut_spatial_data | Data/ETL | Python | Spatial data segmentation/preprocessing |
Component Interaction Flow
Data Sources
│
▼
┌──────────────────────────────────────────────────────────┐
│ ETL Pipeline Layer │
│ cut_spatial_data → historical_spatial_etl │
│ → historical_location_etl │
│ │
│ Output: Normalized data written to PostgreSQL │
└──────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────┐
│ ORM Layer │
│ Defines: entities, relationships, schemas, validations │
│ Tools: SQLAlchemy models, Alembic migrations │
│ Consumed by: WebAPI, ETLs, Admin │
└──────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────┐
│ WebAPI Layer │
│ Exposes: REST endpoints per domain │
│ Auth: JWT-based authentication │
│ Consumed by: Frontend, Admin, external consumers │
└──────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────┐
│ Presentation Layer │
│ Frontend: End-user features (forecasts, maps, reports) │
│ Admin: Configuration UI (catalogs, parameters, users) │
└──────────────────────────────────────────────────────────┘
Deployment Architecture
All components are containerized (Docker) and deployed via CI/CD pipelines:
- Jenkins: Build and deployment orchestration
- Docker: Container runtime for all services
- PostgreSQL: Primary data store (relational)
- Environment separation: dev, qa/stg, prod
Security & Access Control
- API Authentication: JWT tokens with role-based access
- Service-to-service: Internal network communication
- Database: Connection pooling with credential management
- Secrets: Environment variables managed per environment
Architecture Decision Records (ADR)
Key architectural decisions are documented in each repository's docs/ directory. Notable decisions include:
- Migration from MongoDB (v2) to PostgreSQL + SQLAlchemy (v3)
- Separation of ORM as an independent, versioned package
- API-first design pattern for all data access
- Containerized deployment with Docker