# ramilmoral/simple-weather-api architecture

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

- Interactive diagram: https://gitdiagram.com/ramilmoral/simple-weather-api
- Repository: https://github.com/ramilmoral/simple-weather-api

## Overview

This Express API serves weather data through four weather routes: current weather by coordinates, city geocoding, a city forecast, and a latitude/longitude lookup. Requests enter through the app mount and weather routers, then route handlers validate query parameters, call OpenWeather, and return JSON or errors; shared error messages come from the enum module. The README documents configurable OpenWeather URLs and credentials, but their configuration template usage is not verified in the sampled code. The graph focuses on the API runtime; the separate sample home and users routes are not part of this workflow.

Main entry points: [`api/routes/weather.route.js`](https://github.com/ramilmoral/simple-weather-api/blob/main/api/routes/weather.route.js) (Weather router), [`api/enums/weather.enums.js`](https://github.com/ramilmoral/simple-weather-api/blob/main/api/enums/weather.enums.js) (Weather errors), [`api/controllers/weather.controller.js`](https://github.com/ramilmoral/simple-weather-api/blob/main/api/controllers/weather.controller.js) (Current weather), [`app.js`](https://github.com/ramilmoral/simple-weather-api/blob/main/app.js) (Express app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_server["HTTP server"]
  node_app["Express app<br/>[app.js]"]
end

subgraph group_routing["Weather routing"]
  node_api_router["API router<br/>[index.js]"]
  node_weather_router["Weather router<br/>[weather.route.js]"]
end

subgraph group_handlers["Weather handlers"]
  node_current_weather["Current weather"]
  node_city_lookup["City lookup"]
  node_daily_forecast["Daily forecast"]
  node_lat_lon_lookup["Coordinate lookup"]
  node_error_messages["Weather errors<br/>[weather.enums.js]"]
end

subgraph group_external["External service"]
  node_openweather{{"OpenWeather API"}}
end

node_caller(("HTTP client"))

node_caller -->|"sends request"| node_app
node_app -->|"mounts at /api"| node_api_router
node_api_router -->|"mounts at /weather"| node_weather_router
node_weather_router -->|"dispatches GET /"| node_current_weather
node_weather_router -->|"dispatches GET /city"| node_city_lookup
node_weather_router -->|"dispatches GET /daily-forecast"| node_daily_forecast
node_weather_router -->|"dispatches GET /lat-lon"| node_lat_lon_lookup
node_current_weather -->|"fetches weather"| node_openweather
node_city_lookup -->|"geocodes city"| node_openweather
node_daily_forecast -->|"fetches forecast"| node_openweather
node_lat_lon_lookup -->|"fetches weather"| node_openweather
node_current_weather -->|"uses messages"| node_error_messages
node_city_lookup -->|"uses messages"| node_error_messages
node_daily_forecast -->|"uses messages"| node_error_messages
node_lat_lon_lookup -->|"uses messages"| node_error_messages

click node_app "https://github.com/ramilmoral/simple-weather-api/blob/main/app.js"
click node_api_router "https://github.com/ramilmoral/simple-weather-api/blob/main/api/routes/index.js"
click node_weather_router "https://github.com/ramilmoral/simple-weather-api/blob/main/api/routes/weather.route.js"
click node_current_weather "https://github.com/ramilmoral/simple-weather-api/blob/main/api/controllers/weather.controller.js"
click node_city_lookup "https://github.com/ramilmoral/simple-weather-api/blob/main/api/controllers/weather.controller.js"
click node_daily_forecast "https://github.com/ramilmoral/simple-weather-api/blob/main/api/controllers/weather.controller.js"
click node_lat_lon_lookup "https://github.com/ramilmoral/simple-weather-api/blob/main/api/controllers/weather.controller.js"
click node_error_messages "https://github.com/ramilmoral/simple-weather-api/blob/main/api/enums/weather.enums.js"

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_app,node_caller toneBlue
class node_api_router,node_weather_router toneAmber
class node_current_weather,node_city_lookup,node_daily_forecast,node_lat_lon_lookup,node_error_messages toneMint
class node_openweather toneRose
```

## Components

### HTTP server

- [Express app](https://github.com/ramilmoral/simple-weather-api/blob/main/app.js): `app.js`

### Weather routing

- [API router](https://github.com/ramilmoral/simple-weather-api/blob/main/api/routes/index.js): `api/routes/index.js`
- [Weather router](https://github.com/ramilmoral/simple-weather-api/blob/main/api/routes/weather.route.js): `api/routes/weather.route.js`

### Weather handlers

- [Current weather](https://github.com/ramilmoral/simple-weather-api/blob/main/api/controllers/weather.controller.js): `api/controllers/weather.controller.js`
- [City lookup](https://github.com/ramilmoral/simple-weather-api/blob/main/api/controllers/weather.controller.js): `api/controllers/weather.controller.js`
- [Daily forecast](https://github.com/ramilmoral/simple-weather-api/blob/main/api/controllers/weather.controller.js): `api/controllers/weather.controller.js`
- [Coordinate lookup](https://github.com/ramilmoral/simple-weather-api/blob/main/api/controllers/weather.controller.js): `api/controllers/weather.controller.js`
- [Weather errors](https://github.com/ramilmoral/simple-weather-api/blob/main/api/enums/weather.enums.js): `api/enums/weather.enums.js`

### External service

- **OpenWeather API**

### Other components

- **HTTP client**

## Connections

- HTTP client → Express app: sends request (evidence: `app.js`)
- Express app → API router: mounts at /api (evidence: `app.js`)
- API router → Weather router: mounts at /weather (evidence: `api/routes/index.js`)
- Weather router → Current weather: dispatches GET / (evidence: `api/routes/weather.route.js`)
- Weather router → City lookup: dispatches GET /city (evidence: `api/routes/weather.route.js`)
- Weather router → Daily forecast: dispatches GET /daily-forecast (evidence: `api/routes/weather.route.js`)
- Weather router → Coordinate lookup: dispatches GET /lat-lon (evidence: `api/routes/weather.route.js`)
- Current weather → OpenWeather API: fetches weather (evidence: `api/controllers/weather.controller.js`)
- City lookup → OpenWeather API: geocodes city (evidence: `api/controllers/weather.controller.js`)
- Daily forecast → OpenWeather API: fetches forecast (evidence: `api/controllers/weather.controller.js`)
- Coordinate lookup → OpenWeather API: fetches weather (evidence: `api/controllers/weather.controller.js`)
- Current weather → Weather errors: uses messages (evidence: `api/controllers/weather.controller.js`)
- City lookup → Weather errors: uses messages (evidence: `api/controllers/weather.controller.js`)
- Daily forecast → Weather errors: uses messages (evidence: `api/controllers/weather.controller.js`)
- Coordinate lookup → Weather errors: uses messages (evidence: `api/controllers/weather.controller.js`)
