How chaweroty/habittabackend works
Project type and purpose
• This is a Node.js-based RESTful backend service (Express.js) called “habittaBackend”
• It exposes HTTP endpoints for user and subscription management, persists data in a SQL database, and uses JWT for auth
File structure
• Top-level files:
• package.json / package-lock.json → Node dependencies and scripts
• database.sql → initial schema or seed data
• src/ directory follows a layered architecture:
• src/server.js & src/app.js → express app setup and server bootstrap
• src/config/database.js → DB connection config
• src/container/DIContainer.js → custom dependency-injection setup
• src/routes/*.js → HTTP route definitions (authRoutes, userRoutes)
• src/middleware/*.js → cross-cutting concerns (auth, validation, error handling)
• src/controllers/*.js → translate requests to service calls
• src/services/*.js → business logic, orchestrates repositories and utils
• src/repositories/*.js → data access layer (UserRepository, SubscriptionRepository)
• src/models/*.js → ORM or data models (User, Subscription)
• src/schemas/*.js → request-validation schemas (e.g. Joi)
• src/utils/*.js → helper functions (hashing, JWT handling)
• src/scripts/initDb.js → DB initialization script
Extract insights from README
• Minimal README. We rely primarily on code structure and naming to infer architecture.
Detail
• Call out error handling in the middleware chain
• Where validation and authentication occur
• Architectural elements—even small ones like utility modules—to give a complete picture