How subscan-explorer/subscan-essentials works
Main Components
• Backend Service: The Go code under directories like “cmd”, “configs”, “internal”, “model”, “pkg”, “plugins”, “util”, etc. This service handles blockchain data indexing (blocks, extrinsics, events, logs, etc.), processing configuration, and providing HTTP API endpoints.
• API Server: Located under “internal/server/http”, this component handles RESTful APIs that the frontend communicates with.
• Database & Cache: The configuration files in “configs” (and instructions in the README) indicate usage of MySQL (for persistent datastore) and Redis (for caching and possibly pub/sub mechanisms).
• Plugin System: Notice the “plugins” folder with modules for “balance” and “system”. This shows the architecture is extensible via plugins.
• UI / Frontend: The “ui” folder, developed with Nuxt.js, manages the user interface and communicates with the backend API.
• Configuration and Deployment: Files such as “Dockerfile”, “docker-compose.yml”, and config files in “configs” illustrate how the project is deployed and configured.
Relationships and Interactions
• The UI communicates with the HTTP API (internal/server/http) over RESTful endpoints.
• The API Server interacts with the business logic found under the “internal/service” directory.
• The data access layer (“internal/dao”, “plugins/*/dao”) handles MySQL and Redis interactions, making use of ORM or direct database calls.
• The plugin system allows custom parsing or extended indexing; plugins integrate with the core service logic and additional HTTP endpoints.
• Order of operation: Client UI → API Gateway → Service Layer → DAO Layer → Database/Cache.
Architectural Patterns and Design Principles
• Separation of Concerns: The project neatly separates configuration, API handling, business logic, data access, and UI logic.
• Modular Plugin Architecture: This allows additional functionality (such as supporting new protocol features) to be added without modifying the core system.
• Micro-Service/Component-Oriented Design: Although it is a monorepo, the clear separation between “internal” (backend), “plugins”, and “ui” components illustrates loosely coupled parts.
• Clear configuration management using external config files (YAML and TOML) to decouple environment-specific settings.
Technologies and Frameworks
• Backend: Written in Go.
• UI: Built using Nuxt.js (Vue.js framework) and AMIS.
• Database: MySQL.
• Caching: Redis.
• Containerization: Docker and docker-compose for quick deployment.
• CI/CD: GitHub Actions (observed in “.github/workflows”) indicate automated testing/building.
• Code Quality: Tools such as golangci-lint are integrated (note the “.golangci.yml”).