<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Saras Growth Space</title>
    <description>The latest articles on DEV Community by Saras Growth Space (@saras_growth_space).</description>
    <link>https://dev.to/saras_growth_space</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3805711%2F9d71d829-9e4b-42ad-919e-ef864f55f79d.png</url>
      <title>DEV Community: Saras Growth Space</title>
      <link>https://dev.to/saras_growth_space</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/saras_growth_space"/>
    <language>en</language>
    <item>
      <title>Building a Production-Oriented Weather API with FastAPI – Project Structure and Environment Setup</title>
      <dc:creator>Saras Growth Space</dc:creator>
      <pubDate>Sat, 05 Dec 2026 16:05:28 +0000</pubDate>
      <link>https://dev.to/saras_growth_space/building-a-production-oriented-weather-api-with-fastapi-project-structure-and-environment-setup-3ekc</link>
      <guid>https://dev.to/saras_growth_space/building-a-production-oriented-weather-api-with-fastapi-project-structure-and-environment-setup-3ekc</guid>
      <description>&lt;p&gt;&lt;em&gt;Part 2 of our FastAPI Weather API series&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In the previous article, we explored the architecture of our Weather API project and discussed how to organize a FastAPI application beyond a simple collection of endpoints.&lt;/p&gt;

&lt;p&gt;In this article, we'll move from architectural planning to the actual project foundation.&lt;/p&gt;

&lt;p&gt;Before writing application code, we need two things in place:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A well-defined project structure.&lt;/li&gt;
&lt;li&gt;A reproducible Python development environment.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We'll walk through the decisions, setup steps, commands, and reasoning behind them.&lt;/p&gt;

&lt;p&gt;Our goal is not just to make a FastAPI application run. We want to establish a foundation that can support testing, external API integrations, error handling, observability, and future production requirements.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Project Overview
&lt;/h2&gt;

&lt;p&gt;We're building a Weather API using &lt;strong&gt;FastAPI&lt;/strong&gt; and &lt;strong&gt;Open-Meteo&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Open-Meteo provides two APIs that will form the foundation of our application:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Geocoding API:&lt;/strong&gt; Converts a location or city name into geographic coordinates.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Forecast API:&lt;/strong&gt; Retrieves weather information using latitude and longitude.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Our planned API endpoints are:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Endpoint&lt;/th&gt;
&lt;th&gt;Responsibility&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /health&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Check application health&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /api/v1/locations/search&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Search for locations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /api/v1/weather/current&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Retrieve current weather&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /api/v1/weather/forecast&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Retrieve weather forecasts&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;We'll develop these endpoints incrementally rather than implementing everything at once.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Task 1 – Designing the Project Structure
&lt;/h2&gt;

&lt;p&gt;Before creating files, we first defined how responsibilities should be separated.&lt;/p&gt;

&lt;p&gt;A common beginner approach is to place everything inside a single &lt;code&gt;main.py&lt;/code&gt; file. This is convenient for a small demonstration, but it becomes difficult to maintain as the application grows.&lt;/p&gt;

&lt;p&gt;For our project, we chose a layered structure that separates:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;API routing and HTTP concerns&lt;/li&gt;
&lt;li&gt;Application services&lt;/li&gt;
&lt;li&gt;Domain models and interfaces&lt;/li&gt;
&lt;li&gt;External API integrations&lt;/li&gt;
&lt;li&gt;Configuration and infrastructure&lt;/li&gt;
&lt;li&gt;Error handling&lt;/li&gt;
&lt;li&gt;Observability&lt;/li&gt;
&lt;li&gt;Tests&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2.1 Our planned directory structure
&lt;/h3&gt;

&lt;p&gt;The following is the target structure for the project. We'll introduce and implement these components progressively as the relevant milestones arrive.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;weather-service/
│
├── app/
│   ├── main.py
│   │
│   ├── api/
│   │   ├── router.py
│   │   ├── dependencies/
│   │   │   └── weather.py
│   │   ├── routers/
│   │   │   └── health.py
│   │   └── v1/
│   │       ├── router.py
│   │       └── routers/
│   │           ├── weather.py
│   │           └── locations.py
│   │
│   ├── middleware/
│   │   ├── request_context.py
│   │   └── request_logging.py
│   │
│   ├── core/
│   │   ├── config.py
│   │   ├── lifespan.py
│   │   └── logging.py
│   │
│   ├── schemas/
│   │   ├── requests/
│   │   │   └── weather.py
│   │   ├── responses/
│   │   │   ├── weather.py
│   │   │   ├── location.py
│   │   │   └── common.py
│   │   └── errors.py
│   │
│   ├── domain/
│   │   ├── models/
│   │   │   ├── weather.py
│   │   │   └── location.py
│   │   ├── interfaces/
│   │   │   └── weather_provider.py
│   │   └── exceptions/
│   │       └── weather.py
│   │
│   ├── services/
│   │   ├── weather_service.py
│   │   └── location_service.py
│   │
│   ├── integrations/
│   │   └── open_meteo/
│   │       ├── provider.py
│   │       ├── geocoding_client.py
│   │       ├── forecast_client.py
│   │       ├── schemas/
│   │       │   ├── geocoding.py
│   │       │   └── forecast.py
│   │       ├── mapper.py
│   │       └── exceptions.py
│   │
│   ├── exceptions/
│   │   ├── application.py
│   │   └── handlers.py
│   │
│   └── observability/
│       ├── instrumentation.py
│       ├── metrics.py
│       └── tracing.py
│
├── tests/
│   ├── unit/
│   ├── integration/
│   └── contract/
│
├── .env.example
├── .gitignore
├── .python-version
├── pyproject.toml
├── uv.lock
├── README.md
├── Dockerfile
└── docker-compose.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Some files and folders in this structure are planned for later milestones. We are not creating every file immediately.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.2 Why did we choose this structure?
&lt;/h3&gt;

&lt;p&gt;Let's understand the purpose of the major directories.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;app/api/&lt;/code&gt; – API layer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is where FastAPI routers and dependencies live.&lt;/p&gt;

&lt;p&gt;We separated the health endpoint from the versioned API:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;api/routers/health.py&lt;/code&gt; contains the health-check endpoint.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;api/v1/routers/weather.py&lt;/code&gt; contains weather-related endpoints.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;api/v1/routers/locations.py&lt;/code&gt; contains location-search endpoints.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;api/v1/router.py&lt;/code&gt; combines the version 1 routers.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;api/router.py&lt;/code&gt; combines the health router and versioned API router.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This gives us a clean place to introduce future API versions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;app/api/dependencies/&lt;/code&gt; – Reusable dependencies&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;FastAPI dependencies allow us to provide initialized services and other reusable components to endpoints.&lt;/p&gt;

&lt;p&gt;For example, an endpoint shouldn't need to construct a new weather provider every time it receives a request.&lt;/p&gt;

&lt;p&gt;Dependencies help us manage these objects and make testing easier.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;app/core/&lt;/code&gt; – Application configuration and infrastructure&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This directory contains application-wide configuration:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;config.py&lt;/code&gt; – Application settings.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;lifespan.py&lt;/code&gt; – Startup and shutdown resource management.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;logging.py&lt;/code&gt; – Logging configuration.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, we'll eventually use the application lifespan to initialize and close a shared HTTP client.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;app/schemas/&lt;/code&gt; – Public API contracts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Schemas define the structure of data entering and leaving our API.&lt;/p&gt;

&lt;p&gt;We separated request schemas from response schemas because they serve different purposes.&lt;/p&gt;

&lt;p&gt;We also included &lt;code&gt;errors.py&lt;/code&gt; to define the structure of our API error responses.&lt;/p&gt;

&lt;p&gt;An important distinction: this file defines the response format for errors. It does not contain all application exceptions or their handling logic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;app/domain/&lt;/code&gt; – Core application concepts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The domain layer contains application-level concepts independent of the external weather provider.&lt;/p&gt;

&lt;p&gt;It includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Models representing weather and location information.&lt;/li&gt;
&lt;li&gt;Interfaces describing the expected behavior of a weather provider.&lt;/li&gt;
&lt;li&gt;Domain exceptions representing meaningful application problems.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This separation helps prevent our business logic from becoming tightly coupled to Open-Meteo.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;app/services/&lt;/code&gt; – Application operations&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Services coordinate application operations.&lt;/p&gt;

&lt;p&gt;For example, a weather service might coordinate a provider call, process the returned data, and prepare the result for the API layer.&lt;/p&gt;

&lt;p&gt;The router should handle HTTP concerns, not implement the entire weather retrieval workflow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;app/integrations/open_meteo/&lt;/code&gt; – External provider integration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This directory contains everything specific to Open-Meteo.&lt;/p&gt;

&lt;p&gt;We separated geocoding and forecast clients because they communicate with different external API endpoints.&lt;/p&gt;

&lt;p&gt;The provider adapter exposes a consistent interface to the rest of our application.&lt;/p&gt;

&lt;p&gt;The mapper translates provider-specific responses into our internal representations.&lt;/p&gt;

&lt;p&gt;This means that if we introduce another weather provider in the future, we won't need to redesign the entire application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;app/exceptions/&lt;/code&gt; – Application-level error handling&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This directory contains application exceptions and FastAPI exception handlers.&lt;/p&gt;

&lt;p&gt;The handlers will translate internal errors into appropriate HTTP status codes and the public error response format defined in &lt;code&gt;schemas/errors.py&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A location that cannot be found may become HTTP 404.&lt;/li&gt;
&lt;li&gt;Invalid input may become HTTP 422.&lt;/li&gt;
&lt;li&gt;An upstream provider timeout may become HTTP 504.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The exact mapping will depend on the semantics of each error.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;app/middleware/&lt;/code&gt; – Cross-cutting HTTP concerns&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Middleware is useful for functionality that applies across HTTP requests.&lt;/p&gt;

&lt;p&gt;We'll use this area for request context and request logging.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;app/observability/&lt;/code&gt; – Monitoring and diagnostics&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Observability helps us understand how the application behaves.&lt;/p&gt;

&lt;p&gt;We have reserved space for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Instrumentation&lt;/li&gt;
&lt;li&gt;Metrics&lt;/li&gt;
&lt;li&gt;Distributed tracing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These concerns will be introduced when the application reaches the relevant development stage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;tests/&lt;/code&gt; – Testing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We divided tests into three categories:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;unit/&lt;/code&gt; – Test individual functions and components.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;integration/&lt;/code&gt; – Test interactions between application components.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;contract/&lt;/code&gt; – Verify that external and public API contracts are respected.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This separation helps us organize tests as the project grows.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.3 Why don't we have a repositories directory?
&lt;/h3&gt;

&lt;p&gt;A repository layer is commonly used when an application works with databases or persistent storage.&lt;/p&gt;

&lt;p&gt;Our current application retrieves weather information from an external API. Calling an external API is not automatically a repository operation.&lt;/p&gt;

&lt;p&gt;We therefore chose not to introduce a &lt;code&gt;repositories/&lt;/code&gt; directory prematurely.&lt;/p&gt;

&lt;p&gt;If we introduce database-backed functionality later, we can add the appropriate abstraction then.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.4 Why do we have two schema locations?
&lt;/h3&gt;

&lt;p&gt;This is an important architectural distinction.&lt;/p&gt;

&lt;p&gt;We have:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;app/schemas/&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;app/integrations/open_meteo/schemas/&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;They serve different purposes.&lt;/p&gt;

&lt;p&gt;Our application schemas define the contracts exposed by our own Weather API.&lt;/p&gt;

&lt;p&gt;Open-Meteo schemas describe the response formats returned by the external provider.&lt;/p&gt;

&lt;p&gt;We shouldn't expose the external provider's response structure directly as our public API contract.&lt;/p&gt;

&lt;p&gt;Keeping these schemas separate gives us control over our own API, even if the external provider changes its response format.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.5 Python packages and &lt;code&gt;__init__.py&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;For directories intended to be regular Python packages, we'll include &lt;code&gt;__init__.py&lt;/code&gt; files.&lt;/p&gt;

&lt;p&gt;Initially, these files can remain empty.&lt;/p&gt;

&lt;p&gt;Python also supports namespace packages, which don't require &lt;code&gt;__init__.py&lt;/code&gt;. However, namespace packages are useful for specific packaging scenarios and aren't necessary for our application.&lt;/p&gt;

&lt;p&gt;For this project, regular packages provide a straightforward and predictable structure.&lt;/p&gt;

&lt;p&gt;We'll use absolute imports and run the application from the project root.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Task 2 – Setting Up the Python Development Environment
&lt;/h2&gt;

&lt;p&gt;With the architecture planned, we can establish our development environment.&lt;/p&gt;

&lt;p&gt;Our actual development setup is:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Choice&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Operating system&lt;/td&gt;
&lt;td&gt;Windows&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;IDE&lt;/td&gt;
&lt;td&gt;Visual Studio Code&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Python&lt;/td&gt;
&lt;td&gt;3.14&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Shell&lt;/td&gt;
&lt;td&gt;PowerShell&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Virtual environment&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.venv&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Project/dependency manager&lt;/td&gt;
&lt;td&gt;uv&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Web framework&lt;/td&gt;
&lt;td&gt;FastAPI&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;We chose Python 3.14 for this project. Dependency compatibility is important, so we should verify that the packages we use support the selected Python version.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.1 Verify Python installation
&lt;/h3&gt;

&lt;p&gt;First, open the project folder in VS Code.&lt;/p&gt;

&lt;p&gt;Open the integrated terminal and select PowerShell.&lt;/p&gt;

&lt;p&gt;Verify the installed Python version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check which Python executable is being used:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;where&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exe&lt;/span&gt; &lt;span class="n"&gt;python&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This helps confirm that the terminal is resolving the expected Python installation.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.2 Create a virtual environment
&lt;/h3&gt;

&lt;p&gt;A virtual environment isolates project dependencies from other Python projects on the same machine.&lt;/p&gt;

&lt;p&gt;This is important because different projects may require different versions of the same package.&lt;/p&gt;

&lt;p&gt;We created the virtual environment using VS Code.&lt;/p&gt;

&lt;p&gt;Our environment directory is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.venv/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After creation, we verified that it was activated and that the expected Python executable was being used.&lt;/p&gt;

&lt;p&gt;Useful verification commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="no"&gt;VIRTUAL_ENV&lt;/span&gt;
&lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;version&lt;/span&gt;
&lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="n"&gt;pip&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;VIRTUAL_ENV&lt;/code&gt; variable should point to the project's &lt;code&gt;.venv&lt;/code&gt; directory when the environment is activated.&lt;/p&gt;

&lt;p&gt;The Python and pip commands should resolve to the environment's executables.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.3 Why use a virtual environment?
&lt;/h3&gt;

&lt;p&gt;Without an isolated environment, installing a package for one project can affect another project.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Project A may require one version of HTTPX.&lt;/li&gt;
&lt;li&gt;Project B may require a different version.&lt;/li&gt;
&lt;li&gt;Installing both globally can create dependency conflicts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A virtual environment keeps their dependencies separate.&lt;/p&gt;

&lt;p&gt;We will also make sure that &lt;code&gt;.venv&lt;/code&gt; is excluded from Git because it is a local development environment, not source code.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Understanding uv and Uvicorn
&lt;/h2&gt;

&lt;p&gt;One of the important decisions in our setup was choosing &lt;code&gt;uv&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;There is a common source of confusion here: &lt;strong&gt;uv and Uvicorn are different tools.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;uv&lt;/strong&gt; is a Python project and package manager. We use it to manage dependencies, lockfiles, and environment synchronization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Uvicorn&lt;/strong&gt; is an ASGI server. It runs our FastAPI application and handles incoming ASGI requests.&lt;/p&gt;

&lt;p&gt;They solve different problems, so they are not alternatives to each other.&lt;/p&gt;

&lt;p&gt;FastAPI applications commonly use Uvicorn as their ASGI server.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.1 Installing uv inside our virtual environment
&lt;/h3&gt;

&lt;p&gt;For this project, we decided to keep uv inside the project's &lt;code&gt;.venv&lt;/code&gt; rather than install it separately on the machine.&lt;/p&gt;

&lt;p&gt;We bootstrapped uv using pip:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="n"&gt;pip&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="n"&gt;uv&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then verified the installation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;uv&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the workflow we chose for our learning project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;General recommendation:&lt;/strong&gt; It is more conventional to install uv outside the environment it manages, often at the user level. That way, uv remains available even if a project virtual environment is deleted.&lt;/p&gt;

&lt;p&gt;Our chosen approach works, but it has a practical limitation: if &lt;code&gt;.venv&lt;/code&gt; is deleted, uv must be bootstrapped again before it can be used to recreate the environment.&lt;/p&gt;

&lt;p&gt;We'll keep this distinction in mind rather than presenting our choice as the universal recommendation.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Configuring pyproject.toml
&lt;/h2&gt;

&lt;p&gt;Python projects need a central place to define project metadata, dependencies, and development-tool configuration.&lt;/p&gt;

&lt;p&gt;We use &lt;code&gt;pyproject.toml&lt;/code&gt; for this purpose.&lt;/p&gt;

&lt;p&gt;Our initial configuration is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="k"&gt;[project]&lt;/span&gt;
&lt;span class="na"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"weather-service"&lt;/span&gt;
&lt;span class="na"&gt;version&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"0.1.0"&lt;/span&gt;
&lt;span class="na"&gt;description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"A production-oriented weather API built with FastAPI"&lt;/span&gt;
&lt;span class="na"&gt;requires-python&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;gt;=3.14,&amp;lt;3.15"&lt;/span&gt;
&lt;span class="na"&gt;dependencies&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s2"&gt;"fastapi[standard]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"httpx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"pydantic"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;[dependency-groups]&lt;/span&gt;
&lt;span class="na"&gt;dev&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s2"&gt;"pytest"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"ruff"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"uv"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;[tool.uv]&lt;/span&gt;
&lt;span class="na"&gt;package&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;

&lt;span class="k"&gt;[tool.ruff]&lt;/span&gt;
&lt;span class="na"&gt;line-length&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;
&lt;span class="na"&gt;target-version&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"py314"&lt;/span&gt;

&lt;span class="k"&gt;[tool.pytest.ini_options]&lt;/span&gt;
&lt;span class="na"&gt;testpaths&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"tests"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's understand the important sections.&lt;/p&gt;

&lt;h3&gt;
  
  
  5.1 Project metadata
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="k"&gt;[project]&lt;/span&gt;
&lt;span class="na"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"weather-service"&lt;/span&gt;
&lt;span class="na"&gt;version&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"0.1.0"&lt;/span&gt;
&lt;span class="na"&gt;requires-python&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;gt;=3.14,&amp;lt;3.15"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This defines the project name, version, and supported Python version range.&lt;/p&gt;

&lt;p&gt;We explicitly selected Python 3.14 for this project.&lt;/p&gt;

&lt;h3&gt;
  
  
  5.2 Runtime dependencies
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="na"&gt;dependencies&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s2"&gt;"fastapi[standard]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"httpx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"pydantic"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These packages are required by the application at runtime.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FastAPI&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Our web framework.&lt;/p&gt;

&lt;p&gt;We chose &lt;code&gt;fastapi[standard]&lt;/code&gt; instead of declaring FastAPI and Uvicorn separately.&lt;/p&gt;

&lt;p&gt;The standard extras provide commonly used FastAPI tooling, including an ASGI server and the FastAPI CLI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTTPX&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We'll use HTTPX to communicate with Open-Meteo.&lt;/p&gt;

&lt;p&gt;It supports synchronous and asynchronous HTTP requests. For our application, we'll use its asynchronous capabilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pydantic&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;FastAPI uses Pydantic for data validation and serialization.&lt;/p&gt;

&lt;p&gt;Although Pydantic is installed as a dependency of FastAPI, our application will use it directly. Explicitly declaring it makes our direct dependency clear.&lt;/p&gt;

&lt;h3&gt;
  
  
  5.3 Development dependencies
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="k"&gt;[dependency-groups]&lt;/span&gt;
&lt;span class="na"&gt;dev&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s2"&gt;"pytest"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"ruff"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"uv"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These packages support development rather than application runtime functionality.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;pytest:&lt;/strong&gt; Testing framework.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ruff:&lt;/strong&gt; Linting and formatting.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;uv:&lt;/strong&gt; Included in our development environment as part of our chosen setup.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One detail worth remembering: uv is included here because of our specific decision to keep it in &lt;code&gt;.venv&lt;/code&gt;. It is not a normal application runtime dependency.&lt;/p&gt;

&lt;h3&gt;
  
  
  5.4 Why package = false?
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="k"&gt;[tool.uv]&lt;/span&gt;
&lt;span class="na"&gt;package&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our application is not intended to be distributed as an installable Python library.&lt;/p&gt;

&lt;p&gt;We want to run the application directly from the project directory.&lt;/p&gt;

&lt;p&gt;This setting tells uv not to install the project itself as a package when synchronizing the environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  5.5 Ruff configuration
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="k"&gt;[tool.ruff]&lt;/span&gt;
&lt;span class="na"&gt;line-length&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;
&lt;span class="na"&gt;target-version&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"py314"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We configure Ruff to use a line length of 100 characters and target Python 3.14 syntax.&lt;/p&gt;

&lt;p&gt;This helps maintain consistent code quality as the project grows.&lt;/p&gt;

&lt;h3&gt;
  
  
  5.6 Pytest configuration
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="k"&gt;[tool.pytest.ini_options]&lt;/span&gt;
&lt;span class="na"&gt;testpaths&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"tests"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This tells pytest where to look for tests by default.&lt;/p&gt;

&lt;p&gt;We have already reserved the &lt;code&gt;tests/&lt;/code&gt; directory in our project structure.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. Generating the Lockfile and Synchronizing Dependencies
&lt;/h2&gt;

