Chapter 44: Applications

1. What does “Node.js Application” really mean in practice?

When people say “Node.js application”, they almost always mean one of these categories:

Type Typical use case Main frameworks/libraries in 2025–2026 Approx. % of Node.js projects
REST / GraphQL API Backend for web/mobile apps Express, Fastify, NestJS, Hono, Elysia ~70–80%
Real-time / WebSocket app Chat, live notifications, collaboration Socket.IO, ws, uWebSockets, Fastify + ws ~10–15%
CLI tool / dev utility create-app, migration tools, generators Commander.js, yargs, cac, ink (TUI) ~5–10%
Background worker / queue Image processing, email sending, cron jobs BullMQ, Bee-Queue, Agenda, node-cron ~5–10%
Serverless function Vercel, Netlify, AWS Lambda, Cloudflare hono, itty-router, workerd growing very fast
Monorepo tooling turbo, nx, lage, moon in larger teams

Most beginners start with #1 (REST API) — and that is what most tutorials teach.

Most real money is made with #1 + #3 + #4 (API + CLI + workers).

We will build a modern REST API step-by-step — this is the foundation that almost everything else builds on.

2. Project structure – what actually works in 2025–2026

There are several popular styles. Here are the ones you see most often:

Style A – Layered / Clean Architecture (most common in medium/large teams)

text

Style B – Feature folders (popular with vertical slice architecture)

text

Which one to choose?

  • Layered → easier for teams > 5 people, easier to enforce architecture
  • Feature folders → easier to delete whole features, better for micro-frontends mindset

Recommendation for learning / medium projects (2025–2026): start with layered — it is easier to understand and most tutorials/books use it.

We will use layered style in this tutorial.

3. Realistic modern package.json (2025–2026)

JSON

4. Creating the first working API (step by step)

src/index.ts – entry point

TypeScript

src/config/env.ts – safe environment variables

TypeScript

src/middleware/error.middleware.ts

TypeScript

src/routes/task.routes.ts – simple example

TypeScript

src/controllers/task.controller.ts

TypeScript

src/types/task.types.ts

TypeScript

src/services/task.service.ts – fake in-memory for now

TypeScript

Summary – What you now have

You have a modern, type-safe, production-ready foundation:

  • ESM + top-level await
  • Strict TypeScript
  • Zod runtime validation
  • Custom error handling
  • Layered architecture
  • Automatic linting & formatting
  • Environment validation

This structure is used (with small variations) by many real teams building serious Node.js backends today.

Which part would you like to extend / improve next?

  • Add JWT authentication + protected routes
  • Connect real database (Prisma / Drizzle)
  • Add rate limiting, logging (pino), request tracing
  • Implement unit & integration tests with Vitest
  • Add Dockerfile + docker-compose
  • Deploy checklist (Render, Railway, Fly.io, Vercel)

Just tell me what you want to build or understand next — I’ll continue with complete, realistic code. 😊

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *