MERN (MongoDB, Express, React, Node) project structure

MERN (MongoDB, Express, React, Node) project structure

Explorer

  • .git…
  • .devcontainernew
  • devcontainer.jsonnew
  • .huskynew
  • pre-commitnew
  • commit-msgnew
  • .vscodenew
  • settings.jsonnew
  • extensions.jsonnew
  • launch.jsonnew
  • node_modules…, not committed
  • client
  • dist…new, not committed
  • .gitignore
  • .oxlintrc.json
  • index.html
  • package.json
  • README.md
  • tsconfig.app.json
  • tsconfig.json
  • tsconfig.node.json
  • vite.config.ts
  • server
  • dist…new, not committed
  • .envnew, not committed
  • .env.examplenew
  • migrate-mongo-config.jsnew
  • package.json
  • tsconfig.json
  • vitest.config.tsnew
  • sharednew
  • package.jsonnew
  • tsconfig.jsonnew
  • .editorconfig
  • .gitignore
  • .lintstagedrc.jsonnew
  • .nvmrcnew
  • .prettierrc.jsonnew
  • AGENTS.mdnew
  • CLAUDE.mdnew
  • README.md
  • docker-compose.ymlnew
  • package-lock.json
  • package.json
  • tsconfig.base.jsonnew
  1. # Create the root folder and its package.json

    mkdir mern-app && cd mern-app && npm init -y
  2. # Scaffold the React client with Vite

    npm create vite@latest client -- --template react-ts
  3. # Create the server workspace

    npm init -y -w server
  4. # Add Express and Mongoose to the server

    npm install express mongoose -w server
  5. # Add the server dev tools

    npm install -D typescript tsx @types/express @types/node -w server
  6. # Install everything from the root

    npm install
  7. # Growing: client data, forms, styling and tests

    npm install @tanstack/react-query react-router react-hook-form @hookform/resolvers zod tailwindcss @tailwindcss/vite -w client && npm install -D vitest jsdom @testing-library/react @testing-library/user-event @testing-library/jest-dom msw -w client
  8. # Growing: server validation, logging, migrations and tests

    npm install zod pino pino-http argon2 jose -w server && npm install -D vitest supertest @types/supertest mongodb-memory-server migrate-mongo -w server
  9. # Production: security, jobs, observability and e2e

    npm install helmet cors express-rate-limit bullmq @sentry/node -w server && npm install -D @testcontainers/mongodb -w server && npm install -D @playwright/test -w client