&lt;p&gt;Defining dependencies in &lt;code&gt;pyproject.toml&lt;/code&gt; is only part of dependency management.&lt;/p&gt;

&lt;p&gt;We also want a lockfile.&lt;/p&gt;

&lt;p&gt;A lockfile records the resolved dependency versions so that the environment can be reproduced more consistently.&lt;/p&gt;

&lt;h3&gt;
  
  
  6.1 Generate uv.lock
&lt;/h3&gt;

&lt;p&gt;From the project root, execute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;uv&lt;/span&gt; &lt;span class="n"&gt;lock&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This generates the &lt;code&gt;uv.lock&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;We should commit this file to Git because it helps other developers reproduce the same resolved dependency environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  6.2 Synchronize the environment
&lt;/h3&gt;

&lt;p&gt;Next, execute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;uv&lt;/span&gt; &lt;span class="n"&gt;sync&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This synchronizes the project's virtual environment with the dependencies declared in the project configuration and lockfile.&lt;/p&gt;

&lt;p&gt;Because we use the &lt;code&gt;dev&lt;/code&gt; dependency group, the default development synchronization includes our development tools.&lt;/p&gt;




&lt;h2&gt;
  
  
  7. Verifying the Environment
&lt;/h2&gt;

&lt;p&gt;After installation, we verify that the expected tools are available.&lt;/p&gt;

&lt;p&gt;Run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;uv&lt;/span&gt; &lt;span class="n"&gt;run&lt;/span&gt; &lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;version&lt;/span&gt;
&lt;span class="n"&gt;uv&lt;/span&gt; &lt;span class="n"&gt;run&lt;/span&gt; &lt;span class="n"&gt;fastapi&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;version&lt;/span&gt;
&lt;span class="n"&gt;uv&lt;/span&gt; &lt;span class="n"&gt;run&lt;/span&gt; &lt;span class="n"&gt;pytest&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;version&lt;/span&gt;
&lt;span class="n"&gt;uv&lt;/span&gt; &lt;span class="n"&gt;run&lt;/span&gt; &lt;span class="n"&gt;ruff&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can also inspect installed packages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;uv&lt;/span&gt; &lt;span class="n"&gt;pip&lt;/span&gt; &lt;span class="n"&gt;list&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These checks help confirm that the environment is configured correctly.&lt;/p&gt;

&lt;p&gt;At this stage, we have not implemented our API endpoints yet. We have established the project structure and development environment needed to begin application development.&lt;/p&gt;




&lt;h2&gt;
  
  
  8. Important Project Configuration Files
&lt;/h2&gt;

&lt;p&gt;Our project root contains several configuration and documentation files.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;File&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;pyproject.toml&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Project metadata, dependencies, and tool configuration&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;uv.lock&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Resolved dependency versions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.python-version&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Declares the project's intended Python version&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.gitignore&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Defines files and directories Git should ignore&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.env.example&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Documents environment variables the application may require&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;README.md&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Project documentation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Dockerfile&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Planned container build instructions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;docker-compose.yml&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Planned local multi-container configuration&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Not every file needs to contain implementation details immediately. Some are included in the target project structure for future milestones.&lt;/p&gt;




&lt;h2&gt;
  
  
  9. Git and Project Progress
&lt;/h2&gt;

&lt;p&gt;We are developing this project alongside a Git repository.&lt;/p&gt;

&lt;p&gt;The intention is to keep meaningful milestones in separate commits rather than wait until the entire application is finished.&lt;/p&gt;

&lt;p&gt;For the environment and dependency setup, our commit message is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chore: configure Python environment and dependencies
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before committing, we should inspect the changes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;
&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;diff&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Stage the relevant project files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="no"&gt;README&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;md&lt;/span&gt; &lt;span class="n"&gt;pyproject&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;toml&lt;/span&gt; &lt;span class="n"&gt;uv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lock&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;python&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;version&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gitignore&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Review the staged changes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;diff&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;cached&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then commit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;commit&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="s2"&gt;"chore: configure Python environment and dependencies"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, verify:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;
&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;log&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;oneline&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We should not commit &lt;code&gt;.venv&lt;/code&gt;, Python cache files, or local secrets.&lt;/p&gt;




&lt;h2&gt;
  
  
  10. Task 3 – Git Configuration and Repository Hygiene
&lt;/h2&gt;

&lt;p&gt;With the project structure and Python environment ready, we also need to ensure that our Git repository is configured properly.&lt;/p&gt;

&lt;p&gt;We created a GitHub repository using GitHub's standard Python template, which provided us with an initial &lt;code&gt;.gitignore&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;We reviewed it and made a few project-specific decisions.&lt;/p&gt;

&lt;h3&gt;
  
  
  10.1 What should Git track?
&lt;/h3&gt;

&lt;p&gt;Not everything in a Python project belongs in version control.&lt;/p&gt;

&lt;p&gt;We should exclude:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;.venv/&lt;/code&gt; – Local virtual environment.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.env&lt;/code&gt; – Local environment variables and secrets.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;__pycache__/&lt;/code&gt; – Python-generated cache files.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.pytest_cache/&lt;/code&gt; – Pytest cache.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.ruff_cache/&lt;/code&gt; – Ruff cache.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.vscode/&lt;/code&gt; – Local editor configuration in our current setup.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We also made sure that the following files remain eligible for version control:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;pyproject.toml&lt;/code&gt; – Project metadata and dependencies.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;uv.lock&lt;/code&gt; – Resolved dependency versions.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.python-version&lt;/code&gt; – Selected Python version.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.env.example&lt;/code&gt; – Example environment configuration without real secrets.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;README.md&lt;/code&gt; – Project documentation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One important detail: our &lt;code&gt;.gitignore&lt;/code&gt; contains commented-out entries for &lt;code&gt;uv.lock&lt;/code&gt; and &lt;code&gt;.python-version&lt;/code&gt;. Since these entries are commented out, Git does not ignore those files.&lt;/p&gt;

&lt;h3&gt;
  
  
  10.2 What about the .vscode directory?
&lt;/h3&gt;

&lt;p&gt;VS Code workspace configuration can be useful when working in a team.&lt;/p&gt;

&lt;p&gt;However, it can also contain personal settings and machine-specific configuration.&lt;/p&gt;

&lt;p&gt;For our current individual development workflow, we decided to ignore the entire &lt;code&gt;.vscode/&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;If we later introduce shared workspace settings or recommended extensions, we can selectively commit those files.&lt;/p&gt;

&lt;h3&gt;
  
  
  10.3 Commit message conventions
&lt;/h3&gt;

&lt;p&gt;We also decided to follow a consistent commit message format.&lt;/p&gt;

&lt;p&gt;We'll use the Conventional Commits style:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;type: short description&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Some common prefixes we'll use:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Prefix&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;feat:&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;New functionality&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;fix:&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Bug fixes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;chore:&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Project maintenance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;docs:&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Documentation changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;test:&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Tests&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;refactor:&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Code restructuring&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chore: configure Python environment and dependencies
chore: initialize project structure
chore: update gitignore for local development
docs: update project documentation
feat: add weather forecast endpoint
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We are currently committing directly to the &lt;code&gt;main&lt;/code&gt; branch. For an individual learning project, this is a reasonable starting point. We can introduce feature branches and pull requests when collaboration or more complex development workflows become relevant.&lt;/p&gt;




&lt;h2&gt;
  
  
  11. Milestone 1 – Final Verification
&lt;/h2&gt;

&lt;p&gt;Before moving into application development, we reviewed the project foundation.&lt;/p&gt;

&lt;p&gt;Our checklist:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[x] Designed the application architecture.&lt;/li&gt;
&lt;li&gt;[x] Defined the directory structure and responsibilities.&lt;/li&gt;
&lt;li&gt;[x] Selected Python 3.14.&lt;/li&gt;
&lt;li&gt;[x] Created and verified the &lt;code&gt;.venv&lt;/code&gt; environment.&lt;/li&gt;
&lt;li&gt;[x] Installed and configured uv.&lt;/li&gt;
&lt;li&gt;[x] Defined runtime and development dependencies.&lt;/li&gt;
&lt;li&gt;[x] Generated the &lt;code&gt;uv.lock&lt;/code&gt; file.&lt;/li&gt;
&lt;li&gt;[x] Reviewed and customized &lt;code&gt;.gitignore&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;[x] Established commit message conventions.&lt;/li&gt;
&lt;li&gt;[x] Updated the project README.&lt;/li&gt;
&lt;li&gt;[x] Committed the project foundation to GitHub.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At this point, we have completed &lt;strong&gt;Milestone 1 – Project Foundation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;We haven't implemented the weather endpoints yet. Instead, we've established the structure and tooling needed to implement them in a maintainable way.&lt;/p&gt;




&lt;h2&gt;
  
  
  12. What's Next?
&lt;/h2&gt;

&lt;p&gt;With the project foundation ready, we'll move to the next milestone:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Milestone 2 – FastAPI Application Bootstrap&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We'll begin implementing the actual application, covering:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Understanding the FastAPI application entry point.&lt;/li&gt;
&lt;li&gt;Creating and initializing the FastAPI application.&lt;/li&gt;
&lt;li&gt;Registering application routers.&lt;/li&gt;
&lt;li&gt;Implementing our first health-check endpoint.&lt;/li&gt;
&lt;li&gt;Running the application using Uvicorn.&lt;/li&gt;
&lt;li&gt;Exploring Swagger UI and the generated OpenAPI documentation.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;em&gt;This article is part of our ongoing FastAPI Weather API series. The project is being developed incrementally, with architecture, implementation decisions, setup steps, and Git changes documented along the way.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>backend</category>
      <category>python</category>
      <category>fastapi</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Building a Production-Ready FastAPI Project Structure: A Practical Weather Service Example</title>
      <dc:creator>Saras Growth Space</dc:creator>
      <pubDate>Sat, 05 Dec 2026 13:02:58 +0000</pubDate>
      <link>https://dev.to/saras_growth_space/building-a-production-ready-fastapi-project-structure-a-practical-weather-service-example-4iek</link>
      <guid>https://dev.to/saras_growth_space/building-a-production-ready-fastapi-project-structure-a-practical-weather-service-example-4iek</guid>
      <description>&lt;p&gt;When starting a FastAPI project, one of the first questions is:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How should we organize our application?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Should we have a &lt;code&gt;routers&lt;/code&gt; folder? Where should services and clients go? What is the difference between schemas, models, and domain objects? Why do some projects have multiple exception folders? And what exactly belongs in &lt;code&gt;core&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;These questions become more important as an application grows.&lt;/p&gt;

&lt;p&gt;Let's understand these concepts by designing a production-ready learning project: a &lt;strong&gt;Weather Service API using FastAPI and Open-Meteo&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;We will use Open-Meteo's free APIs to search for locations and retrieve current weather and forecast information.&lt;/p&gt;

&lt;p&gt;The objective is not to create the maximum number of folders. It is to understand the responsibility of each layer, why it exists, and how the layers communicate.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;1. First, understand what we are building&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Our application will expose the following endpoints:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Endpoint&lt;/th&gt;
&lt;th&gt;Responsibility&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /health&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Check whether our application is running&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /api/v1/locations/search&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Search for a city&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /api/v1/weather/current&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Retrieve current weather&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /api/v1/weather/forecast&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Retrieve weather forecasts&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Consider this request:&lt;/p&gt;

&lt;p&gt;A consumer calls our API to get the current weather in Delhi.&lt;/p&gt;

&lt;p&gt;Our application needs to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Accept the request.&lt;/li&gt;
&lt;li&gt;Validate the incoming parameters.&lt;/li&gt;
&lt;li&gt;Resolve the location into geographical coordinates.&lt;/li&gt;
&lt;li&gt;Call Open-Meteo's Forecast API.&lt;/li&gt;
&lt;li&gt;Convert the external response into our application's internal representation.&lt;/li&gt;
&lt;li&gt;Prepare a response for our API consumer.&lt;/li&gt;
&lt;li&gt;Return the result.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Notice something important: our application is communicating with another external service.&lt;/p&gt;

&lt;p&gt;We don't want our API endpoints to contain all the HTTP communication, data conversion, business logic, and error handling themselves.&lt;/p&gt;

&lt;p&gt;That's where a well-organized project structure helps.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;2. The proposed project structure&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's start with the structure we will use.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;weather-service/
│
├── app/
│   ├── main.py
│   │
│   ├── api/
│   │   ├── router.py
│   │   ├── dependencies/
│   │   │   └── weather.py
│   │   ├── routers/
│   │   │   └── health.py
│   │   └── v1/
│   │       ├── router.py
│   │       └── routers/
│   │           ├── weather.py
│   │           └── locations.py
│   │
│   ├── middleware/
│   │   ├── request_context.py
│   │   └── request_logging.py
│   │
│   ├── core/
│   │   ├── config.py
│   │   ├── lifespan.py
│   │   └── logging.py
│   │
│   ├── schemas/
│   │   ├── requests/
│   │   │   └── weather.py
│   │   ├── responses/
│   │   │   ├── weather.py
│   │   │   ├── location.py
│   │   │   └── common.py
│   │   └── errors.py
│   │
│   ├── domain/
│   │   ├── models/
│   │   │   ├── weather.py
│   │   │   └── location.py
│   │   ├── interfaces/
│   │   │   └── weather_provider.py
│   │   └── exceptions/
│   │       └── weather.py
│   │
│   ├── services/
│   │   ├── weather_service.py
│   │   └── location_service.py
│   │
│   ├── integrations/
│   │   └── open_meteo/
│   │       ├── provider.py
│   │       ├── geocoding_client.py
│   │       ├── forecast_client.py
│   │       ├── schemas/
│   │       │   ├── geocoding.py
│   │       │   └── forecast.py
│   │       ├── mapper.py
│   │       └── exceptions.py
│   │
│   ├── exceptions/
│   │   ├── application.py
│   │   └── handlers.py
│   │
│   └── observability/
│       ├── instrumentation.py
│       ├── metrics.py
│       └── tracing.py
│
├── tests/
│   ├── unit/
│   ├── integration/
│   └── contract/
│
├── .env.example
├── .gitignore
├── pyproject.toml
├── README.md
├── Dockerfile
└── docker-compose.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is our target structure, not a requirement to create every file before writing the first endpoint.&lt;/p&gt;

&lt;p&gt;Some files will become useful as we introduce more functionality.&lt;/p&gt;

&lt;p&gt;Now let's understand the responsibilities.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;3. &lt;code&gt;main.py&lt;/code&gt; — Where our application starts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;main.py&lt;/code&gt; is the entry point of our FastAPI application.&lt;/p&gt;

&lt;p&gt;Its responsibility is to create the FastAPI application and connect the major application components.&lt;/p&gt;

&lt;p&gt;For example, it brings together:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Application configuration.&lt;/li&gt;
&lt;li&gt;Application lifespan.&lt;/li&gt;
&lt;li&gt;Middleware.&lt;/li&gt;
&lt;li&gt;API routers.&lt;/li&gt;
&lt;li&gt;Exception handlers.&lt;/li&gt;
&lt;li&gt;Observability instrumentation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It should not contain weather-related business logic or direct calls to Open-Meteo.&lt;/p&gt;

&lt;p&gt;Think of &lt;code&gt;main.py&lt;/code&gt; as the place where we assemble the application, not where we implement its features.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;4. Why do we have &lt;code&gt;api/routers/&lt;/code&gt;, &lt;code&gt;api/v1/routers/&lt;/code&gt;, and multiple &lt;code&gt;router.py&lt;/code&gt; files?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is a common source of confusion.&lt;/p&gt;

&lt;p&gt;Let's understand the distinction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A. &lt;code&gt;api/v1/routers/&lt;/code&gt; — Individual endpoint groups&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We divide API endpoints according to their responsibility.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;weather.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Contains endpoints related to weather:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Current weather.&lt;/li&gt;
&lt;li&gt;Weather forecasts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;locations.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Contains endpoints related to locations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Search for a city.&lt;/li&gt;
&lt;li&gt;Retrieve location information.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each file defines routes belonging to a particular feature.&lt;/p&gt;

&lt;p&gt;Why not put everything in one &lt;code&gt;router.py&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;We could, but as the application grows, a single file containing dozens of unrelated endpoints becomes difficult to maintain.&lt;/p&gt;

&lt;p&gt;Separating routes by feature gives us a cleaner organization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;B. &lt;code&gt;api/v1/router.py&lt;/code&gt; — Aggregator for version 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If &lt;code&gt;weather.py&lt;/code&gt; and &lt;code&gt;locations.py&lt;/code&gt; already define routes, why do we need another &lt;code&gt;router.py&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;Because it serves a different purpose.&lt;/p&gt;

&lt;p&gt;It collects the individual routers and combines them into one versioned router.&lt;/p&gt;

&lt;p&gt;For example, conceptually:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Include the weather router.&lt;/li&gt;
&lt;li&gt;Include the locations router.&lt;/li&gt;
&lt;li&gt;Make them available under the version 1 API.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It doesn't implement the endpoints itself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C. &lt;code&gt;api/router.py&lt;/code&gt; — Application-level API aggregator&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This file combines the versioned API router with other API routers that should not be versioned.&lt;/p&gt;

&lt;p&gt;For example, our health endpoint.&lt;/p&gt;

&lt;p&gt;We may want:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/health&lt;/code&gt; for application health.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/api/v1/weather/current&lt;/code&gt; for the versioned weather API.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Health checks are generally infrastructure-facing endpoints rather than part of the versioned business API.&lt;/p&gt;

&lt;p&gt;This is why we keep &lt;code&gt;health.py&lt;/code&gt; under &lt;code&gt;api/routers/&lt;/code&gt;, outside &lt;code&gt;api/v1/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;D. &lt;code&gt;api/dependencies/weather.py&lt;/code&gt; — Providing dependencies to endpoints&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Suppose multiple endpoints need access to the same &lt;code&gt;WeatherService&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Should every endpoint create its own service and HTTP client?&lt;/p&gt;

&lt;p&gt;No.&lt;/p&gt;

&lt;p&gt;FastAPI provides dependency injection.&lt;/p&gt;

&lt;p&gt;This folder contains reusable dependency functions that provide things such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An initialized weather service.&lt;/li&gt;
&lt;li&gt;A provider implementation.&lt;/li&gt;
&lt;li&gt;Other shared objects required by API endpoints.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The dependency layer is responsible for providing dependencies, not implementing business logic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Remember the distinction:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;File/folder&lt;/th&gt;
&lt;th&gt;Responsibility&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;api/v1/routers/weather.py&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Defines weather endpoints&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;api/v1/routers/locations.py&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Defines location endpoints&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;api/v1/router.py&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Combines version 1 routers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;api/routers/health.py&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Defines health endpoints&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;api/router.py&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Combines application-level API routers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;api/dependencies/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Provides dependencies to endpoints&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;p&gt;&lt;strong&gt;5. Why do we need a separate &lt;code&gt;middleware/&lt;/code&gt; folder?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Middleware handles operations that apply across HTTP requests and responses.&lt;/p&gt;

&lt;p&gt;Imagine that every incoming request should have a correlation ID.&lt;/p&gt;

&lt;p&gt;We want to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Check whether the request already contains a correlation ID.&lt;/li&gt;
&lt;li&gt;Generate one if it doesn't.&lt;/li&gt;
&lt;li&gt;Make it available while processing the request.&lt;/li&gt;
&lt;li&gt;Include it in the response headers.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We don't want to repeat this logic in every endpoint.&lt;/p&gt;

&lt;p&gt;That's a good use case for middleware.&lt;/p&gt;

&lt;p&gt;Our proposed files:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;request_context.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Responsible for establishing request-specific context, such as correlation IDs.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;request_logging.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Responsible for logging information about incoming requests and outgoing responses.&lt;/p&gt;

&lt;p&gt;Other possible middleware responsibilities include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Security-related HTTP headers.&lt;/li&gt;
&lt;li&gt;Request/response processing.&lt;/li&gt;
&lt;li&gt;Cross-origin resource sharing configuration, where configured through middleware.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, not everything related to monitoring belongs in middleware.&lt;/p&gt;

&lt;p&gt;For example, measuring how long the Open-Meteo API takes to respond is better instrumented around the actual external HTTP call.&lt;/p&gt;

&lt;p&gt;Middleware observes the overall HTTP request lifecycle. Instrumentation around the provider call observes that particular operation.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;6. What belongs in &lt;code&gt;core/&lt;/code&gt;?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;core&lt;/code&gt; folder contains foundational application configuration and infrastructure setup.&lt;/p&gt;

&lt;p&gt;Our initial files are:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;config.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Contains application settings.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Application name.&lt;/li&gt;
&lt;li&gt;Environment: development, staging, production.&lt;/li&gt;
&lt;li&gt;External API base URLs.&lt;/li&gt;
&lt;li&gt;Request timeout configuration.&lt;/li&gt;
&lt;li&gt;Logging configuration values.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Environment-specific values should generally come from environment variables rather than being hardcoded.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;lifespan.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Handles application startup and shutdown.&lt;/p&gt;

&lt;p&gt;For example, our application may need a shared HTTPX client to communicate with Open-Meteo.&lt;/p&gt;

&lt;p&gt;We don't want to create a completely new client for every request unnecessarily.&lt;/p&gt;

&lt;p&gt;The application can initialize shared resources during startup and close them during shutdown.&lt;/p&gt;

&lt;p&gt;This is where FastAPI's lifespan mechanism becomes useful.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;logging.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Configures application logging.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Log format.&lt;/li&gt;
&lt;li&gt;Log levels.&lt;/li&gt;
&lt;li&gt;Structured logging configuration.&lt;/li&gt;
&lt;li&gt;Standard logging setup.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Then why not put middleware here?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Because these folders represent different responsibilities.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;core&lt;/code&gt; provides foundational configuration and setup.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;middleware&lt;/code&gt; contains HTTP request/response processing components.&lt;/p&gt;

