# rgbarra/informe-web-avanzado architecture

> Architecture diagram of the GitHub repository rgbarra/informe-web-avanzado, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rgbarra/informe-web-avanzado
- Repository: https://github.com/rgbarra/informe-web-avanzado

## Overview

1. **Overall shape**
   - This repository is a **two-tier weather application**: a React frontend and an Express backend.
   - The frontend is a UI layer only; the backend acts as a **proxy/API facade** to OpenWeatherMap so the API key stays server-side.

2. **Frontend subsystem**
   - Located in `frontend/src`.
   - Built with **React 18 + Vite**.
   - `App.jsx` is the top-level composition point, with UI styling in `App.css` and global styles in `index.css`.
   - The UI is split into two main components:
     - `WeatherSearch.jsx` for city input / search submission
     - `WeatherCard.jsx` for displaying the returned weather data

3. **Frontend data access layer**
   - `frontend/src/services/weatherService.js` is the frontend’s HTTP client abstraction.
   - This is the only place the React UI should talk to the backend API, which keeps request logic out of components.
   - The frontend therefore follows a simple pattern: user action → service call → state update → render result.

4. **Backend subsystem**
   - Located in `backend`.
   - Built with **Node.js + Express**.
   - `backend/index.js` is the server bootstrap entrypoint: it likely initializes Express, middleware, environment config, route mounting, and starts the listener.
   - There is no database layer in this repo; the backend is stateless and request-driven.

5. **Backend request flow**
   - The API surface is defined in `backend/routes/weatherRoutes.js`.
   - Requests for weather data flow through:
     - route definition
     - `backend/controllers/weather.controller.js`
     - `backend/services/weather.service.js`
   - This separation creates a clean boundary between HTTP handling, business logic, and external API integration.

6. **External weather integration**
   - `backend/services/weather.service.js` is the integration point to **OpenWeatherMap**.
   - The backend uses the API key from environment variables, so the secret never reaches the browser.
   - The exposed endpoint, per the README, is `GET /api/v1/weather?city=...`.

7. **Configuration and security boundary**
   - `backend/config/environment.js` centralizes runtime configuration.
   - The README indicates use of `.env` for sensitive values such as `API_KEY`.
   - The architecture also includes a **CORS whitelist** so only approved frontend origins can call the backend.

8. **End-to-end data flow**
   - User enters a city in `WeatherSearch`.
   - `App.jsx` coordinates the request using `weatherService.js`.
   - The frontend sends an Axios request to the backend’s weather endpoint.
   - The backend controller validates/handles the request, the service calls OpenWeatherMap, and the response returns to the frontend.
   - `WeatherCard` renders the resulting weather conditions.

9. **Deployment topology**
   - The README shows the frontend is deployed on **Netlify** and the backend on **Render**.
   - `frontend/_redirects` suggests SPA fallback routing for direct client-side navigation on the hosting platform.
   - In production, the frontend talks across domains to the Render-hosted API.

10. **Build and tooling boundaries**
   - Frontend package uses the Vite toolchain and ESLint config (`eslint.config.js`).
   - Backend and frontend each have their own `package.json` and lockfile, so they are independently installable and deployable.
   - This is a **monorepo with two isolated runtimes**, not a single combined app.

11. **What is not present**
   - No persistent storage, authentication, job queue, or real-time channel is visible in the tree.
   - The architecture is intentionally narrow: **search city → fetch live weather → render result**.

12. **Diagram-friendly summary**
   - Draw two main boxes: **React UI** and **Express API**.
   - Between them, place a single HTTP/API call path.
   - From the backend, draw a second outbound connection to **OpenWeatherMap**.
   - Annotate the backend as the **secret-protecting proxy** and the frontend as the **presentation + user input layer**.

