How rgbarra/informe-web-avanzado works
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: App.jsx App · weatherService.js Weather API · index.js Server · weatherRoutes.js Weather routes
Components 16
Frontend
React UI and client-side data access
- App · Top-level UI composition and request orchestration
frontend/src/App.jsx - Search · City input and submit control
frontend/src/components/WeatherSearch.jsx - Weather card · Displays weather results
frontend/src/components/WeatherCard.jsx - Weather API · Frontend abstraction for backend requests
frontend/src/services/weatherService.js - Main · Mounts the React application
frontend/src/main.jsx - Styles · Component and global styling
frontend/src/App.css - Global CSS · Base site styles
frontend/src/index.css - Redirects · SPA fallback routing for deployment
frontend/_redirects
Backend
Express API and weather proxy
- Server · Initializes middleware, config, routes, and listener
backend/index.js - Weather routes · API route definitions for weather requests
backend/routes/weatherRoutes.js - Controller · Handles weather API requests and responses
backend/controllers/weather.controller.js - Weather service · Calls OpenWeatherMap and shapes weather data
backend/services/weather.service.js - Config · Centralized environment and server configuration
backend/config/environment.js
External
Third-party APIs and hosting targets
- OpenWeatherMap · Upstream weather data provider
- Netlify · Frontend deployment target
- Render · Backend deployment target
Connections 17
- 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