&lt;p&gt;Both are application-wide, but they are not the same thing.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;7. Schemas vs models vs domain models — What is the difference?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is probably one of the most important distinctions in the entire structure.&lt;/p&gt;

&lt;p&gt;Let's understand it using our weather application.&lt;/p&gt;

&lt;p&gt;We have three different representations of data:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What our API consumer sends or receives.&lt;/li&gt;
&lt;li&gt;What Open-Meteo sends to us.&lt;/li&gt;
&lt;li&gt;How our application represents the information internally.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;They may contain similar fields, but they serve different purposes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A. &lt;code&gt;schemas/&lt;/code&gt; — Our API contracts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Schemas define the structure of data exchanged between our application and its API consumers.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;requests/weather.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Defines the expected request structure.&lt;/p&gt;

&lt;p&gt;For example, a request may contain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;City name.&lt;/li&gt;
&lt;li&gt;Number of forecast days.&lt;/li&gt;
&lt;li&gt;Units or other supported preferences.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;responses/weather.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Defines the weather response our application returns.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Location.&lt;/li&gt;
&lt;li&gt;Temperature.&lt;/li&gt;
&lt;li&gt;Weather condition.&lt;/li&gt;
&lt;li&gt;Humidity.&lt;/li&gt;
&lt;li&gt;Wind speed.&lt;/li&gt;
&lt;li&gt;Observation time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;responses/location.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Defines the structure returned by our location search endpoint.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;responses/common.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Contains reusable response structures shared by multiple response schemas.&lt;/p&gt;

&lt;p&gt;For example, if multiple endpoints return pagination metadata, we might define a reusable pagination structure here.&lt;/p&gt;

&lt;p&gt;But should &lt;code&gt;common.py&lt;/code&gt; always exist?&lt;/p&gt;

&lt;p&gt;No.&lt;/p&gt;

&lt;p&gt;Create it when there is genuinely reusable response data.&lt;/p&gt;

&lt;p&gt;If we have structures shared between both request and response schemas, we can consider a root-level &lt;code&gt;schemas/common.py&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We don't need that in our initial project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;B. Why &lt;code&gt;schemas/errors.py&lt;/code&gt;?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Because errors are also part of our public API contract.&lt;/p&gt;

&lt;p&gt;Suppose a consumer requests weather information for a city that cannot be found.&lt;/p&gt;

&lt;p&gt;Our API should return a predictable error response.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"code"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"LOCATION_NOT_FOUND"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"The requested location could not be found."&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;schemas/errors.py&lt;/code&gt; defines the structure of this response.&lt;/p&gt;

&lt;p&gt;It answers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What fields does an error response contain?&lt;/li&gt;
&lt;li&gt;Is there an error code?&lt;/li&gt;
&lt;li&gt;Is there a human-readable message?&lt;/li&gt;
&lt;li&gt;Should we include a request or correlation ID?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why not put this inside &lt;code&gt;responses/common.py&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;Because error responses have a distinct purpose and may have a different structure from successful responses.&lt;/p&gt;

&lt;p&gt;Keeping them in &lt;code&gt;errors.py&lt;/code&gt; makes that responsibility explicit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; &lt;code&gt;schemas/errors.py&lt;/code&gt; defines the error response format. It does not define the exceptions themselves or decide when they occur.&lt;/p&gt;

&lt;p&gt;We will cover that distinction shortly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C. What about schemas under &lt;code&gt;integrations/open_meteo/&lt;/code&gt;?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These represent a completely different contract.&lt;/p&gt;

&lt;p&gt;Our public API and Open-Meteo do not necessarily exchange the same data structure.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;Our consumer might send:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"city"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Delhi"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our application resolves the city through Open-Meteo's Geocoding API.&lt;/p&gt;

&lt;p&gt;The external provider returns its own structure containing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Location name.&lt;/li&gt;
&lt;li&gt;Latitude.&lt;/li&gt;
&lt;li&gt;Longitude.&lt;/li&gt;
&lt;li&gt;Country.&lt;/li&gt;
&lt;li&gt;Other geographical information.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Forecast API has another response structure containing current, hourly, or daily weather information.&lt;/p&gt;

&lt;p&gt;We should not assume that Open-Meteo's response format is the same as our public API response format.&lt;/p&gt;

&lt;p&gt;That's why we keep:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;integrations/open_meteo/schemas/geocoding.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Defines the provider response structure used by our geocoding integration.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;integrations/open_meteo/schemas/forecast.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Defines the provider response structure used by our forecast integration.&lt;/p&gt;

&lt;p&gt;This separation protects our application from becoming tightly coupled to the external provider's response format.&lt;/p&gt;

&lt;p&gt;If Open-Meteo changes its response structure, ideally we only need to update the integration and mapping logic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;D. Then what are &lt;code&gt;domain/models/&lt;/code&gt;?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Domain models represent the concepts our application understands internally.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;domain/models/location.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;May represent a location using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Name.&lt;/li&gt;
&lt;li&gt;Latitude.&lt;/li&gt;
&lt;li&gt;Longitude.&lt;/li&gt;
&lt;li&gt;Country.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;domain/models/weather.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;May represent weather information using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Temperature.&lt;/li&gt;
&lt;li&gt;Humidity.&lt;/li&gt;
&lt;li&gt;Wind speed.&lt;/li&gt;
&lt;li&gt;Weather condition.&lt;/li&gt;
&lt;li&gt;Observation time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These models should represent our application's concepts, not simply copy an external API response.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A simple comparison&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Location&lt;/th&gt;
&lt;th&gt;What it represents&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;schemas/requests/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;What our API accepts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;schemas/responses/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;What our API returns&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;schemas/errors.py&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;What our API returns when something goes wrong&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;integrations/open_meteo/schemas/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;What we receive from Open-Meteo&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;domain/models/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;How our application represents information internally&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;One more important point: domain models do not have to be Pydantic models. We can use dataclasses or other appropriate representations depending on our requirements.&lt;/p&gt;

&lt;p&gt;Similarly, if we later introduce a database, database models will represent persistence structures. They should not automatically become our API schemas or domain models.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The principle is simple: similar data does not mean identical responsibility.&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;8. Understanding &lt;code&gt;domain/&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The domain layer represents the concepts and rules that belong to our application.&lt;/p&gt;

&lt;p&gt;Our weather application may initially seem simple, but it still has concepts such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Weather.&lt;/li&gt;
&lt;li&gt;Location.&lt;/li&gt;
&lt;li&gt;Weather provider.&lt;/li&gt;
&lt;li&gt;Weather data availability.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Our proposed domain structure contains three areas.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;models/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Contains internal representations of our business concepts.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;interfaces/weather_provider.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Defines the expected behaviour of a weather provider.&lt;/p&gt;

&lt;p&gt;For example, our application needs a provider that can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Search for locations.&lt;/li&gt;
&lt;li&gt;Retrieve current weather.&lt;/li&gt;
&lt;li&gt;Retrieve forecasts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why define an interface?&lt;/p&gt;

&lt;p&gt;Because our application should depend on what a weather provider can do, rather than being tightly coupled to one specific provider.&lt;/p&gt;

&lt;p&gt;Today, we use Open-Meteo.&lt;/p&gt;

&lt;p&gt;Tomorrow, we might decide to use another weather provider.&lt;/p&gt;

&lt;p&gt;The service should not need to understand the provider's HTTP endpoints or response formats.&lt;/p&gt;

&lt;p&gt;The interface defines the expected operations, and the integration implements them.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;exceptions/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Contains domain-specific exceptions.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;LocationNotFoundError&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;WeatherDataUnavailableError&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These represent situations meaningful to our application.&lt;/p&gt;

&lt;p&gt;They should not depend on HTTP status codes or FastAPI.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;9. Why do we have exceptions in multiple locations?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We now have three exception-related locations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;domain/exceptions/&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;integrations/open_meteo/exceptions.py&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;app/exceptions/&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Are we duplicating the same thing?&lt;/p&gt;

&lt;p&gt;No. They represent different responsibilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A. Domain exceptions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These represent problems meaningful to our application's domain.&lt;/p&gt;

&lt;p&gt;For example, the requested location does not exist.&lt;/p&gt;

&lt;p&gt;This is a meaningful application-level outcome, regardless of which provider we use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;B. Integration exceptions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These represent failures while communicating with an external provider.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open-Meteo request timed out.&lt;/li&gt;
&lt;li&gt;Open-Meteo is unavailable.&lt;/li&gt;
&lt;li&gt;Open-Meteo returned an invalid response.&lt;/li&gt;
&lt;li&gt;The provider rejected a request due to its limits.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The integration layer can translate low-level HTTPX exceptions and provider-specific errors into meaningful integration exceptions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C. Application exceptions and handlers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;exceptions/application.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Contains application-level exception definitions when we need them.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;exceptions/handlers.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Contains FastAPI exception handlers that translate exceptions into HTTP responses.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Situation&lt;/th&gt;
&lt;th&gt;Possible HTTP status&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Location not found&lt;/td&gt;
&lt;td&gt;404&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Invalid API request&lt;/td&gt;
&lt;td&gt;422&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;External provider timeout&lt;/td&gt;
&lt;td&gt;504&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;External provider unavailable&lt;/td&gt;
&lt;td&gt;503&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Unexpected internal error&lt;/td&gt;
&lt;td&gt;500&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The exact mapping depends on the API contract and the meaning of the failure.&lt;/p&gt;

&lt;p&gt;For example, we should not blindly convert every provider error into a 503.&lt;/p&gt;

&lt;p&gt;A provider timeout, rate limit, and invalid response may need different handling.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where does &lt;code&gt;schemas/errors.py&lt;/code&gt; fit into this?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's connect the responsibilities:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A domain or integration exception occurs.&lt;/li&gt;
&lt;li&gt;The exception propagates to the application boundary.&lt;/li&gt;
&lt;li&gt;A registered exception handler determines the appropriate HTTP status and error code.&lt;/li&gt;
&lt;li&gt;The handler creates a response matching the structure defined in &lt;code&gt;schemas/errors.py&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The API consumer receives a predictable error response.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Exceptions represent failures.&lt;/li&gt;
&lt;li&gt;Handlers decide how to translate them into HTTP responses.&lt;/li&gt;
&lt;li&gt;Error schemas define the structure of those responses.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are three related but different responsibilities.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;10. &lt;code&gt;services/&lt;/code&gt; vs &lt;code&gt;integrations/&lt;/code&gt; — Another important distinction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Suppose we receive a request for current weather in Delhi.&lt;/p&gt;

&lt;p&gt;Which component should decide what needs to happen?&lt;/p&gt;

&lt;p&gt;And which component should actually call Open-Meteo?&lt;/p&gt;

&lt;p&gt;These are different responsibilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A. &lt;code&gt;services/&lt;/code&gt; — Application operations and orchestration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;weather_service.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Coordinates the steps required to retrieve weather information.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Receive a location.&lt;/li&gt;
&lt;li&gt;Obtain its coordinates if necessary.&lt;/li&gt;
&lt;li&gt;Ask the weather provider for current weather.&lt;/li&gt;
&lt;li&gt;Apply application-level rules.&lt;/li&gt;
&lt;li&gt;Return the result in an internal representation.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;location_service.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Coordinates location-related operations.&lt;/p&gt;

&lt;p&gt;For example, searching for a city and returning normalized location information.&lt;/p&gt;

&lt;p&gt;Services should not contain the details of constructing Open-Meteo URLs or parsing its raw HTTP response.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;B. &lt;code&gt;integrations/&lt;/code&gt; — Communication with external systems&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Our external dependency is Open-Meteo.&lt;/p&gt;

&lt;p&gt;We use two separate API clients because Geocoding and Forecast are distinct external APIs with different responsibilities and response formats.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;geocoding_client.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Communicates with Open-Meteo's Geocoding API.&lt;/p&gt;

&lt;p&gt;Its responsibility is to send requests and retrieve location information.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;forecast_client.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Communicates with Open-Meteo's Forecast API.&lt;/p&gt;

&lt;p&gt;Its responsibility is to retrieve current and forecast weather data.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;provider.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Combines the clients into an implementation of our &lt;code&gt;WeatherProvider&lt;/code&gt; interface.&lt;/p&gt;

&lt;p&gt;In other words, it acts as an adapter between our application's expected provider operations and Open-Meteo's actual APIs.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mapper.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Converts external provider data into our application's internal models.&lt;/p&gt;

&lt;p&gt;This is particularly useful for weather responses where data may contain arrays of timestamps and corresponding values.&lt;/p&gt;

&lt;p&gt;For example, hourly timestamps and temperatures need to be mapped correctly into our internal representation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A practical comparison&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Main responsibility&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Router&lt;/td&gt;
&lt;td&gt;Receives and handles API requests&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Service&lt;/td&gt;
&lt;td&gt;Coordinates application operations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Provider&lt;/td&gt;
&lt;td&gt;Implements the weather provider interface&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Client&lt;/td&gt;
&lt;td&gt;Performs external HTTP communication&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mapper&lt;/td&gt;
&lt;td&gt;Converts external data into internal models&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A useful way to remember this:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The service decides what needs to happen. The integration knows how to communicate with the external provider.&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;11. Why don't we have a &lt;code&gt;repositories/&lt;/code&gt; folder?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You might have noticed that many FastAPI project structures contain a &lt;code&gt;repositories/&lt;/code&gt; folder.&lt;/p&gt;

&lt;p&gt;We have deliberately omitted it.&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Repositories are generally used to abstract data persistence.&lt;/p&gt;

&lt;p&gt;For example, if our weather application later stores:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Favourite locations.&lt;/li&gt;
&lt;li&gt;User preferences.&lt;/li&gt;
&lt;li&gt;Historical weather records.&lt;/li&gt;
&lt;li&gt;Cached weather information.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We might introduce a database.&lt;/p&gt;

&lt;p&gt;At that point, we could create:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;repositories/weather_repository.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;repositories/location_repository.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;These components would abstract database operations from the application services.&lt;/p&gt;

&lt;p&gt;But our current application retrieves information from Open-Meteo and returns it to the consumer.&lt;/p&gt;

&lt;p&gt;We don't need a repository just to call an external API.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;External API communication is not the same thing as database persistence.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's why we have &lt;code&gt;integrations/&lt;/code&gt;, not &lt;code&gt;repositories/&lt;/code&gt;, for our current use case.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;12. What belongs in &lt;code&gt;observability/&lt;/code&gt;?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A production-ready application needs more than successful API responses.&lt;/p&gt;

&lt;p&gt;We need to understand what is happening inside it.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How many requests are arriving?&lt;/li&gt;
&lt;li&gt;How long does each request take?&lt;/li&gt;
&lt;li&gt;How long does Open-Meteo take to respond?&lt;/li&gt;
&lt;li&gt;How many external requests fail?&lt;/li&gt;
&lt;li&gt;Are there unexpected application errors?&lt;/li&gt;
&lt;li&gt;Which operations are responsible for increased latency?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Our proposed files:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;instrumentation.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Initializes or coordinates observability instrumentation.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;metrics.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Defines or configures application metrics.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Request count.&lt;/li&gt;
&lt;li&gt;Request duration.&lt;/li&gt;
&lt;li&gt;Provider request duration.&lt;/li&gt;
&lt;li&gt;Provider failure count.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;tracing.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Supports distributed tracing and the propagation of trace context across operations.&lt;/p&gt;

&lt;p&gt;For our learning project, we can later introduce OpenTelemetry, Prometheus, Grafana, Loki, and Tempo as appropriate.&lt;/p&gt;

&lt;p&gt;Remember that logging, metrics, and tracing answer different questions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Logs tell us what happened.&lt;/li&gt;
&lt;li&gt;Metrics tell us how much or how often something happened.&lt;/li&gt;
&lt;li&gt;Traces tell us how an operation travelled through different components.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We can start with structured logs and gradually introduce the other observability components.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;13. What about &lt;code&gt;security.py&lt;/code&gt;?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You might have expected a &lt;code&gt;security.py&lt;/code&gt; file under &lt;code&gt;core/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We haven't included one yet.&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Our application will call Open-Meteo's free API, which does not require an API key for this use case.&lt;/p&gt;

&lt;p&gt;We don't need to introduce an outbound API-key management layer unnecessarily.&lt;/p&gt;

&lt;p&gt;However, we may later need to secure our own FastAPI application.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User authentication.&lt;/li&gt;
&lt;li&gt;JWT validation.&lt;/li&gt;
&lt;li&gt;API-key authentication for our consumers.&lt;/li&gt;
&lt;li&gt;Authorization rules.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At that point, we can introduce security dependencies and supporting configuration.&lt;/p&gt;

&lt;p&gt;Security is important, but the project structure should reflect actual requirements rather than contain empty files for hypothetical features.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;14. Understanding &lt;code&gt;tests/&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Testing should be organized around the responsibility being tested.&lt;/p&gt;

&lt;p&gt;Our proposed structure:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;tests/unit/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Tests individual components in isolation.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Weather service behaviour.&lt;/li&gt;
&lt;li&gt;Location service behaviour.&lt;/li&gt;
&lt;li&gt;Mapper transformations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;External dependencies should generally be mocked in unit tests.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;tests/integration/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Tests whether multiple components work together.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;API endpoint calling the service.&lt;/li&gt;
&lt;li&gt;Service working with the provider adapter.&lt;/li&gt;
&lt;li&gt;HTTP client integration with a mocked external HTTP response.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;tests/contract/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Tests assumptions about external or internal contracts.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Whether our Open-Meteo response parsing matches representative provider payloads.&lt;/li&gt;
&lt;li&gt;Whether our public API response continues to match its documented structure.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We should not depend on a live external API for every test. Controlled fixtures and mocked responses make tests more predictable.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;conftest.py&lt;/code&gt; can provide reusable pytest fixtures.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;15. What is &lt;code&gt;pyproject.toml&lt;/code&gt; and why do we need it?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Unlike the folders under &lt;code&gt;app/&lt;/code&gt;, &lt;code&gt;pyproject.toml&lt;/code&gt; is not an application architecture component.&lt;/p&gt;

&lt;p&gt;It is a Python project configuration file.&lt;/p&gt;

&lt;p&gt;It can contain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Project metadata.&lt;/li&gt;
&lt;li&gt;Python version requirements.&lt;/li&gt;
&lt;li&gt;Runtime dependencies.&lt;/li&gt;
&lt;li&gt;Development dependencies.&lt;/li&gt;
&lt;li&gt;Build configuration.&lt;/li&gt;
&lt;li&gt;Tool configurations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For our project, dependencies might include:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Dependency&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;FastAPI&lt;/td&gt;
&lt;td&gt;API framework&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Uvicorn&lt;/td&gt;
&lt;td&gt;ASGI server&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HTTPX&lt;/td&gt;
&lt;td&gt;External HTTP communication&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pydantic Settings&lt;/td&gt;
&lt;td&gt;Application configuration&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pytest&lt;/td&gt;
&lt;td&gt;Testing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ruff&lt;/td&gt;
&lt;td&gt;Linting and formatting&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Why not use &lt;code&gt;requirements.txt&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;We can. It is still a perfectly valid option.&lt;/p&gt;

&lt;p&gt;However, &lt;code&gt;pyproject.toml&lt;/code&gt; provides a standardized place for project metadata and configuration used by modern Python packaging and development tools.&lt;/p&gt;

&lt;p&gt;As our project grows, we can keep dependency management and tool configuration organized in one place.&lt;/p&gt;

&lt;p&gt;It is a useful choice, not a mandatory requirement.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;16. What about the remaining root-level files?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These files support development, deployment, and project maintenance.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;.env.example&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Documents the environment variables required to run the application.&lt;/p&gt;

&lt;p&gt;It should contain example or placeholder values, never actual secrets.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;.gitignore&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Specifies files and folders Git should ignore.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;.env&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__pycache__/&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Virtual environment directories.&lt;/li&gt;
&lt;li&gt;Test and coverage artifacts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;README.md&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Explains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What the application does.&lt;/li&gt;
&lt;li&gt;How to install dependencies.&lt;/li&gt;
&lt;li&gt;How to run it.&lt;/li&gt;
&lt;li&gt;Available endpoints.&lt;/li&gt;
&lt;li&gt;Configuration.&lt;/li&gt;
&lt;li&gt;How to execute tests.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;Dockerfile&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Defines how to package our application into a Docker image.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker-compose.yml&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Helps run the application and supporting services together during development.&lt;/p&gt;

&lt;p&gt;For example, we might later use it to run the application alongside monitoring services.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;17. Let's connect everything: One request, multiple layers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We now understand the purpose of individual folders.&lt;/p&gt;

&lt;p&gt;But how do they work together?&lt;/p&gt;

&lt;p&gt;Let's follow a request:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;GET /api/v1/weather/current?city=Delhi&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The conceptual flow is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Middleware:&lt;/strong&gt; Request context is established, and request logging begins.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Router:&lt;/strong&gt; &lt;code&gt;api/v1/routers/weather.py&lt;/code&gt; receives the request.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validation:&lt;/strong&gt; The request is validated against our API request schema.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dependency injection:&lt;/strong&gt; The router receives an initialized &lt;code&gt;WeatherService&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Service:&lt;/strong&gt; &lt;code&gt;weather_service.py&lt;/code&gt; coordinates the operation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Provider:&lt;/strong&gt; The service uses the &lt;code&gt;WeatherProvider&lt;/code&gt; abstraction.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integration:&lt;/strong&gt; &lt;code&gt;open_meteo/provider.py&lt;/code&gt; coordinates the external API calls.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clients:&lt;/strong&gt; &lt;code&gt;geocoding_client.py&lt;/code&gt; resolves Delhi's coordinates, and &lt;code&gt;forecast_client.py&lt;/code&gt; retrieves weather information.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mapper:&lt;/strong&gt; &lt;code&gt;mapper.py&lt;/code&gt; converts external response data into internal domain models.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Service:&lt;/strong&gt; The service returns the application-level result.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Response schema:&lt;/strong&gt; The API layer prepares the public response using &lt;code&gt;schemas/responses/weather.py&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Middleware:&lt;/strong&gt; Request processing finishes, and response logging is completed.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If an error occurs, the relevant exception propagates to the application exception-handling layer.&lt;/p&gt;