Main entry points: [`frontend/src/App.jsx`](https://github.com/rgbarra/informe-web-avanzado/blob/main/frontend/src/App.jsx) (App), [`frontend/src/services/weatherService.js`](https://github.com/rgbarra/informe-web-avanzado/blob/main/frontend/src/services/weatherService.js) (Weather API), [`backend/index.js`](https://github.com/rgbarra/informe-web-avanzado/blob/main/backend/index.js) (Server), [`backend/routes/weatherRoutes.js`](https://github.com/rgbarra/informe-web-avanzado/blob/main/backend/routes/weatherRoutes.js) (Weather routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_frontend_app["App<br/>React entry<br/>[App.jsx]"]
  node_frontend_search["Search<br/>UI component<br/>[WeatherSearch.jsx]"]
  node_frontend_card["Weather card<br/>UI component<br/>[WeatherCard.jsx]"]
  node_frontend_service["Weather API<br/>HTTP client<br/>[weatherService.js]"]
  node_frontend_main["Main<br/>React bootstrap<br/>[main.jsx]"]
  node_frontend_styles["Styles<br/>CSS<br/>[App.css]"]
  node_frontend_global["Global CSS<br/>[index.css]"]
  node_frontend_redirects["Redirects<br/>hosting config"]
end

subgraph group_backend["Backend"]
  node_backend_index["Server<br/>Express bootstrap<br/>[index.js]"]
  node_backend_routes["Weather routes<br/>HTTP routes<br/>[weatherRoutes.js]"]
  node_backend_controller["Controller<br/>request handler"]
  node_backend_service["Weather service<br/>API integration<br/>[weather.service.js]"]
  node_backend_env["Config<br/>[environment.js]"]
end

subgraph group_external["External"]
  node_external_weather(("OpenWeatherMap<br/>weather API"))
  node_external_netlify(("Netlify<br/>hosting"))
  node_external_render(("Render<br/>hosting"))
end

node_frontend_main -->|"boots"| node_frontend_app
node_frontend_app -->|"renders"| node_frontend_search
node_frontend_app -->|"renders"| node_frontend_card
node_frontend_app -->|"uses"| node_frontend_service
node_frontend_search -->|"submits"| node_frontend_service
node_frontend_service -->|"HTTP GET"| node_backend_routes
node_frontend_app -->|"styles"| node_frontend_styles
node_frontend_app -->|"styles"| node_frontend_global
node_frontend_redirects -.->|"deploys on"| node_external_netlify
node_backend_index -->|"loads"| node_backend_env
node_backend_index -->|"mounts"| node_backend_routes
node_backend_routes -->|"delegates"| node_backend_controller
node_backend_controller -->|"calls"| node_backend_service
node_backend_service -->|"requests"| node_external_weather
node_backend_env -->|"configures"| node_backend_service
node_backend_index -.->|"deploys on"| node_external_render
node_frontend_service -.->|"targets"| node_external_render

click node_frontend_app "https://github.com/rgbarra/informe-web-avanzado/blob/main/frontend/src/App.jsx"
click node_frontend_search "https://github.com/rgbarra/informe-web-avanzado/blob/main/frontend/src/components/WeatherSearch.jsx"
click node_frontend_card "https://github.com/rgbarra/informe-web-avanzado/blob/main/frontend/src/components/WeatherCard.jsx"
click node_frontend_service "https://github.com/rgbarra/informe-web-avanzado/blob/main/frontend/src/services/weatherService.js"
click node_frontend_main "https://github.com/rgbarra/informe-web-avanzado/blob/main/frontend/src/main.jsx"
click node_frontend_styles "https://github.com/rgbarra/informe-web-avanzado/blob/main/frontend/src/App.css"
click node_frontend_global "https://github.com/rgbarra/informe-web-avanzado/blob/main/frontend/src/index.css"
click node_frontend_redirects "https://github.com/rgbarra/informe-web-avanzado/tree/main/frontend/_redirects"
click node_backend_index "https://github.com/rgbarra/informe-web-avanzado/blob/main/backend/index.js"
click node_backend_routes "https://github.com/rgbarra/informe-web-avanzado/blob/main/backend/routes/weatherRoutes.js"
click node_backend_controller "https://github.com/rgbarra/informe-web-avanzado/blob/main/backend/controllers/weather.controller.js"
click node_backend_service "https://github.com/rgbarra/informe-web-avanzado/blob/main/backend/services/weather.service.js"
click node_backend_env "https://github.com/rgbarra/informe-web-avanzado/blob/main/backend/config/environment.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_frontend_app,node_frontend_search,node_frontend_card,node_frontend_service,node_frontend_main,node_frontend_styles,node_frontend_global,node_frontend_redirects toneBlue
class node_backend_index,node_backend_routes,node_backend_controller,node_backend_service,node_backend_env toneAmber
class node_external_weather,node_external_netlify,node_external_render toneMint
```

## Components

### Frontend

React UI and client-side data access

- [App](https://github.com/rgbarra/informe-web-avanzado/blob/main/frontend/src/App.jsx): React entry · Top-level UI composition and request orchestration · `frontend/src/App.jsx`
- [Search](https://github.com/rgbarra/informe-web-avanzado/blob/main/frontend/src/components/WeatherSearch.jsx): UI component · City input and submit control · `frontend/src/components/WeatherSearch.jsx`
- [Weather card](https://github.com/rgbarra/informe-web-avanzado/blob/main/frontend/src/components/WeatherCard.jsx): UI component · Displays weather results · `frontend/src/components/WeatherCard.jsx`
- [Weather API](https://github.com/rgbarra/informe-web-avanzado/blob/main/frontend/src/services/weatherService.js): HTTP client · Frontend abstraction for backend requests · `frontend/src/services/weatherService.js`
- [Main](https://github.com/rgbarra/informe-web-avanzado/blob/main/frontend/src/main.jsx): React bootstrap · Mounts the React application · `frontend/src/main.jsx`
- [Styles](https://github.com/rgbarra/informe-web-avanzado/blob/main/frontend/src/App.css): CSS · Component and global styling · `frontend/src/App.css`
- [Global CSS](https://github.com/rgbarra/informe-web-avanzado/blob/main/frontend/src/index.css): CSS · Base site styles · `frontend/src/index.css`
- [Redirects](https://github.com/rgbarra/informe-web-avanzado/tree/main/frontend/_redirects): hosting config · SPA fallback routing for deployment · `frontend/_redirects`

### Backend

Express API and weather proxy

- [Server](https://github.com/rgbarra/informe-web-avanzado/blob/main/backend/index.js): Express bootstrap · Initializes middleware, config, routes, and listener · `backend/index.js`
- [Weather routes](https://github.com/rgbarra/informe-web-avanzado/blob/main/backend/routes/weatherRoutes.js): HTTP routes · API route definitions for weather requests · `backend/routes/weatherRoutes.js`
- [Controller](https://github.com/rgbarra/informe-web-avanzado/blob/main/backend/controllers/weather.controller.js): request handler · Handles weather API requests and responses · `backend/controllers/weather.controller.js`
- [Weather service](https://github.com/rgbarra/informe-web-avanzado/blob/main/backend/services/weather.service.js): API integration · Calls OpenWeatherMap and shapes weather data · `backend/services/weather.service.js`
- [Config](https://github.com/rgbarra/informe-web-avanzado/blob/main/backend/config/environment.js): runtime config · Centralized environment and server configuration · `backend/config/environment.js`

### External

Third-party APIs and hosting targets

- **OpenWeatherMap**: weather API · Upstream weather data provider
- **Netlify**: hosting · Frontend deployment target
- **Render**: hosting · Backend deployment target

## Connections

- Main → App: boots · React entry mounts the application
- App → Search: renders · Composes city search UI
- App → Weather card: renders · Composes weather result UI
- App → Weather API: uses · Coordinates API requests through the service layer
- Search → Weather API: submits · User search triggers a weather lookup
- Weather API → Weather routes: HTTP GET · Calls the backend weather endpoint
- App → Styles: styles · Application-specific styling
- App → Global CSS: styles · Global base styling
- Redirects → Netlify: deploys on · Supports SPA routing in production
- Server → Config: loads · Bootstraps runtime configuration
- Server → Weather routes: mounts · Registers API routes
- Weather routes → Controller: delegates · Routes forward requests to controller logic
- Controller → Weather service: calls · Controller delegates weather retrieval
- Weather service → OpenWeatherMap: requests · Fetches live weather from upstream provider
- Config → Weather service: configures · Provides API key and runtime settings
- Server → Render: deploys on · Backend hosted as a separate service
- Weather API → Render: targets · Frontend talks to the hosted API across domains
