Преглед изворни кода

explorer/site: enhance explorer site README.md

Expanded site README documentation to provide updated instructions reflecting the latest code.

Summary of Updates:
- Updated overall project description
- Included a key features section detailing core site functionality
- Reorganized the Usage section into a Getting Started section, separating prerequisites, installation, and running the application
- Moved supporting daemons and explorerd-related setup to explorerd/README.md and explorer/README.md
- Added a configuration section describing the site's configuration options
- Added a Logging section providing insights on the site's use of logs, log locations, log output, and log level configuration
kalm пре 1 година
родитељ
комит
aa42428f23
1 измењених фајлова са 122 додато и 29 уклоњено
  1. 122 29
      bin/explorer/site/README.md

+ 122 - 29
bin/explorer/site/README.md

@@ -1,46 +1,139 @@
-Blockchain explorer web front-end
-=======
+# DarkFi Explorer Site
 
-This is a very basic python based web front-end, based on `flask`,
-to serve static pages with blockchain data.
+The Explorer Site is a python based web application that serves as the user interface for viewing DarkFi blockchain data. It provides an interactive way to explore blockchain information, gas analytics, and DarkFi native contract source code, connecting with explorer nodes for real-time data.
 
-## Usage
+## Key Features
 
-We fist have to run 2 other daemons, to retrieve data from.
-Note: all paths are from repo root.
+- **Explorer Node Integration**: Enables real-time blockchain data retrieval, ensuring a consistent and accurate view of blockchain data across supported networks.
+- **View Blockchain Data**: View and navigate block and transaction data.
+- **Gas Analytics**: Access detailed gas usage metrics across the blockchain and per-transaction basis.
+- **Contract Source Code Navigation**: Inspect native contract source code implementations directly.
 
-First we start a `darkfid` localnet:
+## Getting Started
 
-```
-% cd contrib/localnet/darkfid-single-node/
-% ./tmux_sessions.sh
+### Prerequisites
+- Python 3.12
+- Additional dependencies listed in `requirements.txt`
+
+### Installation
+
+Install dependencies:
+```bash
+pip install -r requirements.txt
 ```
 
-It is advised to shutdown the `minerd` daemon after couple of blocks, to not waste resources.
+## Configuration
 
-Update the `explorerd` configuration to the localnet `darkfid` JSON-RPC endpoint
-and start the daemon:
+The application uses a TOML configuration file to manage different environment settings located at [Site Config](site_config.toml).
 
-```
-% cd bin/explorer/explorerd
-% make install
-% explorerd -c explored_config.toml  
-```
+### Example Configuration
 
-Then we enter the site folder and we generate a new python virtual environment,
-source it and install required dependencies:
+Below is an example configuration for `localnet`.
 
+```toml
+[localnet]
+# Explorer daemon JSON-RPC endpoint URL
+explorer_rpc_url = "127.0.0.1"
+
+# Explorer daemon JSON-RPC port
+explorer_rpc_port = 14567
+
+# Path to store log files
+log_path = "~/.local/share/darkfi/explorer_site/localnet"
 ```
-% cd bin/explorer/site
-% python -m venv venv
-% source venv/bin/activate
-% pip install -r requirements.txt
-```
 
-To start the `flask` server, simply execute:
+### Pre-Configured Networks
+
+The Explorer Site supports the following pre-configured `explorerd` environments out of the box.
+- **`localnet`**: An environment for testing and running `explorerd` locally.
+- **`testnet`**: A testing environment for validating the site's functionality prior to mainnet (pending availability).
+- **`mainnet`**: The live production environment connected to the canonical DarkFi blockchain network (pending availability).
+
+> Once the DarkFi blockchain testnet and mainnet are fully available, the Explorer Site will show more than just the genesis blocks for these networks.
 
+Each network environment corresponds to a pre-configured explorerd configuration defined in [Explorerd Config](../explorerd/explorerd_config.toml).
+
+### Custom Configurations
+
+The Explorer Site supports custom configurations to connect to an Explorer Node, whether running locally on the same machine or remotely on a different network. Proper alignment between the Explorer Site and Explorer Node configurations is essential to ensure the site displays blockchain data.
+
+#### Connecting to a Remote Explorer Node
+
+To enable a remote setup, such as for designers testing their UI design, the Explorer Site can be configured to connect to a remote Explorer Node.
+
+To connect to a remote node, configure the Explorer RPC URL and port in the `site_config.toml` file. Ensure that the domain address and port correspond to the remote node's settings.
+
+**Example Configuration for a Testnet**:
+
+`site_config.toml`:
+
+```toml
+[testnet]
+explorer_rpc_url = "remote-explorer-node.com"
+explorer_rpc_port = 80
 ```
-% python -m flask run
+
+Replace `remote-explorer-node.com` with the domain of your remote node and adjust the port as needed for your specific setup.
+
+#### Connecting to a Local Explorer Node
+
+When running the Explorer Node and Site on the same machine with a custom configuration, make sure the RPC URL and port in `site_config.toml` match the `rpc_listen` settings in `explorerd_config.toml` to establish connectivity with the node.
+
+**Example Local Configuration Alignment**:
+
+- **`site_config.toml`**:
+
+  ```toml
+  [localnet]
+  explorer_rpc_url = "127.0.0.1"
+  explorer_rpc_port = 14567
+  ```
+  
+- **`explorerd_config.toml`**:
+
+  ```toml
+  [network_config."localnet"]
+  rpc_listen = "tcp://127.0.0.1:14567"
+  ```
+
+## Running the Application
+
+Launch the application using the Flask server:
+
+```bash
+FLASK_ENV=<environment> python -m flask run
 ```
 
-The web site will be available at `127.0.0.1:5000`.
+Where `<environment>` can be:
+- `localnet` - To run locally.
+- `testnet` - For testing environment.
+
+## Logging
+
+The Explorer Site provides logs that can be inspected to resolve issues and understand runtime behavior. The logging behavior adapts based on the environment setting. In `localnet`, logs are written to both console and files to assist with development and debugging, while `testnet` uses standard file handlers for log files only. For production use, `mainnet` employs rotating file handlers that maintain logs.
+
+### Log Locations
+
+The log files are stored in environment-specific directories:
+
+| Environment | Log Path |
+|------------|----------|
+| Localnet | `~/.local/share/darkfi/explorer_site/localnet` |
+| Testnet | `~/.local/share/darkfi/explorer_site/testnet` |
+| Mainnet | `~/.local/share/darkfi/explorer_site/mainnet` |
+
+### Log Output
+
+The logging system maintains two log files in each environment directory:
+
+| Log File | Purpose |
+|----------|---------|
+| `app.log` | Application logs and HTTP requests |
+| `error.log` | Application errors |
+
+### Log Level Configuration
+
+The logging level can be set using the `LOG_LEVEL` environment variable:
+```bash
+LOG_LEVEL=DEBUG FLASK_ENV=localnet python -m flask run
+```