# ismapereira/green-air architecture

> Architecture diagram of the GitHub repository ismapereira/green-air, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ismapereira/green-air
- Repository: https://github.com/ismapereira/green-air

## Overview

Green Air is a PHP/MySQL collaborative urban-tree mapping application. The main workflow is user registration/authentication, tree submission with GPS and photo, contribution points and badges, and discovery through the map and personal dashboard. Separate features include rankings, public statistics, collaborative suggestions, weather/air-quality data, notifications, and admin management. Edges reflect only README statements, route declarations, or shown calls; unsampled capabilities are represented at their supported controller or directory paths.

Main entry points: [`routes/web.php`](https://github.com/ismapereira/green-air/blob/main/routes/web.php) (Route table), [`app/controllers/TreeController.php`](https://github.com/ismapereira/green-air/blob/main/app/controllers/TreeController.php) (Tree submissions and CRUD), [`app/controllers/DashboardController.php`](https://github.com/ismapereira/green-air/blob/main/app/controllers/DashboardController.php) (User dashboard and APIs), [`app/models/Tree.php`](https://github.com/ismapereira/green-air/blob/main/app/models/Tree.php) (Tree records and map queries)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Web entry"]
  node_front["HTTP front controller<br/>[index.php]"]
  node_routes["Route table<br/>[web.php]"]
  node_auth["Accounts and authentication<br/>[AuthController.php]"]
  node_base["Controller services<br/>[Controller.php]"]
end

subgraph group_trees["Tree mapping"]
  node_treeflow["Tree submissions and CRUD<br/>[TreeController.php]"]
  node_treedata["Tree records and map queries<br/>[Tree.php]"]
  node_catalog["Species and preservation status<br/>[TreeSpecies.php]"]
  node_uploads["Image upload handling<br/>[UploadHelper.php]"]
  node_treesview["Map and tree views<br/>[index.php]"]
end

subgraph group_engagement["Community engagement"]
  node_contributions["Contribution history"]
  node_suggestions["Community suggestions"]
  node_suggestiondata["Suggestion records"]
  node_badges["Achievement checks<br/>[BadgeChecker.php]"]
  node_badge_records["Badge records<br/>[Badge.php]"]
  node_notifications["User notifications<br/>[Notification.php]"]
end

subgraph group_insights["Dashboards and insights"]
  node_dashboard["User dashboard and APIs"]
  node_users["User points and rankings<br/>[User.php]"]
  node_cache["Weather response cache<br/>[CacheHelper.php]"]
  node_ranking["Ranking pages"]
  node_publicstats["Public statistics<br/>[HomeController.php]"]
end

subgraph group_operations["Administration"]
  node_admin["Admin management"]
end

node_visitor(("Visitor or user"))
node_weather["OpenWeather"]
node_database[("MySQL database<br/>[database.php]")]
node_modelbase["PDO model layer<br/>[Model.php]"]

node_visitor -->|"sends requests"| node_front
node_front -->|"dispatches via"| node_routes
node_routes -->|"routes auth requests"| node_auth
node_routes -->|"routes tree requests"| node_treeflow
node_routes -->|"routes dashboard APIs"| node_dashboard
node_routes -->|"routes suggestions"| node_suggestions
node_routes -->|"routes ranking"| node_ranking
node_routes -->|"routes statistics"| node_publicstats
node_routes -->|"routes admin requests"| node_admin
node_treeflow -->|"creates and updates"| node_treedata
node_treeflow -->|"uses catalog"| node_catalog
node_treeflow -->|"validates uploads"| node_uploads
node_treeflow -->|"awards points"| node_users
node_treeflow -->|"logs actions"| node_contributions
node_treeflow -->|"checks achievements"| node_badges
node_treesview -->|"uses tree data"| node_treedata
node_suggestions -->|"creates suggestions"| node_suggestiondata
node_suggestions -->|"checks achievements"| node_badges
node_badges -->|"checks and unlocks"| node_badge_records
node_badges -->|"notifies unlocks"| node_notifications
node_auth -->|"registers users"| node_users
node_auth -->|"creates welcome notice"| node_notifications
node_dashboard -->|"loads user trees"| node_treedata
node_dashboard -->|"loads contributors"| node_users
node_dashboard -->|"reads and writes"| node_cache
node_dashboard -->|"requests weather data"| node_weather
node_dashboard -->|"loads and marks read"| node_notifications
node_ranking -.->|"loads ranking data"| node_users
node_publicstats -.->|"uses tree statistics"| node_treedata
node_admin -.->|"manages records"| node_database
node_base -->|"counts unread"| node_notifications
node_treeflow -.->|"inherits services"| node_base
node_modelbase -->|"queries through PDO"| node_database
node_treedata -->|"uses PDO helpers"| node_modelbase
node_users -.->|"uses PDO helpers"| node_modelbase
node_notifications -->|"uses PDO helpers"| node_modelbase

click node_front "https://github.com/ismapereira/green-air/blob/main/public/index.php"
click node_routes "https://github.com/ismapereira/green-air/blob/main/routes/web.php"
click node_auth "https://github.com/ismapereira/green-air/blob/main/app/controllers/AuthController.php"
click node_base "https://github.com/ismapereira/green-air/blob/main/app/controllers/Controller.php"
click node_treeflow "https://github.com/ismapereira/green-air/blob/main/app/controllers/TreeController.php"
click node_treedata "https://github.com/ismapereira/green-air/blob/main/app/models/Tree.php"
click node_catalog "https://github.com/ismapereira/green-air/blob/main/app/models/TreeSpecies.php"
click node_uploads "https://github.com/ismapereira/green-air/blob/main/app/helpers/UploadHelper.php"
click node_treesview "https://github.com/ismapereira/green-air/blob/main/app/views/map/index.php"
click node_contributions "https://github.com/ismapereira/green-air/blob/main/app/models/ContributionLog.php"
click node_suggestions "https://github.com/ismapereira/green-air/blob/main/app/controllers/SuggestionController.php"
click node_suggestiondata "https://github.com/ismapereira/green-air/blob/main/app/models/CommunitySuggestion.php"
click node_badges "https://github.com/ismapereira/green-air/blob/main/app/helpers/BadgeChecker.php"
click node_badge_records "https://github.com/ismapereira/green-air/blob/main/app/models/Badge.php"
click node_notifications "https://github.com/ismapereira/green-air/blob/main/app/models/Notification.php"
click node_dashboard "https://github.com/ismapereira/green-air/blob/main/app/controllers/DashboardController.php"
click node_users "https://github.com/ismapereira/green-air/blob/main/app/models/User.php"
click node_cache "https://github.com/ismapereira/green-air/blob/main/app/helpers/CacheHelper.php"
click node_ranking "https://github.com/ismapereira/green-air/blob/main/app/controllers/RankingController.php"
click node_publicstats "https://github.com/ismapereira/green-air/blob/main/app/controllers/HomeController.php"
click node_admin "https://github.com/ismapereira/green-air/tree/main/app/controllers"
click node_database "https://github.com/ismapereira/green-air/blob/main/config/database.php"
click node_modelbase "https://github.com/ismapereira/green-air/blob/main/app/models/Model.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_front,node_routes,node_auth,node_base,node_visitor toneBlue
class node_treeflow,node_treedata,node_catalog,node_uploads,node_treesview,node_database toneAmber
class node_contributions,node_suggestions,node_suggestiondata,node_badges,node_badge_records,node_notifications toneMint
class node_dashboard,node_users,node_cache,node_ranking,node_publicstats toneRose
class node_admin,node_weather,node_modelbase toneIndigo
```

## Components

### Web entry

- [HTTP front controller](https://github.com/ismapereira/green-air/blob/main/public/index.php): `public/index.php`
- [Route table](https://github.com/ismapereira/green-air/blob/main/routes/web.php): `routes/web.php`
- [Accounts and authentication](https://github.com/ismapereira/green-air/blob/main/app/controllers/AuthController.php): `app/controllers/AuthController.php`
- [Controller services](https://github.com/ismapereira/green-air/blob/main/app/controllers/Controller.php): `app/controllers/Controller.php`

### Tree mapping

- [Tree submissions and CRUD](https://github.com/ismapereira/green-air/blob/main/app/controllers/TreeController.php): `app/controllers/TreeController.php`
- [Tree records and map queries](https://github.com/ismapereira/green-air/blob/main/app/models/Tree.php): `app/models/Tree.php`
- [Species and preservation status](https://github.com/ismapereira/green-air/blob/main/app/models/TreeSpecies.php): `app/models/TreeSpecies.php`
- [Image upload handling](https://github.com/ismapereira/green-air/blob/main/app/helpers/UploadHelper.php): `app/helpers/UploadHelper.php`
- [Map and tree views](https://github.com/ismapereira/green-air/blob/main/app/views/map/index.php): `app/views/map/index.php`

### Community engagement

- [Contribution history](https://github.com/ismapereira/green-air/blob/main/app/models/ContributionLog.php): `app/models/ContributionLog.php`
- [Community suggestions](https://github.com/ismapereira/green-air/blob/main/app/controllers/SuggestionController.php): `app/controllers/SuggestionController.php`
- [Suggestion records](https://github.com/ismapereira/green-air/blob/main/app/models/CommunitySuggestion.php): `app/models/CommunitySuggestion.php`
- [Achievement checks](https://github.com/ismapereira/green-air/blob/main/app/helpers/BadgeChecker.php): `app/helpers/BadgeChecker.php`
- [Badge records](https://github.com/ismapereira/green-air/blob/main/app/models/Badge.php): `app/models/Badge.php`
- [User notifications](https://github.com/ismapereira/green-air/blob/main/app/models/Notification.php): `app/models/Notification.php`

### Dashboards and insights

- [User dashboard and APIs](https://github.com/ismapereira/green-air/blob/main/app/controllers/DashboardController.php): `app/controllers/DashboardController.php`
- [User points and rankings](https://github.com/ismapereira/green-air/blob/main/app/models/User.php): `app/models/User.php`
- [Weather response cache](https://github.com/ismapereira/green-air/blob/main/app/helpers/CacheHelper.php): `app/helpers/CacheHelper.php`
- [Ranking pages](https://github.com/ismapereira/green-air/blob/main/app/controllers/RankingController.php): `app/controllers/RankingController.php`
- [Public statistics](https://github.com/ismapereira/green-air/blob/main/app/controllers/HomeController.php): `app/controllers/HomeController.php`

### Administration

- [Admin management](https://github.com/ismapereira/green-air/tree/main/app/controllers): `app/controllers`

### Other components

- **Visitor or user**
- **OpenWeather**
- [MySQL database](https://github.com/ismapereira/green-air/blob/main/config/database.php): `config/database.php`
- [PDO model layer](https://github.com/ismapereira/green-air/blob/main/app/models/Model.php): `app/models/Model.php`

## Connections

- Visitor or user → HTTP front controller: sends requests
- HTTP front controller → Route table: dispatches via (evidence: `public/index.php`)
- Route table → Accounts and authentication: routes auth requests (evidence: `routes/web.php`)
- Route table → Tree submissions and CRUD: routes tree requests (evidence: `routes/web.php`)
- Route table → User dashboard and APIs: routes dashboard APIs (evidence: `routes/web.php`)
- Route table → Community suggestions: routes suggestions (evidence: `routes/web.php`)
- Route table → Ranking pages: routes ranking (evidence: `routes/web.php`)
- Route table → Public statistics: routes statistics (evidence: `routes/web.php`)
- Route table → Admin management: routes admin requests (evidence: `routes/web.php`)
- Tree submissions and CRUD → Tree records and map queries: creates and updates (evidence: `app/controllers/TreeController.php`)
- Tree submissions and CRUD → Species and preservation status: uses catalog (evidence: `app/controllers/TreeController.php`)
- Tree submissions and CRUD → Image upload handling: validates uploads (evidence: `app/controllers/TreeController.php`)
- Tree submissions and CRUD → User points and rankings: awards points (evidence: `app/controllers/TreeController.php`)
- Tree submissions and CRUD → Contribution history: logs actions (evidence: `app/controllers/TreeController.php`)
- Tree submissions and CRUD → Achievement checks: checks achievements (evidence: `app/controllers/TreeController.php`)
- Map and tree views → Tree records and map queries: uses tree data (evidence: `app/views/map/index.php`)
- Community suggestions → Suggestion records: creates suggestions (evidence: `app/controllers/SuggestionController.php`)
- Community suggestions → Achievement checks: checks achievements (evidence: `app/controllers/SuggestionController.php`)
- Achievement checks → Badge records: checks and unlocks (evidence: `app/helpers/BadgeChecker.php`)
- Achievement checks → User notifications: notifies unlocks (evidence: `app/helpers/BadgeChecker.php`)
- Accounts and authentication → User points and rankings: registers users (evidence: `app/controllers/AuthController.php`)
- Accounts and authentication → User notifications: creates welcome notice (evidence: `app/controllers/AuthController.php`)
- User dashboard and APIs → Tree records and map queries: loads user trees (evidence: `app/controllers/DashboardController.php`)
- User dashboard and APIs → User points and rankings: loads contributors (evidence: `app/controllers/DashboardController.php`)
- User dashboard and APIs → Weather response cache: reads and writes (evidence: `app/controllers/DashboardController.php`)
- User dashboard and APIs → OpenWeather: requests weather data (evidence: `app/controllers/DashboardController.php`)
- User dashboard and APIs → User notifications: loads and marks read (evidence: `app/controllers/DashboardController.php`)
- Ranking pages → User points and rankings: loads ranking data
- Public statistics → Tree records and map queries: uses tree statistics (evidence: `app/controllers/HomeController.php`)
- Admin management → MySQL database: manages records
- Controller services → User notifications: counts unread (evidence: `app/controllers/Controller.php`)
- Tree submissions and CRUD → Controller services: inherits services (evidence: `app/controllers/TreeController.php`)
- PDO model layer → MySQL database: queries through PDO (evidence: `app/models/Model.php`)
- Tree records and map queries → PDO model layer: uses PDO helpers (evidence: `app/models/Tree.php`)
- User points and rankings → PDO model layer: uses PDO helpers (evidence: `app/models/User.php`)
- User notifications → PDO model layer: uses PDO helpers (evidence: `app/models/Notification.php`)