&lt;p&gt;The registered handler translates it into an HTTP response using the structure defined in &lt;code&gt;schemas/errors.py&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Observability instrumentation records the relevant request and operation information along the way.&lt;/p&gt;

&lt;p&gt;This is how the different parts of the application cooperate without every component knowing the implementation details of every other component.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;18. Should we create all these folders from Day 1?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No.&lt;/p&gt;

&lt;p&gt;This is a production-oriented target structure for our learning project. We should introduce components when their responsibilities become relevant.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Stage&lt;/th&gt;
&lt;th&gt;What we introduce&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Initial API&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;main.py&lt;/code&gt;, routers, schemas&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;External API communication&lt;/td&gt;
&lt;td&gt;Clients, integrations, services&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Better separation&lt;/td&gt;
&lt;td&gt;Domain models, interfaces, mappers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Application lifecycle&lt;/td&gt;
&lt;td&gt;Configuration and lifespan&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reliability&lt;/td&gt;
&lt;td&gt;Exception handling, timeouts, retries&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Production visibility&lt;/td&gt;
&lt;td&gt;Middleware and observability&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Deployment&lt;/td&gt;
&lt;td&gt;Docker and environment configuration&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Automated quality&lt;/td&gt;
&lt;td&gt;Unit, integration, and contract tests&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;We don't need a database, repository layer, Redis, Celery, Kafka, or Kubernetes just to build this weather service.&lt;/p&gt;

&lt;p&gt;Those technologies solve specific problems. We should introduce them when the application has a requirement that justifies them.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;19. Final architectural summary&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's consolidate the most important distinctions:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Question it answers&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;main.py&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;How is the application assembled?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;api/routers/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Which HTTP endpoints do we expose?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;api/dependencies/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;How are endpoint dependencies provided?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;middleware/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;What should happen across HTTP requests and responses?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;core/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;What foundational configuration and lifecycle setup do we need?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;schemas/requests/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;What can consumers send?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;schemas/responses/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;What do consumers receive?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;schemas/errors.py&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;What does an API error response look like?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;domain/models/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;What concepts does our application understand?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;domain/interfaces/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;What behaviour does our application expect from external capabilities?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;services/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;How do we coordinate application operations?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;integrations/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;How do we communicate with external systems?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;exceptions/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;How do we handle and translate application errors?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;observability/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;How do we understand application behaviour?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;repositories/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;How do we abstract persistence, when a database exists?&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The most important takeaway is that &lt;strong&gt;project structure is about responsibility and boundaries, not the number of folders.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A router should not become a service. A service should not become an HTTP client. A provider response schema should not become our public API contract. And an exception handler should not become the place where every business error is defined.&lt;/p&gt;

&lt;p&gt;Once these boundaries are clear, extending the application becomes much easier.&lt;/p&gt;

&lt;p&gt;We now have a solid architectural baseline for building our FastAPI weather service using Open-Meteo, and we can introduce each component while implementing the actual application rather than treating the folder structure as an end in itself.&lt;/p&gt;

</description>
      <category>backend</category>
      <category>fastapi</category>
      <category>python</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Understanding Observability: Grafana, Prometheus, Loki, Sentry, Splunk, Tempo &amp; OpenTelemetry Explained</title>
      <dc:creator>Saras Growth Space</dc:creator>
      <pubDate>Sat, 05 Dec 2026 10:31:30 +0000</pubDate>
      <link>https://dev.to/saras_growth_space/understanding-observability-grafana-prometheus-loki-sentry-splunk-tempo-opentelemetry-2j45</link>
      <guid>https://dev.to/saras_growth_space/understanding-observability-grafana-prometheus-loki-sentry-splunk-tempo-opentelemetry-2j45</guid>
      <description>&lt;p&gt;If you've ever come across Grafana, Prometheus, Loki, Sentry, Splunk, Tempo and OpenTelemetry while learning backend development or system design, you might have wondered:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Are these tools doing the same thing?&lt;/li&gt;
&lt;li&gt;Why do we need so many monitoring tools?&lt;/li&gt;
&lt;li&gt;Can Grafana display everything?&lt;/li&gt;
&lt;li&gt;If Loki stores error logs, why do we need Sentry?&lt;/li&gt;
&lt;li&gt;What exactly is distributed tracing?&lt;/li&gt;
&lt;li&gt;What is the difference between a trace and a span?&lt;/li&gt;
&lt;li&gt;Is OpenTelemetry another monitoring tool?&lt;/li&gt;
&lt;li&gt;Where does all of this fit into system design?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are reasonable questions because these technologies are closely related, but they don't have the same responsibilities.&lt;/p&gt;

&lt;p&gt;The easiest way to understand them is to stop looking at them as individual tools and first understand the problem they are trying to solve.&lt;/p&gt;

&lt;p&gt;Let's start from the beginning.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. The Problem: What Happens After We Deploy Our Application?
&lt;/h2&gt;

&lt;p&gt;Imagine that we have developed an e-commerce application.&lt;/p&gt;

&lt;p&gt;It contains multiple services:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;API Gateway&lt;/li&gt;
&lt;li&gt;Order Service&lt;/li&gt;
&lt;li&gt;Payment Service&lt;/li&gt;
&lt;li&gt;Inventory Service&lt;/li&gt;
&lt;li&gt;User Service&lt;/li&gt;
&lt;li&gt;Database&lt;/li&gt;
&lt;li&gt;External Payment Gateway&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Everything works perfectly during development. We test our APIs, verify the business logic and deploy the application to production.&lt;/p&gt;

&lt;p&gt;Now imagine the following situations:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The payment API suddenly starts taking 8 seconds instead of 500 milliseconds.&lt;/li&gt;
&lt;li&gt;Some customers are unable to complete their orders.&lt;/li&gt;
&lt;li&gt;The Order Service starts returning HTTP 500 errors.&lt;/li&gt;
&lt;li&gt;Database CPU utilisation reaches 95%.&lt;/li&gt;
&lt;li&gt;The application is running, but customers are complaining that it is extremely slow.&lt;/li&gt;
&lt;li&gt;A request travels through five microservices, but we don't know which service caused the delay.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As developers, we need answers.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is the application healthy?&lt;/li&gt;
&lt;li&gt;How many requests are coming in?&lt;/li&gt;
&lt;li&gt;Which service is failing?&lt;/li&gt;
&lt;li&gt;What exactly happened during a failed request?&lt;/li&gt;
&lt;li&gt;Where did the request spend most of its time?&lt;/li&gt;
&lt;li&gt;Did a recent deployment introduce a problem?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Checking the source code manually every time something goes wrong is not a practical solution.&lt;/p&gt;

&lt;p&gt;We need a way to understand what is happening inside our running application.&lt;/p&gt;

&lt;p&gt;This is where &lt;strong&gt;Observability&lt;/strong&gt; comes in.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. What Is Observability?
&lt;/h2&gt;

&lt;p&gt;Observability is the ability to understand the internal state of a system by examining the information it produces.&lt;/p&gt;

&lt;p&gt;In simple words:&lt;/p&gt;

&lt;p&gt;Our application should provide enough information for us to understand what is happening inside it, especially when something goes wrong.&lt;/p&gt;

&lt;p&gt;Observability is commonly understood through three commonly used types of telemetry, often called the three pillars of observability.:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Metrics&lt;/li&gt;
&lt;li&gt;Logs&lt;/li&gt;
&lt;li&gt;Traces&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's understand each one.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.1 Metrics — What Is Happening?
&lt;/h3&gt;

&lt;p&gt;Metrics are numerical measurements collected over time.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CPU utilisation: 85%&lt;/li&gt;
&lt;li&gt;Memory utilisation: 70%&lt;/li&gt;
&lt;li&gt;Requests per minute: 15,000&lt;/li&gt;
&lt;li&gt;Error rate: 5%&lt;/li&gt;
&lt;li&gt;Average API latency: 800 milliseconds&lt;/li&gt;
&lt;li&gt;Active database connections: 150&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Suppose we collect CPU utilisation every five minutes.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Time&lt;/th&gt;
&lt;th&gt;CPU utilisation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;10:00&lt;/td&gt;
&lt;td&gt;35%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10:05&lt;/td&gt;
&lt;td&gt;40%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10:10&lt;/td&gt;
&lt;td&gt;65%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10:15&lt;/td&gt;
&lt;td&gt;95%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;We can now identify when CPU utilisation started increasing.&lt;/p&gt;

&lt;p&gt;Metrics help answer questions such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is the application receiving more traffic than usual?&lt;/li&gt;
&lt;li&gt;Is the error rate increasing?&lt;/li&gt;
&lt;li&gt;Is the server running out of memory?&lt;/li&gt;
&lt;li&gt;Is API latency increasing?&lt;/li&gt;
&lt;li&gt;How many requests are being processed?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Think of metrics as the numerical health measurements of your application.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.2 Logs — What Exactly Happened?
&lt;/h3&gt;

&lt;p&gt;Logs are records of events occurring inside an application or infrastructure.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10:00:01 INFO Order request received
10:00:02 INFO Payment initiated
10:00:03 WARN Payment retry initiated
10:00:04 ERROR Payment gateway timeout
10:00:04 ERROR Order creation failed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Logs provide contextual information about individual events.&lt;/p&gt;

&lt;p&gt;They help answer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What happened?&lt;/li&gt;
&lt;li&gt;Which operation failed?&lt;/li&gt;
&lt;li&gt;What error occurred?&lt;/li&gt;
&lt;li&gt;What was happening immediately before the failure?&lt;/li&gt;
&lt;li&gt;What did the application record during a particular time period?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Unlike metrics, logs can contain descriptive information and application-specific context.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.3 Traces — Where Did a Request Travel?
&lt;/h3&gt;

&lt;p&gt;This is particularly important in microservices architecture.&lt;/p&gt;

&lt;p&gt;Imagine a customer places an order.&lt;/p&gt;

&lt;p&gt;Internally, the request travels through:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Customer
   |
   v
API Gateway
   |
   v
Order Service
   |
   v
Payment Service
   |
   v
Inventory Service
   |
   v
Database
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The customer sees only one action: placing an order.&lt;/p&gt;

&lt;p&gt;However, multiple services participate in completing that action.&lt;/p&gt;

&lt;p&gt;A trace follows this individual request across the services it visits.&lt;/p&gt;

&lt;p&gt;It records the operations performed and how much time each operation takes.&lt;/p&gt;

&lt;p&gt;Traces help answer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which services participated in this request?&lt;/li&gt;
&lt;li&gt;Which operation took the most time?&lt;/li&gt;
&lt;li&gt;Where did the request fail?&lt;/li&gt;
&lt;li&gt;Which downstream service caused the delay?&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Difference Between Metrics, Logs and Traces
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Concept&lt;/th&gt;
&lt;th&gt;Primary question&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Metrics&lt;/td&gt;
&lt;td&gt;How much? How often? How slow?&lt;/td&gt;
&lt;td&gt;API latency is 2 seconds&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Logs&lt;/td&gt;
&lt;td&gt;What exactly happened?&lt;/td&gt;
&lt;td&gt;Payment gateway returned a timeout&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Traces&lt;/td&gt;
&lt;td&gt;Where did the request travel?&lt;/td&gt;
&lt;td&gt;Payment Service consumed 1.5 seconds&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These three concepts are the foundation of observability.&lt;/p&gt;

&lt;p&gt;Now let's understand the tools built around them.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Prometheus — Metrics Collection and Monitoring
&lt;/h2&gt;

&lt;p&gt;Prometheus is an open-source monitoring and metrics collection system.&lt;/p&gt;

&lt;p&gt;Its primary responsibility is to collect and store numerical measurements from applications and infrastructure.&lt;/p&gt;

&lt;p&gt;Suppose our application exposes the following metrics:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http_requests_total = 15000
http_errors_total = 250
cpu_usage = 85%
memory_usage = 70%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Prometheus periodically collects these metrics and stores them as time-series data.&lt;/p&gt;

&lt;p&gt;Time-series data means that measurements are associated with timestamps.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Time&lt;/th&gt;
&lt;th&gt;Requests per minute&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;10:00&lt;/td&gt;
&lt;td&gt;1,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10:05&lt;/td&gt;
&lt;td&gt;1,500&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10:10&lt;/td&gt;
&lt;td&gt;2,500&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10:15&lt;/td&gt;
&lt;td&gt;5,000&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;We can now analyse how application traffic changes over time.&lt;/p&gt;

&lt;p&gt;Prometheus commonly follows a pull-based model.&lt;/p&gt;

&lt;p&gt;This means Prometheus periodically scrapes metrics from configured endpoints exposed by applications or infrastructure.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FastAPI Application
        |
        v
   /metrics endpoint
        |
        v
    Prometheus
        |
        v
 Metrics Storage
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Prometheus helps monitor:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Request counts&lt;/li&gt;
&lt;li&gt;Error rates&lt;/li&gt;
&lt;li&gt;API latency&lt;/li&gt;
&lt;li&gt;CPU utilisation&lt;/li&gt;
&lt;li&gt;Memory utilisation&lt;/li&gt;
&lt;li&gt;Database connections&lt;/li&gt;
&lt;li&gt;Application throughput&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Remember:&lt;/strong&gt; Prometheus primarily deals with metrics, not general application logs or distributed trace storage.&lt;/p&gt;

&lt;p&gt;Official website: &lt;a href="https://prometheus.io/" rel="noopener noreferrer"&gt;https://prometheus.io/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Grafana — Visualisation and Dashboards
&lt;/h2&gt;

&lt;p&gt;Grafana is an open-source observability and visualisation platform.&lt;/p&gt;

&lt;p&gt;Let's say Prometheus has collected thousands of measurements.&lt;/p&gt;

&lt;p&gt;How do we conveniently understand them?&lt;/p&gt;

&lt;p&gt;We could write queries and inspect the results manually, but that isn't convenient when monitoring an entire production system.&lt;/p&gt;

&lt;p&gt;Grafana solves this problem by connecting to different data sources and presenting their information through dashboards.&lt;/p&gt;

&lt;p&gt;For example, we can create a dashboard showing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CPU utilisation&lt;/li&gt;
&lt;li&gt;Memory utilisation&lt;/li&gt;
&lt;li&gt;Requests per second&lt;/li&gt;
&lt;li&gt;API response time&lt;/li&gt;
&lt;li&gt;Error percentage&lt;/li&gt;
&lt;li&gt;Database connections&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Grafana can connect to multiple data sources, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prometheus for metrics&lt;/li&gt;
&lt;li&gt;Loki for logs&lt;/li&gt;
&lt;li&gt;Tempo for traces&lt;/li&gt;
&lt;li&gt;Other databases and observability systems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This brings us to an important distinction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prometheus collects and stores metrics. Grafana visualises and explores data from connected sources.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Grafana does not automatically collect and store everything just because we have installed it.&lt;/p&gt;

&lt;p&gt;We need to configure the appropriate data sources.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                 GRAFANA
             (Dashboards)
                   |
          +--------+--------+
          |        |        |
          v        v        v
      Prometheus  Loki    Tempo
       Metrics    Logs    Traces
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Grafana can also correlate these sources.&lt;/p&gt;

&lt;p&gt;For example, we notice an increase in API latency on a dashboard. We can investigate related logs and traces to understand the reason.&lt;/p&gt;

&lt;p&gt;What about Sentry?&lt;/p&gt;

&lt;p&gt;Grafana can also integrate with Sentry through supported integrations or plugins, depending on the setup. However, it is not automatically a universal viewer for every Sentry event.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Remember:&lt;/strong&gt; Grafana is primarily the visualisation and exploration layer, not a replacement for the systems that collect and store the data.&lt;/p&gt;

&lt;p&gt;Official website: &lt;a href="https://grafana.com/" rel="noopener noreferrer"&gt;https://grafana.com/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Loki — Log Aggregation and Storage
&lt;/h2&gt;

&lt;p&gt;Now let's understand logs in a distributed application.&lt;/p&gt;

&lt;p&gt;Imagine we have 30 microservices.&lt;/p&gt;

&lt;p&gt;Each service generates logs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Order Service:
INFO Order request received

Payment Service:
INFO Payment initiated

Payment Service:
ERROR Payment gateway timeout

Inventory Service:
INFO Stock updated
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If these services run on different servers or containers, finding their logs individually becomes difficult.&lt;/p&gt;

&lt;p&gt;We need a central place to collect and search logs.&lt;/p&gt;

&lt;p&gt;This is where Loki comes in.&lt;/p&gt;

&lt;p&gt;Loki is an open-source log aggregation system developed by Grafana Labs.&lt;/p&gt;

&lt;p&gt;It collects and stores logs from different applications and infrastructure so that developers can search and investigate them centrally.&lt;/p&gt;

&lt;p&gt;For example, we can search for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All ERROR logs from Payment Service.&lt;/li&gt;
&lt;li&gt;Logs generated between 10:00 and 10:05.&lt;/li&gt;
&lt;li&gt;All logs associated with a particular order.&lt;/li&gt;
&lt;li&gt;All occurrences of database timeout errors.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Loki is designed around indexed log labels rather than indexing the full content of every log line.&lt;/p&gt;

&lt;p&gt;This is an important architectural distinction from traditional full-text log indexing systems.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does Loki Store Error Logs Too?
&lt;/h3&gt;

&lt;p&gt;Absolutely!&lt;/p&gt;

&lt;p&gt;This is one of the common sources of confusion.&lt;/p&gt;

&lt;p&gt;Loki does not store only INFO or WARNING logs.&lt;/p&gt;

&lt;p&gt;It can store:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;INFO logs&lt;/li&gt;
&lt;li&gt;DEBUG logs&lt;/li&gt;
&lt;li&gt;WARNING logs&lt;/li&gt;
&lt;li&gt;ERROR logs&lt;/li&gt;
&lt;li&gt;Exception logs&lt;/li&gt;
&lt;li&gt;Application-generated structured logs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2026-12-05 10:00:00 INFO Order received
2026-12-05 10:00:01 INFO Payment initiated
2026-12-05 10:00:02 ERROR ZeroDivisionError
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All these logs can be sent to Loki.&lt;/p&gt;

&lt;p&gt;But if Loki can store error logs, why do we need Sentry?&lt;/p&gt;

&lt;p&gt;Let's understand that next.&lt;/p&gt;

&lt;p&gt;Official website: &lt;a href="https://grafana.com/oss/loki/" rel="noopener noreferrer"&gt;https://grafana.com/oss/loki/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Sentry — Application Error Tracking
&lt;/h2&gt;

&lt;p&gt;Sentry is an application monitoring and error-tracking platform.&lt;/p&gt;

&lt;p&gt;Let's consider a Python application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate_discount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;discount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;discount&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A customer sends a discount value of zero.&lt;/p&gt;

&lt;p&gt;The application throws:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ZeroDivisionError
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now imagine this happens 500 times in production.&lt;/p&gt;

&lt;p&gt;As developers, we want to know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which function failed?&lt;/li&gt;
&lt;li&gt;Which line of code caused the problem?&lt;/li&gt;
&lt;li&gt;What was the stack trace?&lt;/li&gt;
&lt;li&gt;How frequently is this happening?&lt;/li&gt;
&lt;li&gt;Which application release introduced the issue?&lt;/li&gt;
&lt;li&gt;How many users are affected?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sentry helps developers investigate these problems.&lt;/p&gt;

&lt;p&gt;It can automatically capture exceptions through its SDK and provide information such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Exception type&lt;/li&gt;
&lt;li&gt;Stack trace&lt;/li&gt;
&lt;li&gt;File and line number&lt;/li&gt;
&lt;li&gt;Application release&lt;/li&gt;
&lt;li&gt;Number of occurrences&lt;/li&gt;
&lt;li&gt;Affected users, when configured and available&lt;/li&gt;
&lt;li&gt;Breadcrumbs showing preceding application activity&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It also groups similar occurrences into issues, making it easier to identify recurring bugs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sentry vs Loki: Why Are Both Needed?
&lt;/h3&gt;

&lt;p&gt;This is an important distinction.&lt;/p&gt;

&lt;p&gt;Suppose our application throws a &lt;code&gt;ZeroDivisionError&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;With Loki:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If our application logs the exception, Loki can store it.&lt;/p&gt;

&lt;p&gt;We can search for the error, inspect surrounding log events and investigate what happened.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;With Sentry:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sentry captures the exception as a developer-facing issue and provides additional debugging context.&lt;/p&gt;

&lt;p&gt;It can group repeated occurrences of the same issue and show how frequently it is happening.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Capability&lt;/th&gt;
&lt;th&gt;Loki&lt;/th&gt;
&lt;th&gt;Sentry&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Store ERROR logs&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Not its primary purpose&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Search application logs&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Not its primary purpose&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Store stack traces included in logs&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Captures structured exception context&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Group recurring exceptions into issues&lt;/td&gt;
&lt;td&gt;Not its primary purpose&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Track application releases&lt;/td&gt;
&lt;td&gt;Not its primary purpose&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dedicated error investigation workflow&lt;/td&gt;
&lt;td&gt;Limited&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So, can we skip Sentry and use Loki?&lt;/p&gt;

