How stepsisstuck/sb works
Project type and purpose
• This is a Node.js backend REST API (Express) that follows an MVC-style separation.
• It exposes endpoints for managing Users, GameUsers, Quests, Reports, and Vulnerabilities.
• There is no frontend here—this service is meant to be consumed by external clients (web/mobile).
File structure
• index.js: entry point that starts the Express server.
• src/app.js: configures Express, middleware, and mounts mainRoutes.
• src/routes: each file (GameUsersRoutes, QuestsRoutes, etc.) defines HTTP endpoints; mainRoutes.js aggregates and “routes to others.”
• src/controllers: business-logic handlers invoked by routes.
• src/models: database access for each domain object (User, GameUsers, etc.)—likely raw SQL or a query builder.
• src/services/db.js: central database connection manager.
• src/configs: scripts to create schema, initialize tables, and define lookup data (levels).
Key architectural patterns and design principles
• Layered architecture (Route → Controller → Model → DB).
• Single responsibility per layer and per module: routes only parse the request, controllers orchestrate logic, models handle persistence.
• Config scripts initialize and seed the database before the service runs.
• mainRoutes.js serves as the “router of routers,” forwarding traffic to each feature’s router.
Elements
• Clear labels: “Express Server,” “mainRoutes,” “UserRoutes,” “UserController,” “UserModel,” “DB Connection,” “Database.”
• Orange for Models
• Purple for Config scripts
Detailed callouts
• Call out that mainRoutes.js simply aggregates and delegates to GameUsersRoutes, QuestsRoutes, reportRoutes, userRoutes, vulnerabilityRoutes.
• A note that levels.js populates reference data (lookup table) in the Database at init time.