How raahuldaksh/ec2--last-server-standing works
Last Server Standing is a high-concurrency flash-sale shop API. Clients send HTTP requests to the Fastify server; routes validate product, purchase, and order-history requests, services perform the domain operations, and SQLite persists product and order state. Product reads and stock updates also use an in-memory cache. The graph includes the server’s worker startup and route-registration layers. The README documents health checks and the API capabilities; unsampled schema details and other implementation relationships are not inferred.
Main entry points: app.js Fastify app · errors.js Domain errors · productService.js Product operations · orderService.js Order operations
Components 15
Server runtime
- Worker startup
src/server.js - Fastify app
src/app.js
HTTP API
- Health endpoint
src/routes/health.js - Product routes
src/routes/products.js - Order route
src/routes/orders.js - User history route
src/routes/users.js
Shop operations
- Product operations
src/services/productService.js - Order operations
src/services/orderService.js - Domain errors
src/utils/errors.js
State and configuration
- Product cache
src/cache/productCache.js - Category cache
src/services/productService.js - SQLite connection
src/db/connection.js - Shop database
src/db/schema.sql - Runtime config
src/config/env.js
Other components
- API client
Connections 25
- API client → Worker startup: sends HTTP
README.md - Worker startup → Fastify app: builds app
src/server.js - Worker startup → SQLite connection: initializes database
src/server.js - Worker startup → Runtime config: reads settings
src/server.js - Fastify app → Health endpoint: registers route
src/app.js - Fastify app → Product routes: registers route
src/app.js - Fastify app → Order route: registers route
src/app.js - Fastify app → User history route: registers route
src/app.js - Fastify app → Domain errors: handles errors
src/app.js - Product routes → Product operations: calls
src/routes/products.js - Product routes → Domain errors: validates with
src/routes/products.js - Order route → Order operations: calls
src/routes/orders.js - Order route → Domain errors: validates with
src/routes/orders.js - User history route → Order operations: reads history via
src/routes/users.js - User history route → Domain errors: validates with
src/routes/users.js - Product operations → SQLite connection: queries through
src/services/productService.js - Product operations → Product cache: reads and updates
src/services/productService.js - Product operations → Category cache: reads and updates
src/services/productService.js - Product operations → Domain errors: raises
src/services/productService.js - Order operations → SQLite connection: queries through
src/services/orderService.js - Order operations → Product cache: updates stock
src/services/orderService.js - Order operations → Domain errors: raises
src/services/orderService.js - SQLite connection → Shop database: initializes schema
src/db/connection.js - SQLite connection → Runtime config: reads database path
src/db/connection.js - Product cache → Runtime config: reads cache TTL
src/cache/productCache.js