&lt;p&gt;Yes.&lt;/p&gt;

&lt;p&gt;If our requirements are primarily centralised logging and searching application errors, Loki might be sufficient.&lt;/p&gt;

&lt;p&gt;If we need dedicated exception tracking, issue grouping, release tracking and developer-focused debugging, Sentry provides additional value.&lt;/p&gt;

&lt;p&gt;They can complement each other, but every application does not necessarily need both.&lt;/p&gt;

&lt;p&gt;Sentry also supports performance monitoring and tracing capabilities, so it isn't limited to exception tracking.&lt;/p&gt;

&lt;p&gt;Official website: &lt;a href="https://sentry.io/" rel="noopener noreferrer"&gt;https://sentry.io/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Splunk — A Broader Enterprise Data Platform
&lt;/h2&gt;

&lt;p&gt;Splunk is different from the previous tools because it provides a broader range of enterprise capabilities.&lt;/p&gt;

&lt;p&gt;Imagine a large bank.&lt;/p&gt;

&lt;p&gt;It has:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Payment application logs&lt;/li&gt;
&lt;li&gt;Authentication logs&lt;/li&gt;
&lt;li&gt;Server logs&lt;/li&gt;
&lt;li&gt;Network logs&lt;/li&gt;
&lt;li&gt;Database logs&lt;/li&gt;
&lt;li&gt;Security events&lt;/li&gt;
&lt;li&gt;Infrastructure metrics&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The bank wants to collect, search and analyse information from all these systems.&lt;/p&gt;

&lt;p&gt;Splunk provides products and capabilities for ingesting, indexing, searching and analysing machine-generated data.&lt;/p&gt;

&lt;p&gt;Its use cases include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Application monitoring&lt;/li&gt;
&lt;li&gt;Log analysis&lt;/li&gt;
&lt;li&gt;Security monitoring&lt;/li&gt;
&lt;li&gt;Threat detection&lt;/li&gt;
&lt;li&gt;Infrastructure monitoring&lt;/li&gt;
&lt;li&gt;Enterprise analytics&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Splunk has different product offerings, including observability and security solutions.&lt;/p&gt;

&lt;h3&gt;
  
  
  How Is Splunk Different From Loki?
&lt;/h3&gt;

&lt;p&gt;Both can be used for log-related work, but their scope differs.&lt;/p&gt;

&lt;p&gt;Loki is primarily a specialised log aggregation system.&lt;/p&gt;

&lt;p&gt;Splunk is a broader enterprise platform with capabilities across log analytics, security and observability.&lt;/p&gt;

&lt;h3&gt;
  
  
  How Is Splunk Different From Grafana?
&lt;/h3&gt;

&lt;p&gt;Grafana primarily provides dashboards, visualisation and exploration across connected data sources.&lt;/p&gt;

&lt;p&gt;Splunk also provides its own ingestion, indexing, searching and analytics capabilities.&lt;/p&gt;

&lt;p&gt;Some capabilities overlap, but they are not equivalent products.&lt;/p&gt;

&lt;p&gt;Depending on the products and capabilities selected, an organisation might use Splunk for several observability requirements instead of combining multiple specialised tools. It may also use Splunk alongside tools such as Prometheus, Grafana or Loki.&lt;/p&gt;

&lt;p&gt;Official website: &lt;a href="https://www.splunk.com/" rel="noopener noreferrer"&gt;https://www.splunk.com/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Distributed Tracing — Understanding One Request Across Multiple Services
&lt;/h2&gt;

&lt;p&gt;Now let's understand one of the most important concepts in microservices architecture.&lt;/p&gt;

&lt;p&gt;Imagine a customer places an order.&lt;/p&gt;

&lt;p&gt;Internally, the application performs the following operations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Customer
   |
   v
API Gateway
   |
   v
Order Service
   |
   v
Payment Service
   |
   v
Inventory Service
   |
   v
Database
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The customer sees one operation: Place Order.&lt;/p&gt;

&lt;p&gt;But internally, several services participate.&lt;/p&gt;

&lt;p&gt;Now imagine the customer complains:&lt;/p&gt;

&lt;p&gt;"My order took 8 seconds to complete."&lt;/p&gt;

&lt;p&gt;As developers, we need to identify where the delay occurred.&lt;/p&gt;

&lt;p&gt;Was it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;API Gateway?&lt;/li&gt;
&lt;li&gt;Order Service?&lt;/li&gt;
&lt;li&gt;Payment Service?&lt;/li&gt;
&lt;li&gt;Inventory Service?&lt;/li&gt;
&lt;li&gt;Database?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Knowing only that the overall API took 8 seconds isn't sufficient.&lt;/p&gt;

&lt;p&gt;This is the problem distributed tracing solves.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Distributed tracing follows an individual request across multiple services and records the operations performed during its journey.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  8.1 What Is a Trace?
&lt;/h3&gt;

&lt;p&gt;A trace represents the complete journey of one request.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Customer places order
          |
          v
       TRACE-123
          |
          +--- API Gateway
          |
          +--- Order Service
          |
          +--- Payment Service
          |
          +--- Inventory Service
          |
          +--- Database
          |
          v
      Order completed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Think of &lt;code&gt;TRACE-123&lt;/code&gt; as a tracking number for the entire request.&lt;/p&gt;

&lt;p&gt;Just as a courier tracking number helps us follow a parcel across different locations, a Trace ID helps developers follow one request across multiple services.&lt;/p&gt;

&lt;p&gt;The services participating in the request record information associated with that trace.&lt;/p&gt;

&lt;h3&gt;
  
  
  8.2 What Is a Span?
&lt;/h3&gt;

&lt;p&gt;A span represents one individual operation within a trace.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TRACE-123
   |
   +--- API Gateway              100 ms
   |
   +--- Order Service            300 ms
   |
   +--- Payment Service         4,000 ms
   |
   +--- Inventory Service        200 ms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Trace = Complete order request journey.&lt;/li&gt;
&lt;li&gt;Span = One operation within that journey.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each span can record:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Operation name&lt;/li&gt;
&lt;li&gt;Start time&lt;/li&gt;
&lt;li&gt;Duration&lt;/li&gt;
&lt;li&gt;Service name&lt;/li&gt;
&lt;li&gt;Parent span&lt;/li&gt;
&lt;li&gt;Status (success or error)&lt;/li&gt;
&lt;li&gt;Additional attributes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A trace consists of multiple related spans.&lt;/p&gt;

&lt;p&gt;Spans can also have parent-child relationships, helping us understand which operation initiated another operation.&lt;/p&gt;

&lt;h3&gt;
  
  
  8.3 Why Is Distributed Tracing Important?
&lt;/h3&gt;

&lt;p&gt;Suppose the total order request takes 5 seconds.&lt;/p&gt;

&lt;p&gt;Without distributed tracing, we might know only that the API is slow.&lt;/p&gt;

&lt;p&gt;With distributed tracing, we can discover:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;API Gateway          100 ms
Order Service        300 ms
Payment Service    4,000 ms
Inventory Service   200 ms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we know that Payment Service is consuming most of the time.&lt;/p&gt;

&lt;p&gt;We can investigate the payment operation instead of blindly checking the entire application.&lt;/p&gt;

&lt;p&gt;This is particularly useful in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Microservices architecture&lt;/li&gt;
&lt;li&gt;Distributed systems&lt;/li&gt;
&lt;li&gt;Service-to-service communication&lt;/li&gt;
&lt;li&gt;Database performance investigation&lt;/li&gt;
&lt;li&gt;External API integrations&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  9. How Do Services Know They Belong to the Same Trace?
&lt;/h2&gt;

&lt;p&gt;This is another important question.&lt;/p&gt;

&lt;p&gt;Suppose a request enters the API Gateway.&lt;/p&gt;

&lt;p&gt;The tracing system creates:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Trace ID = ABC123
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The API Gateway calls Order Service.&lt;/p&gt;

&lt;p&gt;It passes the trace context along with the request.&lt;/p&gt;

&lt;p&gt;Order Service receives the request and understands that it belongs to trace &lt;code&gt;ABC123&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Then Order Service calls Payment Service and passes the trace context again.&lt;/p&gt;

&lt;p&gt;Payment Service continues the same trace.&lt;/p&gt;

&lt;p&gt;This mechanism is called &lt;strong&gt;Context Propagation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A simplified representation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;API Gateway
    |
    | Trace ID: ABC123
    v
Order Service
    |
    | Trace ID: ABC123
    v
Payment Service
    |
    | Trace ID: ABC123
    v
Inventory Service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All these services contribute information to the same trace.&lt;/p&gt;

&lt;p&gt;Each service creates its own spans, with different span IDs, while retaining the shared trace identity.&lt;/p&gt;

&lt;p&gt;For HTTP communication, W3C Trace Context is a commonly used standard.&lt;/p&gt;

&lt;p&gt;The propagated trace context contains more than just the Trace ID. It also carries information about the current span, allowing the receiving service to create a new span with the correct parent-child relationship.&lt;/p&gt;

&lt;p&gt;For HTTP communication, this information is commonly propagated using the W3C &lt;code&gt;traceparent&lt;/code&gt; header.&lt;/p&gt;

&lt;p&gt;One important point: context propagation must be supported by instrumentation and the communication libraries. It does not happen automatically just because an application uses microservices.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Tempo — Distributed Trace Storage
&lt;/h2&gt;

&lt;p&gt;Now that we understand distributed tracing, Tempo becomes much easier.&lt;/p&gt;

&lt;p&gt;Tempo is an open-source distributed tracing backend developed by Grafana Labs.&lt;/p&gt;

&lt;p&gt;Remember our earlier tools:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;What it primarily stores&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Prometheus&lt;/td&gt;
&lt;td&gt;Metrics&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Loki&lt;/td&gt;
&lt;td&gt;Logs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tempo&lt;/td&gt;
&lt;td&gt;Traces&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Our application generates traces containing spans.&lt;/p&gt;

&lt;p&gt;Tempo provides a backend where those traces can be stored and queried.&lt;/p&gt;

&lt;p&gt;Grafana can connect to Tempo and visualise the request journey.&lt;/p&gt;

&lt;p&gt;For example, a developer can open a trace and inspect:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The participating services&lt;/li&gt;
&lt;li&gt;Individual spans&lt;/li&gt;
&lt;li&gt;Operation durations&lt;/li&gt;
&lt;li&gt;Parent-child relationships&lt;/li&gt;
&lt;li&gt;Failed operations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tempo is not responsible for creating application instrumentation. It primarily provides trace storage and retrieval.&lt;/p&gt;

&lt;p&gt;Official website: &lt;a href="https://grafana.com/oss/tempo/" rel="noopener noreferrer"&gt;https://grafana.com/oss/tempo/&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  If Loki Logs Already Have a Trace ID, Why Do We Need Tempo?
&lt;/h3&gt;

&lt;p&gt;This is an interesting question.&lt;/p&gt;

&lt;p&gt;Suppose we introduce a Trace ID into every log generated by our microservices.&lt;/p&gt;

&lt;p&gt;For example, when a user places an order, the application generates a Trace ID: &lt;code&gt;TRACE-101&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Every service carries this ID and includes it in its logs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[TRACE-101] Order Service: Request received
[TRACE-101] Order Service: Calling Payment Service
[TRACE-101] Payment Service: Payment initiated
[TRACE-101] Payment Service: Calling Bank API
[TRACE-101] Payment Service: Bank API timeout
[TRACE-101] Order Service: Payment failed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since Loki stores these logs, we can search for &lt;code&gt;TRACE-101&lt;/code&gt; and retrieve all the log messages associated with that request.&lt;/p&gt;

&lt;p&gt;So, doesn't Loki already solve distributed tracing?&lt;/p&gt;

&lt;p&gt;Not exactly.&lt;/p&gt;

&lt;p&gt;Loki helps us find related log messages. However, a Trace ID in a log does not automatically make that log a structured trace.&lt;/p&gt;

&lt;p&gt;A distributed trace contains structured spans, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Trace ID:&lt;/strong&gt; Identifies the complete request journey.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Span ID:&lt;/strong&gt; Identifies an individual operation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Parent Span ID:&lt;/strong&gt; Identifies the operation that initiated another operation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Start time and duration:&lt;/strong&gt; Tell us when an operation happened and how long it took.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Status:&lt;/strong&gt; Indicates whether an operation succeeded or failed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Trace ID: TRACE-101

Span 1:
  Span ID: A
  Parent: None
  Service: Order Service

Span 2:
  Span ID: B
  Parent: A
  Service: Payment Service

Span 3:
  Span ID: C
  Parent: B
  Service: Bank API
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The parent-child relationships help us reconstruct the execution hierarchy of a request.&lt;/p&gt;

&lt;p&gt;Tempo stores and queries this structured trace information, whereas Loki stores and queries log records.&lt;/p&gt;

&lt;p&gt;Technically, we could log Span IDs, Parent Span IDs, timestamps and durations, then write custom logic to reconstruct traces from Loki logs. But we would essentially be building our own tracing system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The takeaway:&lt;/strong&gt; Loki helps us find all logs related to a request. Tempo helps us understand the structured execution journey of that request.&lt;/p&gt;

&lt;h2&gt;
  
  
  11. OpenTelemetry — The Missing Connecting Concept
&lt;/h2&gt;

&lt;p&gt;Now we understand:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Metrics&lt;/li&gt;
&lt;li&gt;Logs&lt;/li&gt;
&lt;li&gt;Traces&lt;/li&gt;
&lt;li&gt;Trace IDs&lt;/li&gt;
&lt;li&gt;Spans&lt;/li&gt;
&lt;li&gt;Distributed tracing&lt;/li&gt;
&lt;li&gt;Trace storage through Tempo&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But one question remains.&lt;/p&gt;

&lt;p&gt;How do we instrument our applications to generate and export telemetry consistently?&lt;/p&gt;

&lt;p&gt;Do developers manually create Trace IDs, Span IDs, record operation timings and send everything to different tools?&lt;/p&gt;

&lt;p&gt;We could implement these mechanisms ourselves, but it would involve considerable repetitive work.&lt;/p&gt;

&lt;p&gt;This is where OpenTelemetry comes in.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OpenTelemetry is a collection of APIs, SDKs, instrumentation libraries and tools that standardises how applications generate, collect and export telemetry.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It supports three major telemetry signals:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Metrics&lt;/li&gt;
&lt;li&gt;Logs&lt;/li&gt;
&lt;li&gt;Traces&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Think of OpenTelemetry as a common instrumentation and telemetry framework.&lt;/p&gt;

&lt;p&gt;It helps different applications produce telemetry in a standardised way, which can then be sent to compatible observability backends.&lt;/p&gt;

&lt;h3&gt;
  
  
  11.1 What Does OpenTelemetry Actually Do?
&lt;/h3&gt;

&lt;p&gt;Suppose we have a FastAPI application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nd"&gt;@app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/orders"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;create_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;save_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;payment&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;process_payment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"success"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We want to understand:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How long did &lt;code&gt;create_order()&lt;/code&gt; take?&lt;/li&gt;
&lt;li&gt;How long did &lt;code&gt;save_order()&lt;/code&gt; take?&lt;/li&gt;
&lt;li&gt;How long did &lt;code&gt;process_payment()&lt;/code&gt; take?&lt;/li&gt;
&lt;li&gt;Did an exception occur?&lt;/li&gt;
&lt;li&gt;Which operation was slow?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;OpenTelemetry instrumentation can automatically capture supported operations.&lt;/p&gt;

&lt;p&gt;Developers can also manually instrument their own business operations.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;tracer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start_as_current_span&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"create_order"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;tracer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start_as_current_span&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"save_order"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;save_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;tracer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start_as_current_span&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"process_payment"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;process_payment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates spans representing the individual operations.&lt;/p&gt;

&lt;p&gt;The OpenTelemetry SDK manages the recording and exporting of this telemetry.&lt;/p&gt;

&lt;p&gt;OpenTelemetry instrumentation can generate trace and span information, while also allowing trace context to be included in application logs. This is how logs and traces can be correlated. The developer doesn't have to build a complete tracing mechanism from scratch.&lt;/p&gt;

&lt;h3&gt;
  
  
  11.2 What Is the OpenTelemetry Collector?
&lt;/h3&gt;

&lt;p&gt;OpenTelemetry also provides a component called the OpenTelemetry Collector.&lt;/p&gt;

&lt;p&gt;Think of it as a central telemetry processing and routing component.&lt;/p&gt;

&lt;p&gt;It can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Receive telemetry from applications.&lt;/li&gt;
&lt;li&gt;Process and batch the data.&lt;/li&gt;
&lt;li&gt;Filter or transform telemetry.&lt;/li&gt;
&lt;li&gt;Export telemetry to configured backends.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FastAPI Application
        |
        v
OpenTelemetry SDK
        |
        v
OpenTelemetry Collector
        |
        +---------- Metrics
        |               |
        |               v
        |           Prometheus
        |
        +---------- Logs
        |               |
        |               v
        |             Loki
        |
        +---------- Traces
                        |
                        v
                      Tempo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is one possible architecture, not a mandatory configuration.&lt;/p&gt;

&lt;p&gt;For example, Prometheus can scrape application metrics directly, and applications can export telemetry directly to backends without a separate Collector.&lt;/p&gt;

&lt;h3&gt;
  
  
  11.3 Is OpenTelemetry a Replacement for Prometheus, Loki or Tempo?
&lt;/h3&gt;

&lt;p&gt;No.&lt;/p&gt;

&lt;p&gt;They have different responsibilities.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Technology&lt;/th&gt;
&lt;th&gt;Responsibility&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;OpenTelemetry&lt;/td&gt;
&lt;td&gt;Instrumentation and telemetry generation/collection/export&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Prometheus&lt;/td&gt;
&lt;td&gt;Metrics monitoring and storage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Loki&lt;/td&gt;
&lt;td&gt;Log aggregation and storage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tempo&lt;/td&gt;
&lt;td&gt;Distributed trace storage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Grafana&lt;/td&gt;
&lt;td&gt;Visualisation and exploration&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A useful analogy:&lt;/p&gt;

&lt;p&gt;OpenTelemetry helps applications produce and transport standardised telemetry.&lt;/p&gt;

&lt;p&gt;Prometheus, Loki and Tempo provide specialised backends for working with different types of telemetry.&lt;/p&gt;

&lt;p&gt;Grafana provides a common interface for exploring the information.&lt;/p&gt;

&lt;p&gt;Official website: &lt;a href="https://opentelemetry.io/" rel="noopener noreferrer"&gt;https://opentelemetry.io/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  12. Putting Everything Together: A Possible Observability Architecture
&lt;/h2&gt;

&lt;p&gt;Now let's combine the concepts.&lt;/p&gt;

&lt;p&gt;Imagine we have deployed our e-commerce application.&lt;/p&gt;

&lt;p&gt;Our application contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Order Service&lt;/li&gt;
&lt;li&gt;Payment Service&lt;/li&gt;
&lt;li&gt;Inventory Service&lt;/li&gt;
&lt;li&gt;Database&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The services generate metrics, logs and traces.&lt;/p&gt;

&lt;p&gt;A possible architecture looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;              PRODUCTION APPLICATION
                        |
        +---------------+---------------+
        |               |               |
      Metrics          Logs           Traces
        |               |               |
        +---------------+---------------+
                        |
                 OpenTelemetry
                 Instrumentation
                        |
                OTel Collector
                        |
        +---------------+---------------+
        |               |               |
        v               v               v
    Prometheus         Loki            Tempo
        |               |               |
        +---------------+---------------+
                        |
                        v
                     Grafana
                        |
                        v
              Dashboards &amp;amp; Investigation


       Sentry: Optional application error tracking
       Splunk: Broader enterprise analytics,
               security and observability platform
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a conceptual architecture. Actual deployments may use different collection paths, exporters, integrations and storage systems.&lt;/p&gt;

&lt;p&gt;Notice that we don't necessarily need every tool.&lt;/p&gt;

&lt;p&gt;A company might use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prometheus + Grafana for metrics and dashboards.&lt;/li&gt;
&lt;li&gt;Loki + Grafana for logs.&lt;/li&gt;
&lt;li&gt;Tempo + Grafana for distributed tracing.&lt;/li&gt;
&lt;li&gt;Sentry for application exception tracking.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Another company might use Splunk for several of these capabilities.&lt;/p&gt;

&lt;p&gt;The architecture depends on the organisation's requirements, infrastructure, budget and scale.&lt;/p&gt;

&lt;h2&gt;
  
  
  13. A Real Production Incident: How Do These Tools Work Together?
&lt;/h2&gt;

&lt;p&gt;Let's bring everything together through one example.&lt;/p&gt;

&lt;p&gt;A customer places an order, but the API takes 8 seconds to respond.&lt;/p&gt;

&lt;p&gt;How would a developer investigate?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Prometheus detects the problem.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The payment API latency has increased from 500 milliseconds to 8 seconds.&lt;/p&gt;

&lt;p&gt;The error rate is also increasing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Grafana helps identify the pattern.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We open the monitoring dashboard and observe that Payment Service latency started increasing around 10:15 AM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Loki helps investigate the logs.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We search Payment Service logs around 10:15 AM.&lt;/p&gt;

&lt;p&gt;We discover:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ERROR Database connection timeout
ERROR Connection pool exhausted
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Tempo helps investigate the request journey.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We inspect a distributed trace and discover that the payment operation is spending most of its time waiting for a database connection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Sentry helps if application exceptions are occurring.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If the service also throws exceptions, Sentry can show the stack trace, affected releases and frequency of the issue.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6: The developer fixes the problem.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We investigate the connection pool configuration, database load or possible connection leak.&lt;/p&gt;

