How crefax/bazaar-api works
Project Type and Purpose
• This is a backend‐only, Rust-based REST API service (“Bazaar API”) whose sole purpose is to track, store, and serve Hypixel SkyBlock Bazaar price data.
• There is no user-facing frontend; instead you have:
• A “tracker” component that polls or receives Bazaar data from Hypixel’s external service
• A MongoDB database for persistence
• A set of HTTP API endpoints for clients to query current and historical data
File Structure
• src/main.rs
• Bootstraps the whole service, wires together the API server, tracker, and database layer
• src/api
• api.rs / mod.rs define HTTP routes (GET /api/skyblock/bazaar/{product_id} and history)
• src/db
• db.rs / mod.rs hold MongoDB connection logic and CRUD methods
• src/tracker
• tracker.rs / mod.rs contain logic that periodically fetches Bazaar data from Hypixel and writes it to MongoDB
• src/models
• models.rs / mod.rs define the BazaarData struct (product_id, buy_price, etc.) used by both tracker and API
README for Additional Insights
• Confirms tech stack: Rust, MongoDB
• Describes the two main feature sets: “latest data” and “historical data” endpoints
Main Components & Their Interactions
a. External Hypixel Bazaar Data Source
• The public Hypixel API or data feed that the tracker polls
b. Tracker Component
• Periodically issues REST calls to the external service, transforms the JSON into BazaarData models, and writes to MongoDB
c. MongoDB Database
• Stores each BazaarData record, indexed by product_id and timestamp
d. API Server Component
• Exposes two endpoints under /api/skyblock/bazaar
• On request, reads from MongoDB via the db module and returns JSON
e. Clients
• Any external consumer (web app, analytics tool, cron job) that calls the API
Architectural Patterns & Design Principles
• Layered Architecture (also known as the 3-tier pattern):
• Data layer (src/db)
• Business logic / service layer (src/tracker + any future domain logic)
• Presentation / API layer (src/api)
• Single binary composed of modules: no microservices, but clear separation of concerns
• Asynchronous I/O (presumably using Tokio or async-std under the hood) for non-blocking tracker and HTTP server
Detail Without Over-Complication
• External interactions (Hypixel and clients)