This backend follows the GeekInk Backend Standard.
Read this README before writing any code. If you are confused, reread the comments inside each file.
If it’s not here, you don’t need it.
This structure exists to:
- Keep code readable
- Separate responsibilities
- Prevent spaghetti code
- Remove dependency on mentors
If you follow this structure correctly, your backend will scale.
Legal license for the project.
Do not modify unless instructed.
Explains:
- What the project does
- How to run it
- How it is structured
If someone asks you “how does this backend work?”
The answer should be: “Read the README.”
All application code lives here.
Nothing outside src/ should contain logic.
Configuration and setup files ONLY.
Responsible for:
- Loading environment variables
- Validating required variables
DO
- Read from
process.env - Export a config object
DO NOT
- Write logic
- Connect to databases here
Responsible for:
- Connecting to the database
- Exporting the database connection
DO
- Handle connection logic
- Handle connection errors
DO NOT
- Define models
- Write queries
Defines data structure only.
Responsible for:
- Defining database schema
- Defining relationships
DO
- Define fields and types
- Export the model
DO NOT
- Handle requests
- Write business logic
- Send responses
Rule:
Models do NOT know about HTTP.
Handles application logic.
Responsible for:
- Receiving requests from routes
- Processing data
- Calling models
- Returning responses
DO
- Validate request data
- Call model methods
- Return structured responses
DO NOT
- Define routes
- Access environment variables directly
Rule:
Controllers think. Routes only route.
Defines URL endpoints only.
Responsible for:
- Mapping URLs to controllers
- Defining HTTP methods
DO
- Use Express Router
- Call controller functions
DO NOT
- Write logic
- Access database
- Handle validation
Example:
router.post("/users", createUser);
src/utils/
Shared helper functions.
response.js
Responsible for:
Standard API responses
Error formatting
Success formatting
DO
Create reusable helpers
DO NOT
Write business logic
### 📄 src/app.js
Main application entry.
Responsible for:
Creating Express app
Registering middleware
Registering routes
Starting server
DO
Keep it clean
Import routes
DO NOT
Write feature logic here
🔥 NON-NEGOTIABLE RULES
❌ No logic in routes
❌ No database access outside models
❌ No response formatting outside utils
❌ No direct res.json() inside models
## ✅ One responsibility per file
> Breaking these rules = rewrite required.
# 🧠 How to Know Where Code Goes
### Ask yourself:
- Is this about data structure? → models
- Is this about handling a request? → controllers
- Is this about URL mapping? → routes
- Is this about configuration? → config
- Is this reusable helper logic? → utils
>If you’re unsure → you’re probably putting it in the wrong place.