&lt;p&gt;After deploying the fix, we check Grafana again to verify that API latency has returned to normal.&lt;/p&gt;

&lt;p&gt;This is how observability helps developers investigate production incidents.&lt;/p&gt;

&lt;p&gt;It is not simply about creating dashboards. It is about understanding system behaviour and reducing the time required to identify and resolve problems.&lt;/p&gt;

&lt;h2&gt;
  
  
  14. Where Does Observability Fit Into System Design?
&lt;/h2&gt;

&lt;p&gt;Observability is an important part of designing production-ready systems.&lt;/p&gt;

&lt;p&gt;When discussing system design, we usually focus on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Scalability&lt;/li&gt;
&lt;li&gt;Availability&lt;/li&gt;
&lt;li&gt;Reliability&lt;/li&gt;
&lt;li&gt;Performance&lt;/li&gt;
&lt;li&gt;Fault tolerance&lt;/li&gt;
&lt;li&gt;Database design&lt;/li&gt;
&lt;li&gt;Caching&lt;/li&gt;
&lt;li&gt;Load balancing&lt;/li&gt;
&lt;li&gt;Distributed communication&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But designing a system is not enough.&lt;/p&gt;

&lt;p&gt;We also need to understand how we will monitor its behaviour after deployment.&lt;/p&gt;

&lt;p&gt;Consider the following relationships:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;System design concept&lt;/th&gt;
&lt;th&gt;How observability helps&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Scalability&lt;/td&gt;
&lt;td&gt;Monitor traffic, CPU, memory and throughput&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reliability&lt;/td&gt;
&lt;td&gt;Detect failures and service degradation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Availability&lt;/td&gt;
&lt;td&gt;Monitor service availability and failed requests&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Performance&lt;/td&gt;
&lt;td&gt;Measure latency and identify bottlenecks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Distributed systems&lt;/td&gt;
&lt;td&gt;Follow requests across microservices&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fault tolerance&lt;/td&gt;
&lt;td&gt;Understand failures and recovery&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rate limiting&lt;/td&gt;
&lt;td&gt;Monitor rejected requests and traffic spikes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Database design&lt;/td&gt;
&lt;td&gt;Monitor query latency and connection pools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Incident management&lt;/td&gt;
&lt;td&gt;Detect, investigate and resolve production problems&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  14.1 SLI, SLO and SLA
&lt;/h3&gt;

&lt;p&gt;Three more terms are closely associated with production reliability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SLI — Service Level Indicator&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A measurable indicator of service health.&lt;/p&gt;

&lt;p&gt;Example: 99.5% of API requests succeed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SLO — Service Level Objective&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The reliability target we want to achieve.&lt;/p&gt;

&lt;p&gt;Example: 99.9% of requests should succeed over a rolling 30-day period.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SLA — Service Level Agreement&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A formal commitment to customers regarding service levels, often with consequences if the agreed targets are not met.&lt;/p&gt;

&lt;p&gt;Observability data helps us measure whether our system is meeting these targets.&lt;/p&gt;

&lt;h2&gt;
  
  
  15. What Should a Software Developer Actually Know?
&lt;/h2&gt;

&lt;p&gt;Does every backend developer need to know how to install, configure and manage all these tools?&lt;/p&gt;

&lt;p&gt;No.&lt;/p&gt;

&lt;p&gt;However, every production-oriented backend developer should understand the concepts behind them.&lt;/p&gt;

&lt;p&gt;I would divide the knowledge into three levels.&lt;/p&gt;

&lt;h3&gt;
  
  
  Level 1: Every Backend Developer Should Know
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Difference between metrics, logs and traces.&lt;/li&gt;
&lt;li&gt;Why observability is required.&lt;/li&gt;
&lt;li&gt;Structured application logging.&lt;/li&gt;
&lt;li&gt;Log levels: DEBUG, INFO, WARNING and ERROR.&lt;/li&gt;
&lt;li&gt;Exception handling.&lt;/li&gt;
&lt;li&gt;HTTP status codes.&lt;/li&gt;
&lt;li&gt;API latency and throughput.&lt;/li&gt;
&lt;li&gt;Request IDs and correlation IDs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Level 2: Production-Ready Backend Developer
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Integrating Sentry into an application.&lt;/li&gt;
&lt;li&gt;Understanding Prometheus metrics.&lt;/li&gt;
&lt;li&gt;Creating and reading Grafana dashboards.&lt;/li&gt;
&lt;li&gt;Searching logs using Loki or Splunk.&lt;/li&gt;
&lt;li&gt;Understanding distributed tracing.&lt;/li&gt;
&lt;li&gt;Instrumenting APIs using OpenTelemetry.&lt;/li&gt;
&lt;li&gt;Understanding alerts, SLIs and SLOs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Level 3: Senior Backend / Platform / SRE Engineer
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Designing an observability architecture.&lt;/li&gt;
&lt;li&gt;Configuring telemetry collection pipelines.&lt;/li&gt;
&lt;li&gt;Managing storage and retention costs.&lt;/li&gt;
&lt;li&gt;Designing alerting strategies.&lt;/li&gt;
&lt;li&gt;Handling high-cardinality metrics.&lt;/li&gt;
&lt;li&gt;Implementing distributed tracing across large microservice environments.&lt;/li&gt;
&lt;li&gt;Managing observability infrastructure at scale.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A backend developer does not need to become an observability engineer, but should know how to investigate application behaviour in production.&lt;/p&gt;

&lt;h2&gt;
  
  
  16. Common Confusions: Quick Answers
&lt;/h2&gt;

&lt;p&gt;Let's summarise the questions that frequently cause confusion.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q1. Can Grafana show Prometheus, Loki and Tempo data together?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yes. Grafana supports multiple data sources and can display metrics, logs and traces through dashboards and exploration interfaces.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q2. Can Loki store ERROR logs?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yes. Loki can store INFO, DEBUG, WARNING and ERROR logs. It is not restricted to a particular log level.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q3. If Loki stores error logs, why do we need Sentry?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Loki is primarily a log aggregation and querying system. Sentry provides dedicated exception tracking, issue grouping, stack traces, release tracking and debugging workflows.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q4. Is Splunk the same as Grafana?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No. Grafana primarily provides visualisation and exploration. Splunk is a broader enterprise platform with data ingestion, indexing, search, analytics, security and observability capabilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q5. Is Tempo the same as Loki?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No. Loki stores and queries logs. Tempo stores and queries distributed traces.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q6. Is OpenTelemetry a monitoring tool?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Not in the same sense as Prometheus or Grafana. It is an instrumentation and telemetry framework that helps applications generate and export metrics, logs and traces.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q7. Is a Trace ID the same as a Span ID?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No. A Trace ID identifies the complete request journey. A Span ID identifies an individual operation within that journey.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q8. Is distributed tracing useful only for microservices?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is especially useful in distributed systems, but tracing can also help understand operations within a monolithic application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q9. Do all applications need Prometheus, Loki, Sentry, Tempo and Splunk?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No. Organisations choose tools based on their requirements. These tools have overlapping capabilities, but they are not all mandatory.&lt;/p&gt;

&lt;h2&gt;
  
  
  17. Quick Revision: Which Tool Is Responsible for What?
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Technology&lt;/th&gt;
&lt;th&gt;Remember it as&lt;/th&gt;
&lt;th&gt;Primary responsibility&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Prometheus&lt;/td&gt;
&lt;td&gt;Measures application health&lt;/td&gt;
&lt;td&gt;Metrics collection and storage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Grafana&lt;/td&gt;
&lt;td&gt;Shows application health&lt;/td&gt;
&lt;td&gt;Dashboards and visualisation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Loki&lt;/td&gt;
&lt;td&gt;Remembers application events&lt;/td&gt;
&lt;td&gt;Log aggregation and querying&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sentry&lt;/td&gt;
&lt;td&gt;Tracks application errors&lt;/td&gt;
&lt;td&gt;Exception and performance tracking&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tempo&lt;/td&gt;
&lt;td&gt;Follows request journeys&lt;/td&gt;
&lt;td&gt;Distributed trace storage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;OpenTelemetry&lt;/td&gt;
&lt;td&gt;Helps applications produce telemetry&lt;/td&gt;
&lt;td&gt;Instrumentation and collection/export&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Splunk&lt;/td&gt;
&lt;td&gt;Enterprise data analysis platform&lt;/td&gt;
&lt;td&gt;Data ingestion, indexing, analytics, security and observability&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Observability is not about installing multiple monitoring tools just because they are popular.&lt;/p&gt;

&lt;p&gt;It is about being able to answer three fundamental questions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Metrics:&lt;/strong&gt; What is happening inside my system?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Logs:&lt;/strong&gt; What exactly happened?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Traces:&lt;/strong&gt; Where did a particular request travel, and where did it spend its time?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The tools support these responsibilities in different ways.&lt;/p&gt;

&lt;p&gt;Prometheus collects metrics, Loki aggregates logs, Tempo stores traces, Sentry helps developers investigate application errors, OpenTelemetry standardises instrumentation and telemetry collection, and Grafana provides a common interface to explore the information.&lt;/p&gt;

&lt;p&gt;Splunk offers a broader enterprise platform that covers several related use cases.&lt;/p&gt;

&lt;p&gt;The bigger engineering lesson is this:&lt;/p&gt;

&lt;p&gt;Writing code that works is only one part of software development. Building software that can be monitored, understood, debugged and operated reliably in production is equally important.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;That is why observability is an essential part of backend engineering and system design.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>observability</category>
      <category>grafana</category>
      <category>prometheus</category>
      <category>backend</category>
    </item>
    <item>
      <title>Back-of-the-Envelope Estimation: Applying It to Real Systems</title>
      <dc:creator>Saras Growth Space</dc:creator>
      <pubDate>Sat, 21 Nov 2026 15:00:00 +0000</pubDate>
      <link>https://dev.to/saras_growth_space/back-of-the-envelope-estimation-applying-it-to-real-systems-34gb</link>
      <guid>https://dev.to/saras_growth_space/back-of-the-envelope-estimation-applying-it-to-real-systems-34gb</guid>
      <description>&lt;p&gt;So far, we’ve covered:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;QPS (requests per second)&lt;/li&gt;
&lt;li&gt;Storage estimation&lt;/li&gt;
&lt;li&gt;Bandwidth&lt;/li&gt;
&lt;li&gt;Bottlenecks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now comes the most important part:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;How do you actually use all of this in real system design?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🚀 The Goal
&lt;/h2&gt;

&lt;p&gt;Back-of-the-envelope estimation is not about formulas.&lt;/p&gt;

&lt;p&gt;It’s about answering:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Can this system handle the expected load?”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🧠 The Mental Framework
&lt;/h2&gt;

&lt;p&gt;Whenever you see a system design problem, follow this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Estimate QPS
2. Estimate Storage
3. Estimate Bandwidth
4. Identify Bottleneck
5. Roughly size the system
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s apply this to real examples.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔗 Example 1: URL Shortener
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Assumptions:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;10M URLs created per day&lt;/li&gt;
&lt;li&gt;each URL is accessed 100 times&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Step 1: QPS
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Writes:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10M/day → ~100 QPS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Reads:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1B/day → ~10K QPS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 2: Storage
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;~2 KB per URL
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10M × 2 KB → ~20 GB/day
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 3: Bandwidth
&lt;/h3&gt;

&lt;p&gt;Reads dominate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;small payload (~1 KB)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10K × 1 KB → ~10 MB/sec
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 4: Bottleneck
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;QPS is high (reads)&lt;/li&gt;
&lt;li&gt;storage grows steadily&lt;/li&gt;
&lt;li&gt;bandwidth manageable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 &lt;strong&gt;Read traffic is the main concern&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🔗 Example 2: Messaging System
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Assumptions:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;100M users&lt;/li&gt;
&lt;li&gt;20 messages/user/day&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Step 1: QPS
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2B/day → ~20K QPS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 2: Storage
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;~1 KB per message
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2B KB/day → ~2 TB/day
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 3: Bandwidth
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;20K × 1 KB → ~20 MB/sec
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 4: Bottleneck
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;storage grows very fast&lt;/li&gt;
&lt;li&gt;real-time delivery required&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 &lt;strong&gt;Storage + delivery latency are key challenges&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🔗 Example 3: Video Streaming
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Assumptions:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;1B views/day&lt;/li&gt;
&lt;li&gt;each view streams ~5 MB chunks&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Step 1: QPS
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1B/day → ~10K QPS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 2: Bandwidth
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10K × 5 MB → ~50 GB/sec
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 3: Bottleneck
&lt;/h3&gt;

&lt;p&gt;👉 &lt;strong&gt;Network bandwidth is the biggest challenge&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 What You Should Notice
&lt;/h2&gt;

&lt;p&gt;Across systems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;URL shortener → read-heavy&lt;/li&gt;
&lt;li&gt;messaging → storage-heavy&lt;/li&gt;
&lt;li&gt;video streaming → bandwidth-heavy&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Different systems break in different ways.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚡ The Real Skill
&lt;/h2&gt;

&lt;p&gt;You’re not solving math problems.&lt;/p&gt;

&lt;p&gt;You’re learning to quickly answer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is this system small or massive?&lt;/li&gt;
&lt;li&gt;What will fail first?&lt;/li&gt;
&lt;li&gt;Where should we optimize?&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔑 Final Takeaway
&lt;/h2&gt;

&lt;p&gt;Back-of-the-envelope estimation helps you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;think clearly under uncertainty&lt;/li&gt;
&lt;li&gt;make quick architectural decisions&lt;/li&gt;
&lt;li&gt;avoid over-engineering&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🎯 You’re Now Ready To
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;approach system design problems with confidence&lt;/li&gt;
&lt;li&gt;estimate system scale quickly&lt;/li&gt;
&lt;li&gt;identify bottlenecks early&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;If you followed along this series, you’ve built a strong foundation.&lt;/p&gt;

&lt;p&gt;What system would you like to estimate next? 👇&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>backend</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Back-of-the-Envelope Estimation: Bandwidth and Bottlenecks</title>
      <dc:creator>Saras Growth Space</dc:creator>
      <pubDate>Fri, 20 Nov 2026 15:00:00 +0000</pubDate>
      <link>https://dev.to/saras_growth_space/back-of-the-envelope-estimation-bandwidth-and-bottlenecks-24b2</link>
      <guid>https://dev.to/saras_growth_space/back-of-the-envelope-estimation-bandwidth-and-bottlenecks-24b2</guid>
      <description>&lt;p&gt;So far, we’ve learned:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;how to estimate requests (QPS)&lt;/li&gt;
&lt;li&gt;how to estimate storage (GB/day)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now we answer a deeper question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;How much data is moving through the system every second?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is where &lt;strong&gt;bandwidth estimation&lt;/strong&gt; comes in.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 What is Bandwidth?
&lt;/h2&gt;

&lt;p&gt;Bandwidth means:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;how much data flows through your system per second&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It’s usually measured in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;KB/sec&lt;/li&gt;
&lt;li&gt;MB/sec&lt;/li&gt;
&lt;li&gt;GB/sec&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧠 The Core Formula
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Bandwidth = QPS × Data per Request
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This connects everything we’ve learned so far.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔢 Basic Example
&lt;/h2&gt;

&lt;p&gt;Let’s say:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;100 requests per second&lt;/li&gt;
&lt;li&gt;each request = 2 MB&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;100 × 2 MB = 200 MB/sec
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So your system needs to handle:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;200 MB of data every second&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  ⚡ Why Bandwidth Matters
&lt;/h2&gt;

&lt;p&gt;Even if your system handles QPS well:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;large payloads can overload the network&lt;/li&gt;
&lt;li&gt;slow responses increase latency&lt;/li&gt;
&lt;li&gt;users experience delays&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So bandwidth is often a &lt;strong&gt;hidden bottleneck&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🧩 Real Intuition
&lt;/h2&gt;

&lt;p&gt;Think of each request having “weight”:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;text request → light (KB)&lt;/li&gt;
&lt;li&gt;image upload → medium (MB)&lt;/li&gt;
&lt;li&gt;video streaming → heavy (GB)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So bandwidth is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“how heavy your traffic is per second”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🚨 What is a Bottleneck?
&lt;/h2&gt;

&lt;p&gt;A bottleneck is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;the first resource that fails under load&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In most systems, you check:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CPU (can it handle QPS?)&lt;/li&gt;
&lt;li&gt;Network (can it handle bandwidth?)&lt;/li&gt;
&lt;li&gt;Storage (can it handle data growth?)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔍 Example: Finding the Bottleneck
&lt;/h2&gt;

&lt;p&gt;Let’s say your system has:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1000 QPS&lt;/li&gt;
&lt;li&gt;10 KB per request → ~10 MB/sec bandwidth&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And your system capacity is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CPU: 2000 QPS&lt;/li&gt;
&lt;li&gt;Network: 5 MB/sec&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Step 1: Check CPU
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Required: 1000 QPS&lt;/li&gt;
&lt;li&gt;Capacity: 2000 QPS → OK&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Step 2: Check Network
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Required: 10 MB/sec&lt;/li&gt;
&lt;li&gt;Capacity: 5 MB/sec → NOT OK&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  👉 Conclusion
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Network is the bottleneck&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Even though CPU is fine.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 Key Insight
&lt;/h2&gt;

&lt;p&gt;A bottleneck is NOT the biggest number.&lt;/p&gt;

&lt;p&gt;It is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;the first constraint that gets exceeded&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🔗 Connecting Everything
&lt;/h2&gt;

&lt;p&gt;Now you can analyze any system:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;QPS → request load&lt;/li&gt;
&lt;li&gt;Storage → data growth&lt;/li&gt;
&lt;li&gt;Bandwidth → data flow&lt;/li&gt;
&lt;li&gt;Bottleneck → system limit&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ⚠️ Common Mistakes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  ❌ Ignoring payload size
&lt;/h3&gt;

&lt;p&gt;QPS alone is not enough.&lt;/p&gt;




&lt;h3&gt;
  
  
  ❌ Assuming CPU is always the problem
&lt;/h3&gt;

&lt;p&gt;Often, network or storage fails first.&lt;/p&gt;




&lt;h3&gt;
  
  
  ❌ Not comparing with capacity
&lt;/h3&gt;

&lt;p&gt;You must always compare:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;demand vs system limits&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🧠 Final Takeaway
&lt;/h2&gt;

&lt;p&gt;Back-of-the-envelope estimation is not about numbers.&lt;/p&gt;

&lt;p&gt;It’s about answering:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“What will break first in this system?”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  👉 What’s next?
&lt;/h2&gt;

&lt;p&gt;In the final part, we’ll apply everything to real systems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;URL shortener&lt;/li&gt;
&lt;li&gt;messaging system&lt;/li&gt;
&lt;li&gt;feed system&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;If this helped, share your thoughts 👇&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>backend</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Back-of-the-Envelope Estimation: Storage Made Simple</title>
      <dc:creator>Saras Growth Space</dc:creator>
      <pubDate>Thu, 19 Nov 2026 15:00:00 +0000</pubDate>
      <link>https://dev.to/saras_growth_space/back-of-the-envelope-estimation-storage-made-simple-2e5b</link>
      <guid>https://dev.to/saras_growth_space/back-of-the-envelope-estimation-storage-made-simple-2e5b</guid>
      <description>&lt;p&gt;In the previous post, we learned how to estimate system load using QPS.&lt;/p&gt;

&lt;p&gt;Now let’s answer another critical question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;How much data will the system store over time?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is where &lt;strong&gt;storage estimation&lt;/strong&gt; comes in.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 Why Storage Estimation Matters
&lt;/h2&gt;

&lt;p&gt;Even if your system handles traffic well:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;data keeps growing&lt;/li&gt;
&lt;li&gt;storage costs increase&lt;/li&gt;
&lt;li&gt;databases slow down&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So you need to estimate:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;how much data you generate per day, month, and year&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🧠 The Core Idea
&lt;/h2&gt;

&lt;p&gt;Every storage estimation follows a simple formula:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Total Storage = Number of Users × Data per User
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🔢 Basic Example
&lt;/h2&gt;

&lt;p&gt;Let’s say:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1 million users&lt;/li&gt;
&lt;li&gt;each generates 10 KB data per day&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1,000,000 × 10 KB = 10,000,000 KB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  📦 Convert to Larger Units
&lt;/h2&gt;

&lt;p&gt;To make sense of big numbers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1 MB ≈ 1,000 KB&lt;/li&gt;
&lt;li&gt;1 GB ≈ 1,000 MB&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10,000,000 KB ≈ 10,000 MB ≈ 10 GB/day
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  📅 Think in Time (Very Important)
&lt;/h2&gt;

&lt;p&gt;Once you have daily storage:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;per month → × 30&lt;/li&gt;
&lt;li&gt;per year → × 365&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;10 GB/day → ~300 GB/month&lt;/li&gt;
&lt;li&gt;→ ~3.6 TB/year&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ⚡ Real Example
&lt;/h2&gt;

&lt;p&gt;Let’s take a more realistic case:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;100 million users&lt;/li&gt;
&lt;li&gt;each generates 5 KB/day&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using the formula:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;100M × 5 KB = 500M KB ≈ 500 GB/day
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That’s:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;500 GB of new data every single day&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  ⚠️ Common Mistakes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  ❌ Ignoring time factor
&lt;/h3&gt;

&lt;p&gt;Always convert:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;per day → per month → per year&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  ❌ Forgetting unit conversion
&lt;/h3&gt;

&lt;p&gt;Keep it simple:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;KB → MB → GB → TB&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  ❌ Underestimating growth
&lt;/h3&gt;

&lt;p&gt;Data grows continuously—design for scale.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 Key Insight
&lt;/h2&gt;

&lt;p&gt;Storage estimation is not about exact numbers.&lt;/p&gt;

