07. Admin Portal¶
Repository: aclimate_v3_admin Stack: HTML (49.4%), Python (41.9%), JavaScript (7.2%), Flask
Overview¶
The admin portal is a Flask-based web application designed for system administrators and researchers to configure and manage the AClimate platform. While the frontend focuses on end users consuming climate data, the admin portal is where the system is set up, configured, and maintained.
Administrators use this portal to manage geographic entities (countries, departments, municipalities), configure crop and soil parameters, import historical climate data, and control user access and permissions across the system.
Technology Stack¶
The portal is built with Flask as the web framework, using Jinja2 templates for server-side rendering. Forms are built with WTForms for validation and CSRF protection. Authentication is handled through Keycloak OAuth integration, and the portal communicates with the WebAPI through a dedicated API client. The interface supports both English and Spanish translations using Flask-Babel, with translation management scripts included in the repository.
Application Structure¶
The application follows the Flask MVC pattern with routes, forms, services, and templates organized by entity:
- Routes: 27 route files, one per entity, handling CRUD operations
- Forms: 24 WTForm definitions with field validation
- Services: 7 service modules for business logic (auth, users, roles, Keycloak API, OAuth, location import, groups)
- Templates: Jinja2 template directories for each entity, each containing list, detail, create, and edit views
- Translations: Babel translation catalogs for English and Spanish
- Decorators: Authentication and permission control decorators
Access Control¶
The portal implements a two-layer access control system. First, authentication is handled through Keycloak OAuth, where users log in using their Keycloak credentials. Second, a permission decorator system controls access to specific routes based on user roles. This ensures that only authorized administrators can modify system configurations.
Internationalization¶
The admin portal supports English and Spanish through Flask-Babel translations. Translation files are managed through dedicated scripts included in the repository:
update_translations_dev.ps1andupdate_translations.shfor extracting and updating translation catalogssrc/translations/en_US/andsrc/translations/es_CO/containing the actual translation files
Sections¶
- Geographic Configuration — Countries, administrative divisions, and weather station management
- Production Configuration — Crops, cultivars, soils, seasons, and setup parameters
- Climate Configuration — Climate measures, indicators, categories, and features
- Phenology and Stress — Phenological stages and stress factor definitions
- Data Sources and Import — External data sources and location data import
- User and Role Management — User accounts, roles, and Keycloak integration