# gustavodesousalima/api-climaia architecture

> Architecture diagram of the GitHub repository gustavodesousalima/api-climaia, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gustavodesousalima/api-climaia
- Repository: https://github.com/gustavodesousalima/api-climaia

## Overview

##### Project type and purpose
- This is a full-stack API service (back-end only) for “Intelligent Weather Forecasting” using Flask and AI.
- Purpose: receive natural-language weather queries (in Portuguese), interpret them via GPT-3.5 (LangChain), fetch real-time data from OpenWeatherMap, and return a conversational response.

##### File structure
- Top-level files:
- app.py – Flask app entrypoint and routing
- requirements.txt / .env.example – dependencies and configuration
- src/config/settings.py – environment and API keys loader
- src/controllers/weather_controller.py – Flask endpoint logic
- src/services/agent_service.py – LangChain/OpenAI orchestration
- src/services/weather_service.py – OpenWeatherMap API wrapper

##### README for additional insights
- Stack: Python 3.8+, Flask for HTTP API, LangChain + OpenAI GPT-3.5 for NLU, OpenWeatherMap for data.
- Exposes endpoint POST /api/chat, expects JSON { "message": "..." }.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client"
        Client["Client (cURL/Postman/Web)"]:::client
    end

    %% HTTP Layer
    subgraph "HTTP Layer"
        FlaskAPI["Flask API (app.py)"]:::api
        WeatherController["Weather Controller"]:::api
    end

    %% Application Layer
    subgraph "Application Layer"
        AgentService["Agent Service"]:::service
        WeatherService["Weather Service"]:::service
    end

    %% Config Layer
    subgraph "Config & Documentation"
        ConfigLoader["Config Loader (settings.py)"]:::config
        EnvExample[".env.example"]:::config
        Requirements["requirements.txt"]:::doc
        Readme["README.md"]:::doc
    end

    %% External Services
    subgraph "External Services"
        OpenAI["OpenAI API"]:::external
        OpenWeatherMap["OpenWeatherMap API"]:::external
    end

    %% Connections
    Client -->|"HTTP POST /api/chat"| FlaskAPI
    FlaskAPI -->|"routes to"| WeatherController
    WeatherController -->|"invokes"| AgentService
    AgentService -->|"fetches weather data"| WeatherService
    AgentService -->|"calls GPT-3.5 via LangChain"| OpenAI
    WeatherService -->|"REST API"| OpenWeatherMap
    WeatherController -->|"returns JSON response"| Client

    %% Config relationships
    ConfigLoader -.->|"loads API keys"| AgentService
    ConfigLoader -.->|"loads API keys"| WeatherService
    EnvExample -.->|"template config"| ConfigLoader

    %% Documentation
    Requirements -.->|"defines dependencies"| FlaskAPI
    Readme -.->|"project overview"| FlaskAPI

    %% Click Events
    click FlaskAPI "https://github.com/gustavodesousalima/api-climaia/blob/main/app.py"
    click ConfigLoader "https://github.com/gustavodesousalima/api-climaia/blob/main/src/config/settings.py"
    click EnvExample "https://github.com/gustavodesousalima/api-climaia/blob/main/.env.example"
    click WeatherController "https://github.com/gustavodesousalima/api-climaia/blob/main/src/controllers/weather_controller.py"
    click AgentService "https://github.com/gustavodesousalima/api-climaia/blob/main/src/services/agent_service.py"
    click WeatherService "https://github.com/gustavodesousalima/api-climaia/blob/main/src/services/weather_service.py"
    click Requirements "https://github.com/gustavodesousalima/api-climaia/blob/main/requirements.txt"
    click Readme "https://github.com/gustavodesousalima/api-climaia/blob/main/README.md"

    %% Styles
    classDef client fill:#D6EAF8,stroke:#3498DB
    classDef api fill:#AED6F1,stroke:#2E86C1
    classDef service fill:#D5F5E3,stroke:#1D8348
    classDef external fill:#FDEDEC,stroke:#C0392B
    classDef config fill:#F9E79F,stroke:#B7950B
    classDef doc fill:#E8DAEF,stroke:#8E44AD
```