&lt;p&gt;It’s about understanding:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Is this system generating MBs, GBs, or TBs per day?”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🔗 Connecting with QPS
&lt;/h2&gt;

&lt;p&gt;Now you have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;QPS → how many requests&lt;/li&gt;
&lt;li&gt;Storage → how much data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next, we combine them to answer:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;how much data flows per second&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  👉 What’s next?
&lt;/h2&gt;

&lt;p&gt;In the next post, we’ll cover:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Bandwidth estimation&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How data moves through the system&lt;/li&gt;
&lt;li&gt;And how to identify bottlenecks&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;If this helped, share your thoughts 👇&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>backend</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Back-of-the-Envelope Estimation : Understanding QPS</title>
      <dc:creator>Saras Growth Space</dc:creator>
      <pubDate>Wed, 18 Nov 2026 15:00:00 +0000</pubDate>
      <link>https://dev.to/saras_growth_space/back-of-the-envelope-estimation-understanding-qps-44hc</link>
      <guid>https://dev.to/saras_growth_space/back-of-the-envelope-estimation-understanding-qps-44hc</guid>
      <description>&lt;p&gt;In the previous post, we talked about what back-of-the-envelope estimation is and why it matters.&lt;/p&gt;

&lt;p&gt;Now we move to the most important concept in system design:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;QPS (Queries Per Second)&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🚀 What is QPS?
&lt;/h2&gt;

&lt;p&gt;QPS simply means:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;How many requests your system handles every second&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is the &lt;strong&gt;starting point of almost every system design problem&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⏱️ The Key Conversion You Must Know
&lt;/h2&gt;

&lt;p&gt;To convert daily traffic into real-time load:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1 day ≈ 100,000 seconds&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This approximation makes calculations fast and simple.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔢 Basic Example
&lt;/h2&gt;

&lt;p&gt;If your system gets:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;10 million requests per day&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10,000,000 / 100,000 ≈ 100 QPS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So your system handles roughly:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;100 requests per second&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🧠 Think in Patterns (Not Calculations)
&lt;/h2&gt;

&lt;p&gt;Instead of calculating every time, learn these patterns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1M requests/day   → ~10 QPS
10M requests/day  → ~100 QPS
100M requests/day → ~1,000 QPS
1B requests/day   → ~10,000 QPS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you internalize this, estimation becomes instant.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚡ Why QPS Matters So Much
&lt;/h2&gt;

&lt;p&gt;QPS directly impacts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;number of servers required&lt;/li&gt;
&lt;li&gt;database load&lt;/li&gt;
&lt;li&gt;system performance&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;100 QPS → small system&lt;/li&gt;
&lt;li&gt;10K QPS → large system&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧩 Real Example
&lt;/h2&gt;

&lt;p&gt;Let’s say:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;50 million requests/day&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using pattern:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;50M ≈ 5 × 10M&lt;/li&gt;
&lt;li&gt;10M → 100 QPS&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;50M → ~500 QPS&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ⚠️ Common Mistakes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  ❌ Trying to be too accurate
&lt;/h3&gt;

&lt;p&gt;You don’t need exact numbers.&lt;/p&gt;

&lt;h3&gt;
  
  
  ❌ Forgetting unit conversion
&lt;/h3&gt;

&lt;p&gt;Always convert:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;per day → per second&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  ❌ Getting stuck on math
&lt;/h3&gt;

&lt;p&gt;Focus on approximation, not precision.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 Key Insight
&lt;/h2&gt;

&lt;p&gt;You’re not solving math problems.&lt;/p&gt;

&lt;p&gt;You’re answering:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Is this system handling hundreds, thousands, or millions of requests per second?”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  👉 What’s next?
&lt;/h2&gt;

&lt;p&gt;In the next post, we’ll cover: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Storage estimation&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How systems grow over time&lt;/li&gt;
&lt;li&gt;GB/day → TB/year thinking&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;If this helped, drop your thoughts 👇&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>backend</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Back-of-the-Envelope Estimation: Foundations</title>
      <dc:creator>Saras Growth Space</dc:creator>
      <pubDate>Tue, 17 Nov 2026 15:00:00 +0000</pubDate>
      <link>https://dev.to/saras_growth_space/back-of-the-envelope-estimation-foundations-2g4n</link>
      <guid>https://dev.to/saras_growth_space/back-of-the-envelope-estimation-foundations-2g4n</guid>
      <description>&lt;p&gt;When I first started learning system design, one thing kept confusing me:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;How do people quickly estimate system scale without exact data?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You’ll often see statements like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;“This system handles ~10K requests per second”&lt;/li&gt;
&lt;li&gt;“We’ll need ~500 GB per day”&lt;/li&gt;
&lt;li&gt;“Bandwidth could be the bottleneck”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But where do these numbers come from?&lt;/p&gt;

&lt;p&gt;That’s where &lt;strong&gt;back-of-the-envelope estimation&lt;/strong&gt; comes in.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 What is Back-of-the-Envelope Estimation?
&lt;/h2&gt;

&lt;p&gt;It’s a way to &lt;strong&gt;quickly approximate system scale using simple assumptions&lt;/strong&gt;, without needing exact data.&lt;/p&gt;

&lt;p&gt;The goal is not precision.&lt;/p&gt;

&lt;p&gt;The goal is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Get close enough (within 10x range) to make design decisions.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🤔 Why does this matter?
&lt;/h2&gt;

&lt;p&gt;In real-world systems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You rarely have exact numbers&lt;/li&gt;
&lt;li&gt;You still need to design scalable architecture&lt;/li&gt;
&lt;li&gt;Over-engineering is expensive&lt;/li&gt;
&lt;li&gt;Under-estimating causes failures&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So instead of guessing, engineers:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Break problems into small assumptions and estimate logically&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🧠 The Core Idea
&lt;/h2&gt;

&lt;p&gt;Every estimation follows a simple chain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Users → Requests → Data → System Load
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You start with something you &lt;em&gt;can assume&lt;/em&gt;, and build from there.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚙️ The 3 Things You Always Estimate
&lt;/h2&gt;

&lt;p&gt;Almost every system design problem boils down to:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Traffic (Requests per second)
&lt;/h3&gt;

&lt;p&gt;How many requests is the system handling?&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Storage
&lt;/h3&gt;

&lt;p&gt;How much data is being stored daily/yearly?&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Bandwidth
&lt;/h3&gt;

&lt;p&gt;How much data is flowing per second?&lt;/p&gt;




&lt;h2&gt;
  
  
  ⏱️ The Most Important Approximation
&lt;/h2&gt;

&lt;p&gt;To convert daily traffic into real-time load:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1 day ≈ 100,000 seconds&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This helps you quickly estimate requests per second.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔑 Example (Simple)
&lt;/h2&gt;

&lt;p&gt;If a system gets:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;10 million requests per day&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10,000,000 / 100,000 ≈ 100 requests per second
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That’s your working estimate.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚠️ Important Mindset Shift
&lt;/h2&gt;

&lt;p&gt;Back-of-the-envelope estimation is NOT about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;exact calculations&lt;/li&gt;
&lt;li&gt;perfect accuracy&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It IS about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;structured thinking&lt;/li&gt;
&lt;li&gt;reasonable assumptions&lt;/li&gt;
&lt;li&gt;fast approximation&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧩 Why beginners struggle
&lt;/h2&gt;

&lt;p&gt;Most beginners:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;try to be too accurate&lt;/li&gt;
&lt;li&gt;don’t know what to assume&lt;/li&gt;
&lt;li&gt;get stuck on numbers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead, you should:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;focus on structure first, numbers later&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🧠 Key takeaway
&lt;/h2&gt;

&lt;p&gt;You’re not trying to calculate perfectly.&lt;/p&gt;

&lt;p&gt;You’re trying to answer:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Is this system small, medium, or massive?”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  👉 What’s next?
&lt;/h2&gt;

&lt;p&gt;In Part 2, we’ll go deeper into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Requests per second (QPS)&lt;/li&gt;
&lt;li&gt;Mental shortcuts for fast estimation&lt;/li&gt;
&lt;li&gt;Real examples&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;If you found this helpful, feel free to share your thoughts 👇&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>backend</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Forever in Stories: Preserving the Memories We Never Want to Lose</title>
      <dc:creator>Saras Growth Space</dc:creator>
      <pubDate>Sat, 31 Oct 2026 07:52:06 +0000</pubDate>
      <link>https://dev.to/saras_growth_space/forever-in-stories-preserving-the-memories-we-never-want-to-lose-19mh</link>
      <guid>https://dev.to/saras_growth_space/forever-in-stories-preserving-the-memories-we-never-want-to-lose-19mh</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/hacktoberfest-week4-2026-10-26"&gt;Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Photographs preserve how someone looked. Stories preserve who they were.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;There are things we wish we had asked our grandparents.&lt;/p&gt;

&lt;p&gt;The story behind an old photograph. The reason they chose a particular name. Their childhood adventures, their first friendship, the challenges they overcame, or the little everyday moments that made them happy.&lt;/p&gt;

&lt;p&gt;Sometimes, we hear these stories repeatedly and assume there will always be another opportunity to listen.&lt;/p&gt;

&lt;p&gt;But memories are fragile. Voices become distant, details get forgotten, and stories that once filled a room can slowly disappear.&lt;/p&gt;

&lt;p&gt;What if we could use AI to help preserve these pieces of our lives?&lt;/p&gt;

&lt;p&gt;Not to recreate people. Not to manufacture conversations with those we have lost. But to make sure the real stories they shared are not lost with time.&lt;/p&gt;

&lt;p&gt;That is the idea behind &lt;strong&gt;Forever in Stories&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Forever in Stories?
&lt;/h2&gt;

&lt;p&gt;Forever in Stories is a proposed AI-powered family memory archive designed to help people collect, organize, preserve, and rediscover personal memories.&lt;/p&gt;

&lt;p&gt;It brings together different forms of memories:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Voice recordings of family members sharing their experiences.&lt;/li&gt;
&lt;li&gt;Photographs with personal stories attached to them.&lt;/li&gt;
&lt;li&gt;Old letters, handwritten notes, and family documents.&lt;/li&gt;
&lt;li&gt;Childhood memories and significant life experiences.&lt;/li&gt;
&lt;li&gt;Stories about family traditions, places, relationships, and important moments.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal is simple: turn scattered memories into an organized family archive that can be explored by future generations.&lt;/p&gt;

&lt;p&gt;Imagine a grandchild opening an old photograph and finding not just a date or a name, but the story behind it — told in the original words of the person who experienced it.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Would It Work?
&lt;/h2&gt;

&lt;p&gt;The experience would be designed to feel natural rather than technical.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Capture a memory&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A family member could record themselves talking about a memory, upload an old photograph, or add a written story.&lt;/p&gt;

&lt;p&gt;They would not need to follow a formal interview format. They could simply speak as they normally would.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Preserve the original&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The original recording, photograph, letter, or written account would remain part of the archive.&lt;/p&gt;

&lt;p&gt;AI would help organize the material, not replace or rewrite the original memory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Understand and organize&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An open-weight AI model could help transcribe recordings, summarize long stories, suggest titles, and identify useful details such as people, places, and approximate time periods.&lt;/p&gt;

&lt;p&gt;For example, a recording about a childhood summer could be organized under topics such as childhood, hometown, family, and school memories.&lt;/p&gt;

&lt;p&gt;Any extracted details would remain suggestions until a family member reviews them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Connect memories&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Different memories could be connected through people, places, events, and family relationships.&lt;/p&gt;

&lt;p&gt;A photograph, a voice recording, and a handwritten letter might all belong to the same chapter of a family's history.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Rediscover the stories&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Family members could search their archive using questions such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What stories did Grandpa share about his childhood?&lt;/li&gt;
&lt;li&gt;Do we have any memories connected to our old hometown?&lt;/li&gt;
&lt;li&gt;What was the story behind this photograph?&lt;/li&gt;
&lt;li&gt;Which recordings mention our family traditions?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The archive would help people find the memories they might otherwise never encounter.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Open Innovation Matters
&lt;/h2&gt;

&lt;p&gt;Family memories are deeply personal.&lt;/p&gt;

&lt;p&gt;Voice recordings, photographs, letters, and private family experiences should not have to become dependent on a third-party AI platform.&lt;/p&gt;

&lt;p&gt;This is where open-source and open-weight AI become especially meaningful.&lt;/p&gt;

&lt;p&gt;With suitable locally runnable models, the system could support transcription, organization, and search directly on a family's own device or private infrastructure.&lt;/p&gt;

&lt;p&gt;That creates several possibilities:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Privacy and control:&lt;/strong&gt; Families could keep sensitive recordings and documents within an environment they control.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Less dependence on one provider:&lt;/strong&gt; The AI components could be replaced as better open models become available.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Offline possibilities:&lt;/strong&gt; Once the required models are downloaded, selected features could work without a continuous internet connection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Long-term preservation:&lt;/strong&gt; Families could retain their original files and export their archive instead of depending entirely on a proprietary service.&lt;/p&gt;

&lt;p&gt;The exact models and licenses would need to be evaluated during implementation. Openness should not be treated as a substitute for security, consent, or responsible data handling.&lt;/p&gt;

&lt;h2&gt;
  
  
  The AI Should Assist, Not Invent
&lt;/h2&gt;

&lt;p&gt;There is an important distinction behind this idea.&lt;/p&gt;

&lt;p&gt;Forever in Stories should never pretend to bring someone back through AI-generated conversations or manufacture memories in their name.&lt;/p&gt;

&lt;p&gt;A summary is not the original story. An AI-generated interpretation is not someone's actual experience.&lt;/p&gt;

&lt;p&gt;The original recording, photograph, or letter must remain the source of truth.&lt;/p&gt;

&lt;p&gt;Families should be able to correct transcripts, approve summaries, control access, and remove material. People should also be able to choose what they want to share and what they want to keep private.&lt;/p&gt;

&lt;p&gt;The purpose is not to make memories artificial.&lt;/p&gt;

&lt;p&gt;It is to make real memories easier to preserve.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I Envision Building It
&lt;/h2&gt;

&lt;p&gt;This is currently a concept-stage proposal, not a completed application.&lt;/p&gt;

&lt;p&gt;The proposed architecture would combine:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Local speech-to-text:&lt;/strong&gt; To convert recorded family stories into searchable transcripts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open-weight language model:&lt;/strong&gt; To organize stories, suggest summaries, and extract reviewable metadata.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory storage:&lt;/strong&gt; To preserve original media, transcripts, descriptions, and connections between memories.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Semantic search:&lt;/strong&gt; To help family members discover related stories using natural-language questions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Human review:&lt;/strong&gt; To ensure that AI-generated descriptions and extracted details are approved before becoming part of the archive.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The AI would be one component of a larger preservation workflow. The archive, its organization, privacy controls, and ability to export original memories would be just as important.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Spirit of It
&lt;/h2&gt;

&lt;p&gt;Technology often focuses on helping us create something new.&lt;/p&gt;

&lt;p&gt;But perhaps one of its most meaningful uses is helping us hold on to something we already have.&lt;/p&gt;

&lt;p&gt;A voice recording might seem ordinary today. A handwritten letter might sit forgotten in a drawer. An old photograph might carry a story that only one person remembers.&lt;/p&gt;

&lt;p&gt;Years later, those things could become priceless.&lt;/p&gt;

&lt;p&gt;We cannot preserve every moment, and we cannot stop time. But we can make an effort to preserve the stories that give those moments meaning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Forever in Stories is built around one thought:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The people who shape our lives may not always be beside us, but the stories they leave behind can continue to bring generations closer.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Because sometimes, the most valuable thing we inherit is not something we own.&lt;/p&gt;

&lt;p&gt;It is a story someone once trusted us enough to share.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Concept submission for Week 4: Ghost in the Machine — Hacktoberfest Open-Source AI Challenge. No working implementation or demo is being claimed at this stage.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>hf26challenge</category>
      <category>ai</category>
    </item>
    <item>
      <title>LaterMate: Let AI Handle the Digital Mess You've Been Ignoring</title>
      <dc:creator>Saras Growth Space</dc:creator>
      <pubDate>Sun, 25 Oct 2026 11:35:20 +0000</pubDate>
      <link>https://dev.to/saras_growth_space/latermate-let-ai-handle-the-digital-mess-youve-been-ignoring-2o4m</link>
      <guid>https://dev.to/saras_growth_space/latermate-let-ai-handle-the-digital-mess-youve-been-ignoring-2o4m</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/hacktoberfest-week3-2026-10-19"&gt;Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem: I'll Organize It Later
&lt;/h2&gt;

&lt;p&gt;We all have that folder.&lt;/p&gt;

&lt;p&gt;The Downloads folder with hundreds of files. Screenshots we no longer remember taking. Documents named &lt;code&gt;final_v2_latest_revised.pdf&lt;/code&gt;. Random images, old invoices, duplicate-looking files, and documents we promised ourselves we would organize someday.&lt;/p&gt;

&lt;p&gt;Someday rarely comes.&lt;/p&gt;

&lt;p&gt;The problem isn't that organizing files is difficult. It's that every individual decision feels too small to justify the effort, until hundreds of those decisions become one enormous chore.&lt;/p&gt;

&lt;p&gt;What if we could stop postponing it and let AI take care of the repetitive work?&lt;/p&gt;

&lt;p&gt;That is the idea behind &lt;strong&gt;LaterMate&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is LaterMate?
&lt;/h2&gt;

&lt;p&gt;LaterMate is a proposed local AI assistant designed to organize digital clutter with minimal effort from the user.&lt;/p&gt;

&lt;p&gt;Instead of manually opening files, figuring out what they contain, renaming them, and dragging them into folders, users would let the assistant do the initial work.&lt;/p&gt;

&lt;p&gt;Imagine opening your Downloads folder after months of neglect.&lt;/p&gt;

&lt;p&gt;LaterMate could identify likely document types, suggest meaningful filenames, group related files, and prepare a proposed folder structure.&lt;/p&gt;

&lt;p&gt;An invoice might be suggested for an &lt;code&gt;Invoices&lt;/code&gt; folder. A résumé could be grouped under &lt;code&gt;Career&lt;/code&gt;. Screenshots might be organized by date or subject when that information is available.&lt;/p&gt;

&lt;p&gt;Instead of spending an evening cleaning up files, you would review a short summary of the proposed changes.&lt;/p&gt;

&lt;p&gt;The goal is simple: less repetitive work, fewer tiny decisions, and more time for things that actually matter.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Would It Work?
&lt;/h2&gt;

&lt;p&gt;The proposed experience would have four stages.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Scan the clutter
&lt;/h3&gt;

&lt;p&gt;The application would inspect filenames, file types, timestamps, and other permitted local metadata.&lt;/p&gt;

&lt;p&gt;For supported documents, a local text extractor could provide content for classification. The user would choose which folders the application is allowed to access.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Understand what each file is
&lt;/h3&gt;

&lt;p&gt;An open-weight language model running locally could classify ambiguous documents, identify likely topics, and suggest meaningful filenames.&lt;/p&gt;

&lt;p&gt;For example, a file named &lt;code&gt;scan_0048.pdf&lt;/code&gt; might contain a utility bill. The assistant could suggest a clearer name based on the extracted content and available date information.&lt;/p&gt;

&lt;p&gt;It should never invent details that aren't present in the file.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Prepare an organization plan
&lt;/h3&gt;

&lt;p&gt;LaterMate could suggest folders such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Work and projects&lt;/li&gt;
&lt;li&gt;Financial documents&lt;/li&gt;
&lt;li&gt;Career and learning&lt;/li&gt;
&lt;li&gt;Personal records&lt;/li&gt;
&lt;li&gt;Images and screenshots&lt;/li&gt;
&lt;li&gt;Files that need review&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Users could customize these categories to match their own habits.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Apply changes safely
&lt;/h3&gt;

&lt;p&gt;Before moving or renaming files, the application would show a preview of the proposed actions.&lt;/p&gt;

&lt;p&gt;Users could approve the changes, reject individual suggestions, or adjust the organization rules.&lt;/p&gt;

&lt;p&gt;A change log and an undo mechanism would help recover from mistakes. Ambiguous files would remain untouched rather than being forced into a category.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The ideal experience is to configure the rules once, review occasional summaries, and let the routine work happen in the background.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Open-Source AI?
&lt;/h2&gt;

&lt;p&gt;For a tool that interacts with personal documents, the way AI is deployed matters as much as what it can do.&lt;/p&gt;

&lt;h3&gt;
  
  
  Your files can stay on your machine
&lt;/h3&gt;

&lt;p&gt;Documents may contain financial records, employment information, personal correspondence, or private notes.&lt;/p&gt;

&lt;p&gt;A locally running open-weight model could classify supported documents without sending their contents to an external AI API.&lt;/p&gt;

&lt;p&gt;This would make privacy a design goal rather than an afterthought, provided the entire processing pipeline is configured to remain local.&lt;/p&gt;

&lt;h3&gt;
  
  
  No dependence on one AI provider
&lt;/h3&gt;

&lt;p&gt;A local application could use a model that fits the available hardware and replace it when a better option becomes available.&lt;/p&gt;

&lt;p&gt;The project would not need to depend on one provider's pricing, usage limits, or API availability for every classification request.&lt;/p&gt;

&lt;h3&gt;
  
  
  Customization for different people
&lt;/h3&gt;

&lt;p&gt;A freelancer might want invoices, client projects, and contracts separated. A student might prefer subjects, notes, and assignments. Someone managing a household might need receipts, warranties, and personal records.&lt;/p&gt;

&lt;p&gt;An open model could be evaluated and adapted for these categories, while ordinary file operations and safety rules would remain explicit application logic.&lt;/p&gt;

