This post documents the initial setup of a Node.js with TypeScript backend for a MERN application. Covering project separation, dependency selection, TypeScript configuration, and version control before any endpoints or code is written.
Click here for Act 4 · Scene 2
Table of Contents
- Overview
- Creating the Backend Folder
- Backend Initialization and Package Setup
- Installing Backend Dependencies
- TypeScript Configuration
- Git Initialization
- Mental Model
- Why this scene matters
Act 5 Scene 1: Here comes the backend
In this scene, I don’t build APIs or wire authentication logic yet. I focus on something quiet but foundational. That is, preparing the backend to exist properly. That means separating it from the frontend, initializing the project, installing the right dependencies, configuring TypeScript, and putting version control in place so future backend work has a stable, secure starting point.
Overview
With the frontend now stable and the data payloads for authentication clearly defined, the next step was inevitable I had to introduce the backend.
So instead of forcing more UI features, I did the responsible thing and switched gears.
This scene is about setting up the server side foundation that will eventually power authentication and data persistence. No endpoints yet. No coding here.
This scene focuses on establishing the bare foundation.
Creating the Backend Folder
First move; let's call it separation.
At the root of the project, I created a backend folder right next to the frontend.
cv-analyzer/
>backend/
>frontend/
That single decision already changes how the project feels.
This is no longer a React app.
It’s a freaking system.
In fact, this separation enforces a clear boundary between client and server concerns from day one.
Backend Initialization and Package Setup
Inside the backend folder, I initialized a Node.js project:
npm init -y
This generated a base package.json, which serves as the entry point for all backend configuration.
Installing Backend Dependencies
Next came the essential packages:
npm install cors express jsonwebtoken bcryptjs dotenv mongoose cookie-parser typescript
This setup tells a clear story:
Express to run the server
JWT for authentication
bcrypt for password security
Mongoose for database communication
dotenv for secrets
CORS and cookies for browser interaction
Then I added developer tooling:
npm install nodemon
npm install -D ts-node ts-node-dev
These packages allow automatic server restarts and direct execution of TypeScript files during development.
TypeScript Configuration
I initialized a TypeScript configuration file:
npx tsc --init
To ensure proper Node.js type support, I added:
npm install @types/node
Without this, TypeScript would not recognize core Node features, like process.env, __dirname, or built-in APIs.
I also installed type definitions for the libraries used:
npm install --save-dev @types/express @types/cors @types/cookie-parser @types/jsonwebtoken
These don’t run the app.
They make the app safer to change.
They exist solely to improve correctness, tooling, and developer experience.
Git Initialization
Although Git had already been initialized earlier, this scene documents the setup properly.
From the project root, I added a .gitignore file and verified the repository status:
git init
git status
At this point, version control cleanly tracks both frontend and backend as a single system.
Mental Model
Right now:
Frontend and backend are clearly separated
The backend is TypeScript first.
Authentication infrastructure is in place before logic
The project is prepared for growth
Why This Scene Matters
This scene shows that I:
Introduce backend systems only when the frontend contract is ready
Set foundations before writing endpoints
Prioritize security, structure, and developer experience
Build like someone expecting the app to grow
Thanks for reading.
Let’s move on to the Next Scene.
We in the Building…
Building in Progress…
Top comments (0)