Each step explained with What, Why, How, and When
What: Setting up the initial backend environment using Node.js and Express.
Why: To create a clean foundation for building APIs, server logic, routes, and database connections.
How:
Create a backend folder → initialize project using
npm init -y → create index.js → install
express → write a basic server and test API route.
When: Begin this setup before any API development or database integration.
Know web TermsWhat: Node.js lets you run JavaScript on the server.
Why: Required for all JS backend tools.
How: Install from nodejs.org, use
npm init to start a project.
When: Before any backend coding.
What: A lightweight web framework for Node.js.
Why: Makes routing, middleware, and APIs easy.
How: Install using npm install express.
When: When you want to handle routes like /users, /login.
What: APIs using HTTP methods (GET, POST, PUT, DELETE).
Why: Standard way to connect frontend and backend.
How: Use Express routes to handle each API.
When: When your frontend needs data from backend.
Model Methods ER DiagramWhat: A tool to manually test your APIs.
Why: Helps verify logic before connecting to frontend.
How: Use GET/POST/PUT/DELETE with headers and body.
When: After creating each route or endpoint.
What: NoSQL database + ODM library.
Why: To store user data, products, etc. in document form.
How: Use mongoose.connect() and define schemas.
When: When data needs to be saved permanently.
What: Functions that run between request and response.
Why: Useful for parsing, logging, authentication.
How: Use app.use() in Express.
When: For every request that needs processing before route.
Know MiddlewaresWhat: Middleware to handle form-data file uploads.
Why: Required for uploading images, resumes, PDFs.
How: Use multer.diskStorage() with routes.
When: When you want to save files to server.
What: External config using .env files.
Why: To hide secrets like DB passwords or JWT keys.
How: Use dotenv package + process.env.
When: Before deploying or sharing project.
What: JSON Web Tokens to verify users.
Why: Needed for secure login and protected routes.
How: Use jsonwebtoken to sign/verify tokens.
When: After user login/register system is ready.
What: CORS is browser security for cross-origin requests.
Why: Needed when frontend and backend are on different domains (e.g. Vercel + Railway).
How: Use npm install cors and app.use(cors()).
When: When connecting frontend to backend.
What: Gracefully managing unexpected errors.
Why: To avoid crashes and show helpful messages.
How: Use try/catch or custom Express error middleware.
When: After building your routes and logic.
What: Hosting your backend on the internet.
Why: So users can access APIs remotely.
How: Push code to GitHub, connect to Railway/Render, set up environment variables.
When: When your APIs are ready for production.
What: Status codes are 3-digit responses returned by a server to indicate the result of a client's request.
Why: They help developers and users understand what happened with a request (success, redirect, error, etc.).
How: Status codes are automatically returned with HTTP responses. For example,
200 means OK, 404 means Not Found.
When: Every time a client (like a browser or mobile app) makes a request to a server.
Understand how many types are databases and where to use and when to use them like SQL, NoSQL, In-Memory, Graph databases.
Understand how many types are databases and where to use and when to use them like SQL, NoSQL, In-Memory, Graph databases.