How madhavawasthi6430/explorer works
Main Components
a. Client/User Interface:
• Represented by the static assets under the "public" directory (images, JavaScript, stylesheets, themes) and the jade templates under "views" that generate the HTML.
• This is the front-end layer that communicates with the backend over HTTP.
b. Application Server:
• The entry point is app.js, and its behavior is managed via multiple processes:
• Cluster support: see bin/cluster and bin/instance scripts for forking the process across CPU cores.
• Routes (the "routes" folder) that process incoming requests.
• Controllers and views (jade templates in "views") to render the final pages.
• Libraries in "lib" (e.g. explorer.js, settings.js, market integrations in lib/markets) offer core functionality for blockchain exploration and market data.
• Configuration via settings.json (copied from settings.json.template).
c. Data Layer (Database):
• MongoDB is the backend data store (as described in README with instructions to create a database and user).
• Models in the "models" folder represent various blockchain data points (addresses, transactions, blocks, peers, richlist, stats).
d. External Interfaces and Services:
• Blockchain Wallet / Node: The explorer expects a compatible blockchain daemon running with “-daemon -txindex” flags for blockchain synchronization.
• Market Data APIs: Within the "lib/markets" directory, there are several modules (for bittrex, bleutrade, etc.) that likely interact with external cryptocurrency market services.
e. Synchronization Scripts:
• Scripts located in the "scripts" folder (sync.js, peers.js, benchmark.js) are used to periodically sync the local database with on-chain data (and possibly external market data) and handle peer discovery.
• These scripts are intended to be triggered via cron jobs.
Relationships and Interactions
• The Client Browser sends HTTP requests to the Application Server.
• The Application Server processes these requests via route handlers. It uses the libraries (in "lib") for business logic and the models (in "models") for database interactions.
• The Application Server communicates with:
• MongoDB for storing and retrieving blockchain data.
• The blockchain wallet node (external) for obtaining up-to-date block, transaction, and network data.
• External cryptocurrency market APIs (triggered through modules in lib/markets) to gather market data.
• The synchronization scripts periodically update the data stored in MongoDB by pulling new information from the blockchain and market services.
• Cluster mode (handled by the scripts in the "bin" directory) improves performance and availability by distributing workload across CPU cores.
Architectural Patterns and Design Principles
• MVC-like separation:
• Models (data structure in the "models" folder)
• Views (jade templates under "views" and styling in "public/stylesheets")
• Controllers/Routes (in the "routes" folder)
• Modular Design:
• Core functionalities are encapsulated in separate modules (e.g., explorers, market modules, localization).
• Clustering for Scalability:
• The use of cluster mode (forking processes per CPU core via scripts in "bin") shows an emphasis on performance and fault-tolerance.
• Asynchronous Task Scheduling:
• Use of scripts (sync.js, peers.js) that are meant to be scheduled via cron jobs to update blockchain and market data in the database.