π Observed Issues
Mixed Concerns β Database logic, routes, and JWT checks are all written together.
No Modularization β Controllers, models, services, and middleware are not separated.
Hard to Debug β Debugging and testing are complicated due to tightly coupled code.
Scaling Issues β Adding new features will make the codebase messy and harder to maintain.
Onboarding Difficulty β New developers may struggle to understand and contribute quickly.
π― Expected Behavior
Code should follow a clear and modular folder structure.
Routes should only handle API endpoints, delegating logic to controllers.
Database queries should be managed inside models or services.
Middleware (e.g., JWT authentication, validation) should be kept reusable and separate.
Project should be clean, scalable, and easy for new contributors to navigate.
β
Suggested Folder Structure
backend/
βββ src/
β βββ config/ # DB connection, environment configs
β βββ models/ # Database models/schemas
β βββ controllers/ # Request handling logic
β βββ routes/ # API route definitions
β βββ middleware/ # JWT auth, validation, etc.
β βββ services/ # Business logic (optional, scalable)
β βββ utils/ # Helper functions
β
βββ index.js # Entry point
π‘ Suggested Fixes
Refactor existing code into the above structure.
Keep routes minimal and delegate logic to controllers.
Move DB queries into models/services.
Separate JWT and validation logic into middleware/.
Update docs so contributors can quickly understand the project structure.
π Type: Enhancement / Refactor
π Priority: High
π Observed Issues
Mixed Concerns β Database logic, routes, and JWT checks are all written together.
No Modularization β Controllers, models, services, and middleware are not separated.
Hard to Debug β Debugging and testing are complicated due to tightly coupled code.
Scaling Issues β Adding new features will make the codebase messy and harder to maintain.
Onboarding Difficulty β New developers may struggle to understand and contribute quickly.
π― Expected Behavior
Code should follow a clear and modular folder structure.
Routes should only handle API endpoints, delegating logic to controllers.
Database queries should be managed inside models or services.
Middleware (e.g., JWT authentication, validation) should be kept reusable and separate.
Project should be clean, scalable, and easy for new contributors to navigate.
β Suggested Folder Structure
backend/
βββ src/
β βββ config/ # DB connection, environment configs
β βββ models/ # Database models/schemas
β βββ controllers/ # Request handling logic
β βββ routes/ # API route definitions
β βββ middleware/ # JWT auth, validation, etc.
β βββ services/ # Business logic (optional, scalable)
β βββ utils/ # Helper functions
β
βββ index.js # Entry point
π‘ Suggested Fixes
Refactor existing code into the above structure.
Keep routes minimal and delegate logic to controllers.
Move DB queries into models/services.
Separate JWT and validation logic into middleware/.
Update docs so contributors can quickly understand the project structure.
π Type: Enhancement / Refactor
π Priority: High