sample.env


Overview

The `sample.env` file serves as a template for environment variables necessary to configure and run the application. It defines both secret keys and public configuration parameters that the software uses to connect to APIs, set logging levels, and specify the network environment. This file is typically used as a reference to create an actual `.env` file containing sensitive information and deployment-specific values. It helps maintain a clear separation between code and configuration, enabling easier environment management across development, staging, and production setups.


Detailed Explanation of Contents

This file contains two main sections:

1. Secret Environment Variables

These variables hold sensitive information, such as API keys, which should **never** be committed to version control or exposed publicly.

2. Public Environment Variables

These are configuration parameters that define service endpoints, logging behavior, and network selection.


Usage Example

When setting up the project, developers copy `sample.env` to `.env` and fill in the secret keys:

cp sample.env .env

Then edit `.env` to add the actual API keys:

INDEXER_API_KEY=your_real_indexer_api_key
RPC_API_KEY=your_real_rpc_api_key

The application reads these environment variables at runtime (commonly via libraries like `dotenv` in Node.js or equivalents in other languages) to configure service connections.


Implementation Details and Best Practices


Interaction with Other Parts of the System

This file is foundational for the application's configuration layer, influencing multiple system components that rely on external services and environment-specific settings.


Visual Diagram

The following flowchart illustrates how the environment variables defined in this file are consumed by different parts of the application to establish configurations and service connections.

flowchart TD
    subgraph sample.env
        SECRETS[Secret Keys]
        CONFIGS[Public Configs]
    end

    SECRETS --> INDEXER_API_KEY["INDEXER_API_KEY"]
    SECRETS --> RPC_API_KEY["RPC_API_KEY"]

    CONFIGS --> INDEXER_URL["INDEXER_URL"]
    CONFIGS --> INDEXER_WS_URL["INDEXER_WS_URL"]
    CONFIGS --> LOG_LEVEL["LOG_LEVEL"]
    CONFIGS --> NETWORK["NETWORK"]
    CONFIGS --> RPC_URL["RPC_URL"]

    INDEXER_API_KEY --> BackendServices["Backend Services (API Authentication)"]
    RPC_API_KEY --> BackendServices

    INDEXER_URL --> IndexerClient["Indexer REST Client"]
    INDEXER_WS_URL --> IndexerWSClient["Indexer WebSocket Client"]
    RPC_URL --> RPCClient["RPC Client"]

    LOG_LEVEL --> LoggingModule["Logging Module"]

    NETWORK --> NetworkConfigModule["Network Configuration Module"]

    BackendServices -->|Uses| IndexerClient
    BackendServices -->|Uses| RPCClient
    IndexerWSClient -->|Receives Events| RealTimeProcessor["Real-time Data Processor"]

Summary

The `sample.env` file is a critical configuration template that defines both secret credentials and public parameters necessary for the application to connect to external APIs, set logging verbosity, and select the network environment. It is designed for ease of use, security, and flexibility, enabling developers and deployment pipelines to configure the system without modifying source code. This file underpins the connectivity and operational behavior of multiple subsystems within the software architecture.