&lt;h3&gt;
  
  
  A practical path to lower recurring costs
&lt;/h3&gt;

&lt;p&gt;Once the required model and supporting components are installed, local inference could reduce per-request API expenses.&lt;/p&gt;

&lt;p&gt;It would not make the software entirely free: hardware, storage, electricity, maintenance, and development still have costs. The advantage is greater control over the operating model and the potential to serve users without charging for every AI interaction.&lt;/p&gt;

&lt;p&gt;Open weights alone do not guarantee unrestricted commercial use, so the model's license would need to be checked before distribution.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Not Let AI Organize Everything Automatically?
&lt;/h2&gt;

&lt;p&gt;Because a file organizer has the potential to make a frustrating mess much worse.&lt;/p&gt;

&lt;p&gt;A document may fit several categories. Two files with similar names may contain different information. A file that looks unimportant might be the only copy of something valuable.&lt;/p&gt;

&lt;p&gt;LaterMate would therefore use a cautious approach:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Preview proposed changes before applying them.&lt;/li&gt;
&lt;li&gt;Avoid permanent deletion by default.&lt;/li&gt;
&lt;li&gt;Detect filename conflicts before renaming.&lt;/li&gt;
&lt;li&gt;Keep an action history and support undo where possible.&lt;/li&gt;
&lt;li&gt;Leave uncertain files in a review folder.&lt;/li&gt;
&lt;li&gt;Respect user-defined access restrictions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;AI would make suggestions and handle routine decisions, but users would retain control over their files.&lt;/p&gt;

&lt;p&gt;The point of automation is to remove unnecessary effort, not to create a new problem that requires even more effort to fix.&lt;/p&gt;

&lt;h2&gt;
  
  
  Could LaterMate Become a Side Hustle?
&lt;/h2&gt;

&lt;p&gt;The potential customers are people who accumulate files faster than they can organize them.&lt;/p&gt;

&lt;p&gt;Freelancers could use it to manage client documents. Students could keep course materials organized. Small businesses could simplify document housekeeping without sending every file to a cloud-based AI service.&lt;/p&gt;

&lt;p&gt;A possible business model would be a free local version with basic organization features and a paid version offering configurable workflows, scheduled scans, advanced document classification, and organization rules for different folders.&lt;/p&gt;

&lt;p&gt;A small business edition could offer shared configuration and reporting while keeping document processing on approved machines.&lt;/p&gt;

&lt;p&gt;These are possible business models, not validated demand. Real users would need to test the experience before there could be credible claims about willingness to pay.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Would Build First
&lt;/h2&gt;

&lt;p&gt;The first prototype would focus on one narrow task: organizing a selected Downloads folder.&lt;/p&gt;

&lt;p&gt;It would scan permitted files, classify supported documents, propose clearer names and destination folders, and show a preview before making changes.&lt;/p&gt;

&lt;p&gt;A small open-weight model would handle the parts that require language understanding. Deterministic code would handle file operations, permissions, conflict checks, and change tracking.&lt;/p&gt;

&lt;p&gt;The prototype would then be evaluated against a manually organized sample folder. Useful measures would include classification accuracy, the number of suggestions users accept, processing time, and how often the assistant proposes an incorrect or ambiguous action.&lt;/p&gt;

&lt;p&gt;This is currently a project concept. No working application, benchmark results, user testing, or revenue is being claimed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Slow and Steady Is the Point
&lt;/h2&gt;

&lt;p&gt;We often think of productivity as doing more in less time.&lt;/p&gt;

&lt;p&gt;But sometimes productivity means no longer spending our limited attention on things that should not require it in the first place.&lt;/p&gt;

&lt;p&gt;You don't need to become a better digital cleaner. You need a system that makes digital clutter less demanding to manage.&lt;/p&gt;

&lt;p&gt;LaterMate explores whether open-source AI can help us build that system locally, privately, and with enough control to trust it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What if the smartest thing your AI assistant did today was take one tedious task off your hands—and then leave you alone?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That is the idea behind LaterMate: less organizing, fewer postponed chores, and more time for everything outside the screen.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>hf26challenge</category>
      <category>ai</category>
    </item>
    <item>
      <title>Fridge2Feast: What Can You Cook With What You Already Have?</title>
      <dc:creator>Saras Growth Space</dc:creator>
      <pubDate>Fri, 16 Oct 2026 15:55:03 +0000</pubDate>
      <link>https://dev.to/saras_growth_space/fridge2feast-what-can-you-cook-with-what-you-already-have-4j7l</link>
      <guid>https://dev.to/saras_growth_space/fridge2feast-what-can-you-cook-with-what-you-already-have-4j7l</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/hacktoberfest-week2-2026-10-12"&gt;Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem: A Fridge Full of Ingredients, but Nothing to Cook
&lt;/h2&gt;

&lt;p&gt;We've all been there.&lt;/p&gt;

&lt;p&gt;You open the fridge and find two tomatoes, half an onion, some leftover rice, a few vegetables, and perhaps a container of something you bought three days ago.&lt;/p&gt;

&lt;p&gt;There is food in the kitchen. But somehow, there is nothing to cook.&lt;/p&gt;

&lt;p&gt;You search for recipes online. The first recipe needs cream. The second needs a special sauce. The third requires ingredients you don't have.&lt;/p&gt;

&lt;p&gt;And before you know it, you're considering ordering food again.&lt;/p&gt;

&lt;p&gt;What if you could simply list the ingredients you already have and discover what you can make with them?&lt;/p&gt;

&lt;p&gt;That is the idea behind &lt;strong&gt;Fridge2Feast&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Fridge2Feast?
&lt;/h2&gt;

&lt;p&gt;Fridge2Feast is a proposed AI-powered cooking assistant that turns an everyday ingredient list into practical meal ideas.&lt;/p&gt;

&lt;p&gt;The goal isn't to generate the most impressive recipe. It's to help people make the best use of the food they already have.&lt;/p&gt;

&lt;p&gt;Imagine entering:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Potatoes&lt;/li&gt;
&lt;li&gt;Tomatoes&lt;/li&gt;
&lt;li&gt;Onions&lt;/li&gt;
&lt;li&gt;Spinach&lt;/li&gt;
&lt;li&gt;Leftover rice&lt;/li&gt;
&lt;li&gt;Basic Indian spices&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead of suggesting an elaborate recipe with a long shopping list, the assistant would prioritize realistic options based on those ingredients.&lt;/p&gt;

&lt;p&gt;Depending on the quantities and available pantry staples, suggestions might include a simple potato-and-spinach curry, a tomato-based vegetable dish, or a quick fried-rice variation.&lt;/p&gt;

&lt;p&gt;Each suggestion would explain which ingredients are required, which are optional, what substitutions might work, and what additional items—if any—are needed.&lt;/p&gt;

&lt;p&gt;The idea is simple: &lt;strong&gt;start with the ingredients, not the recipe.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Who Is It For?
&lt;/h2&gt;

&lt;p&gt;Fridge2Feast could be useful for several groups.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Students and people living alone&lt;/strong&gt; who want affordable meals without buying ingredients they will use only once.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Busy households&lt;/strong&gt; that need to turn leftover ingredients into another meal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Budget-conscious cooks&lt;/strong&gt; who want to make better use of their groceries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;People learning to cook&lt;/strong&gt; who have ingredients available but don't yet know how to combine them.&lt;/p&gt;

&lt;p&gt;For these users, the value isn't another collection of recipes. It's making the next cooking decision easier.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Would It Work?
&lt;/h2&gt;

&lt;p&gt;The proposed experience would have four steps.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Enter what you have
&lt;/h3&gt;

&lt;p&gt;Users could type a list of ingredients, such as:&lt;/p&gt;

&lt;p&gt;"Two potatoes, one onion, tomatoes, spinach, leftover rice."&lt;/p&gt;

&lt;p&gt;A future version could also accept a photograph of the fridge, although recognizing ingredients accurately from images would require additional testing.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Find realistic combinations
&lt;/h3&gt;

&lt;p&gt;An open-weight language model could interpret ingredient names, understand common substitutions, and generate candidate dishes.&lt;/p&gt;

&lt;p&gt;A separate ingredient-matching layer would check how closely each recipe fits what the user has available.&lt;/p&gt;

&lt;p&gt;Recipes that require fewer additional ingredients would be prioritized.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Show useful, honest suggestions
&lt;/h3&gt;

&lt;p&gt;Each dish could include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ingredients available and ingredients missing&lt;/li&gt;
&lt;li&gt;Estimated preparation time&lt;/li&gt;
&lt;li&gt;Simple cooking instructions&lt;/li&gt;
&lt;li&gt;Optional substitutions&lt;/li&gt;
&lt;li&gt;A clear distinction between essential and optional ingredients&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The assistant should never pretend that a recipe is fully achievable when a necessary ingredient is missing.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Help use food before it goes to waste
&lt;/h3&gt;

&lt;p&gt;Users could optionally mark ingredients they want to use soon.&lt;/p&gt;

&lt;p&gt;The system could prioritize suitable recipes around those ingredients, while reminding users that appearance or an AI-generated suggestion cannot reliably establish whether food is safe to eat.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Open-Source AI?
&lt;/h2&gt;

&lt;p&gt;For Fridge2Feast, open innovation could offer more than an alternative model provider.&lt;/p&gt;

&lt;h3&gt;
  
  
  Local processing and privacy
&lt;/h3&gt;

&lt;p&gt;A locally running open-weight model could process ingredient lists without sending them to a third-party AI API.&lt;/p&gt;

&lt;p&gt;This could be useful for people who prefer to keep their household routines and food preferences private.&lt;/p&gt;

&lt;p&gt;Actual offline operation would depend on downloading the model and all required assets in advance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adaptation to local cooking
&lt;/h3&gt;

&lt;p&gt;Food isn't universal.&lt;/p&gt;

&lt;p&gt;An ingredient combination that works in one cuisine may be unusual in another. A useful assistant should understand familiar dishes, regional ingredient names, common pantry staples, and practical substitutions.&lt;/p&gt;

&lt;p&gt;An open model could be evaluated, prompted, or fine-tuned for these needs, subject to its license and available hardware.&lt;/p&gt;

&lt;h3&gt;
  
  
  More predictable operating costs
&lt;/h3&gt;

&lt;p&gt;A small model running on a user's own device could reduce recurring inference costs and avoid dependence on a paid API for every recipe request.&lt;/p&gt;

&lt;p&gt;Local inference would still have hardware, electricity, and maintenance costs. The objective would be to make the economics more sustainable, not to pretend that running AI is entirely free.&lt;/p&gt;

&lt;h3&gt;
  
  
  Freedom to improve the system
&lt;/h3&gt;

&lt;p&gt;The model could be changed as better options become available. Recipe matching, dietary preferences, and food-safety constraints could be handled by explicit application logic instead of relying entirely on generated text.&lt;/p&gt;

&lt;p&gt;That combination of adaptable models and inspectable rules is central to the proposed design.&lt;/p&gt;

&lt;h2&gt;
  
  
  Could This Become a Side Hustle?
&lt;/h2&gt;

&lt;p&gt;The potential customers are people who cook regularly and want to save time, money, or food.&lt;/p&gt;

&lt;p&gt;A possible business model would be a free basic ingredient-to-recipe experience, with a paid tier for features such as weekly meal planning, household profiles, pantry tracking, and shopping-list generation.&lt;/p&gt;

&lt;p&gt;Another possibility would be a low-cost product for shared households or budget-conscious meal planners.&lt;/p&gt;

&lt;p&gt;These are hypotheses, not validated business results. Before charging anyone, the concept would need to be tested with real users to understand which features they value enough to pay for.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Would Build First
&lt;/h2&gt;

&lt;p&gt;Rather than starting with a complicated application, the first prototype would focus on one job:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Accept an ingredient list.&lt;/li&gt;
&lt;li&gt;Suggest three suitable dishes.&lt;/li&gt;
&lt;li&gt;Show missing ingredients honestly.&lt;/li&gt;
&lt;li&gt;Provide simple instructions.&lt;/li&gt;
&lt;li&gt;Prioritize using available ingredients.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The prototype could use a small open-weight model through a local inference runtime, supported by structured ingredient matching and basic cooking constraints.&lt;/p&gt;

&lt;p&gt;The next step would be to compare its suggestions against a conventional recipe-search workflow and ask home cooks whether it actually helps them prepare meals more easily.&lt;/p&gt;

&lt;p&gt;This is currently a project concept, not a completed application. No working demo, user testing, or revenue is being claimed.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Bigger Idea
&lt;/h2&gt;

&lt;p&gt;We often think of AI as a way to create more content, more options, and more things to consume.&lt;/p&gt;

&lt;p&gt;But sometimes the useful answer is much simpler.&lt;/p&gt;

&lt;p&gt;You don't need another grocery order. You don't need another recipe requiring ten unfamiliar ingredients. You might already have enough to make a good meal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What if AI helped us make better use of what we already have?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's the question behind Fridge2Feast: less food waste, fewer unnecessary purchases, and a practical path from a list of ingredients to dinner.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>hf26challenge</category>
      <category>opensource</category>
      <category>ai</category>
    </item>
    <item>
      <title>What If the Sounds of Our Childhood Could Bring Us Back Outside?</title>
      <dc:creator>Saras Growth Space</dc:creator>
      <pubDate>Mon, 12 Oct 2026 03:51:05 +0000</pubDate>
      <link>https://dev.to/saras_growth_space/what-if-the-sounds-of-our-childhood-could-bring-us-back-outside-1756</link>
      <guid>https://dev.to/saras_growth_space/what-if-the-sounds-of-our-childhood-could-bring-us-back-outside-1756</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/hacktoberfest-week1-2026-10-05"&gt;Hacktoberfest Open-Source AI Challenge Week 1: Touch Grass&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Idea: Nostalgia as a Reason to Step Outside
&lt;/h2&gt;

&lt;p&gt;Do you remember the sound of children playing outside in the evening?&lt;/p&gt;

&lt;p&gt;The distant sound of a ball hitting the ground. Someone calling a friend home. Birds returning to the trees. Leaves moving in the wind. The familiar, unplanned noise of a neighborhood that seemed to come alive as the day slowed down.&lt;/p&gt;

&lt;p&gt;For many of us, these sounds belong to a childhood when going outside wasn't something we had to schedule. We simply stepped out.&lt;/p&gt;

&lt;p&gt;Today, we can spend hours surrounded by digital content while feeling strangely disconnected from the world outside our windows.&lt;/p&gt;

&lt;p&gt;What if, instead of sending another notification that says &lt;em&gt;"Go touch grass,"&lt;/em&gt; we used the sounds associated with our happiest outdoor memories to encourage us to do just that?&lt;/p&gt;

&lt;p&gt;That is the idea behind &lt;strong&gt;Echoes of Yesterday&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It is a concept for a nostalgia-inspired, AI-assisted experience designed to help people reconnect with the outdoors through familiar environmental sounds.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Echoes of Yesterday?
&lt;/h2&gt;

&lt;p&gt;The idea is simple: choose a memory, listen to a short soundscape, and let that experience become an invitation to step outside.&lt;/p&gt;

&lt;p&gt;Imagine opening the experience and choosing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;An evening from childhood:&lt;/strong&gt; Children playing, distant conversations, a ball bouncing, and the atmosphere of a neighborhood at dusk.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A quiet afternoon:&lt;/strong&gt; Birds chirping, a soft breeze, rustling leaves, and the occasional sound of life nearby.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A rainy day:&lt;/strong&gt; Raindrops on the ground, water flowing along a street, and the gentle ambience of a familiar rainy afternoon.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A summer holiday:&lt;/strong&gt; Crickets, trees moving in the wind, distant laughter, and the feeling of a long, unhurried day.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These would not be recordings of a user's actual past. They would be carefully composed soundscapes inspired by the kinds of experiences people remember.&lt;/p&gt;

&lt;p&gt;The goal would not be to keep someone listening to a screen for twenty minutes.&lt;/p&gt;

&lt;p&gt;It would be to create a small moment of recognition, then encourage them to experience the real world around them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The screen starts the experience. The world outside completes it.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How Would It Work?
&lt;/h2&gt;

&lt;p&gt;The proposed experience would have three simple stages.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Choose a feeling or memory
&lt;/h3&gt;

&lt;p&gt;Instead of asking users to write a long prompt, the experience could offer simple choices:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The neighborhood where I grew up&lt;/li&gt;
&lt;li&gt;Playing outside until sunset&lt;/li&gt;
&lt;li&gt;Rainy afternoons&lt;/li&gt;
&lt;li&gt;A garden or a field&lt;/li&gt;
&lt;li&gt;Quiet mornings filled with birdsong&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Users could also describe a memory in their own words.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Let open-source AI compose a soundscape
&lt;/h3&gt;

&lt;p&gt;An open-weight language model running locally could interpret the user's description and convert it into a structured soundscape plan.&lt;/p&gt;

&lt;p&gt;For example, a memory of playing outside at sunset might become a sequence of environmental sounds, with children playing in the distance, a few birds, a gentle breeze, and the gradual quiet of evening.&lt;/p&gt;

&lt;p&gt;The soundscape could be assembled from appropriately licensed audio recordings rather than relying on a closed, cloud-based AI service to generate everything.&lt;/p&gt;

&lt;p&gt;The model would decide how the elements fit together; the audio assets would provide the actual sounds.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Take the experience outside
&lt;/h3&gt;

&lt;p&gt;After a short listening session, the experience could offer one gentle invitation:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Step outside for five minutes. Notice the sounds that are already there.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;No endless feed. No streaks to maintain. No pressure to turn relaxation into another productivity goal.&lt;/p&gt;

&lt;p&gt;Just a small bridge between a remembered world and the one that still exists around us.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Open-Source AI?
&lt;/h2&gt;

&lt;p&gt;For this idea, open innovation would not simply be a technical preference. It could shape the experience itself.&lt;/p&gt;

&lt;h3&gt;
  
  
  Personalization without sending memories to a server
&lt;/h3&gt;

&lt;p&gt;Childhood memories can be deeply personal. A locally running model could interpret a memory description on the user's device, without requiring that description to be sent to a third-party AI API.&lt;/p&gt;

&lt;p&gt;That would make privacy a design choice rather than an afterthought, provided the eventual implementation keeps processing and storage local.&lt;/p&gt;

&lt;h3&gt;
  
  
  The freedom to change the model
&lt;/h3&gt;

&lt;p&gt;An open-weight model could be replaced with another model that performs better at understanding short descriptions, producing structured outputs, or running on modest hardware.&lt;/p&gt;

&lt;p&gt;The experience would not need to be permanently tied to one provider's API, pricing, or model behavior.&lt;/p&gt;

&lt;h3&gt;
  
  
  A potentially offline experience
&lt;/h3&gt;

&lt;p&gt;If the model and licensed audio assets were downloaded in advance, the core experience could eventually work without an internet connection.&lt;/p&gt;

&lt;p&gt;Someone sitting in a garden, visiting a park, or walking along a quiet path would not need a continuous connection to a cloud service.&lt;/p&gt;

&lt;h3&gt;
  
  
  More control over the experience
&lt;/h3&gt;

&lt;p&gt;The project could use a small, constrained model prompt and a predefined sound library rather than giving an AI unrestricted control over the experience.&lt;/p&gt;

&lt;p&gt;This would make the output easier to inspect, customize, and reproduce.&lt;/p&gt;

&lt;p&gt;Open-source components would not automatically make the experience free, private, or offline. Those properties would depend on the selected model's license, hardware requirements, audio licenses, and implementation. But open technology would give the project more room to make those choices deliberately.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why This Fits the Touch Grass Theme
&lt;/h2&gt;

&lt;p&gt;Many digital products compete for our attention by giving us more to watch, read, or listen to.&lt;/p&gt;

&lt;p&gt;Echoes of Yesterday would explore the opposite direction.&lt;/p&gt;

&lt;p&gt;Could technology help us remember the pleasure of being outside, then give us a reason to put the device away?&lt;/p&gt;

&lt;p&gt;The experience would be deliberately short. Its success would not be measured by session length or the number of times someone opens the app. A more meaningful outcome would be whether someone actually steps outside, notices their surroundings, or spends a few quiet minutes away from a screen.&lt;/p&gt;

&lt;p&gt;The soundscape is the invitation, not the destination.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Would Like to Explore Next
&lt;/h2&gt;

&lt;p&gt;This is currently a project concept, not a completed or tested application.&lt;/p&gt;

&lt;p&gt;The next steps would be to identify a suitable open-weight model, assemble a small collection of properly licensed environmental recordings, and build a minimal prototype that turns a memory description into a playable soundscape.&lt;/p&gt;

&lt;p&gt;I would also want to test the idea with real people. Do familiar environmental sounds genuinely make someone more inclined to go outside, or do they simply provide another enjoyable digital experience?&lt;/p&gt;

&lt;p&gt;That distinction matters.&lt;/p&gt;

&lt;p&gt;Nostalgia should be an invitation to engage with life, not a substitute for it.&lt;/p&gt;

&lt;h2&gt;
  
  
  One Last Thought
&lt;/h2&gt;

&lt;p&gt;We often use technology to create something new for ourselves.&lt;/p&gt;

&lt;p&gt;Perhaps sometimes it can help us rediscover something we already know.&lt;/p&gt;

&lt;p&gt;The sound of children playing outside. Wind moving through trees. Birds calling from somewhere nearby. The ordinary sounds of a world that existed before every quiet moment needed a screen to fill it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What if the best use of AI were not to keep us online longer, but to help us remember why we want to go outside in the first place?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That is the possibility I would like to explore with Echoes of Yesterday.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This is an early-stage concept. No working application, demo, or real-world user testing is being claimed in this article.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>hf26challenge</category>
    </item>
  </channel>
</rss>
