How ausaf007/uniswap-tracker works
Project type and purpose
• This is a single-responsibility microservice written in Go using the Fiber web framework.
• Its purpose is to continuously track on-chain data from Uniswap V3 pools via an Ethereum JSON-RPC endpoint, persist that data in a SQLite database, and expose it over a RESTful API.
File structure analysis
Top-level directories and their roles:
• bindings/ — auto-generated Go wrappers for Uniswap V3 smart contracts (ERC20 & Pool ABI).
• database/ — initialization and wrappers around the SQLite3 datastore.
• handlers/ — HTTP route handlers (REST endpoints) using Fiber.
• models/ — domain objects for pools and pool data.
• services/ — background “tracker” logic that pulls events/state from Ethereum via go-ethereum RPC.
• main.go & config.json — application entrypoint and configuration (RPC URL, pool address, polling cadence, etc.).
Key insights from README
• Continuously polls a configured Uniswap V3 pool via JSON-RPC (go-ethereum).
• Buffers and writes pool state to SQLite every N blocks.
• Exposes endpoints for latest snapshot, specific block data, historic series, and pool mapping.
Components and interactions
a. Main components:
1) External Ethereum Node (e.g., Infura, geth)
2) Tracker Service (services/tracker.go + bindings/)
3) SQLite Database (database/database.go + models/)
4) Fiber HTTP Server (handlers/pool.go)
5) Clients (curl, Postman, browser)
b. Relationships & data flow:
• Tracker Service polls the Ethereum Node via go-ethereum JSON-RPC → parses events/state via contract bindings → transforms into domain models → writes to SQLite.
• Fiber HTTP Server receives client REST calls → queries SQLite via database layer → marshals model objects to JSON → returns response.
• Config.json drives RPC endpoint, target pool address, polling interval, log frequency.
c. Architectural patterns & design principles:
• Modular layering:
• “bindings” package isolates low-level contract ABI details.
• “services” implements the domain use-case of tracking.
• “database” abstracts persistence details.
• “handlers” layer translates domain models into HTTP resources.
• Single responsibility per package.
• Configuration-driven polling loop.
d. Key technologies/frameworks:
• Go 1.20+
• Fiber (HTTP routing)
• go-ethereum (ethclient, JSON-RPC)
• SQLite3 (via mattn/go-sqlite3)
• Go bindings for Uniswap V3 (abigen output)
Capturing essential elements
• Don’t omit the config.json’s role in wiring the RPC endpoint and poll cadence.
• “bindings” sub-system as a distinct block that converts raw ABI into Go structs/methods.
• If space allows, include notes on retry/backoff or error-handling loops in the Tracker component.