GitHunt
MD

mdahamshi/sb-react-express

A react + express monorepo

create-sb-react-express

โšก Scaffold a modern full-stack monorepo with React + Tailwind (Vite) frontend and Express + PostgreSQL backend โ€” in seconds.

๐Ÿ“ฆ Features

  • ๐Ÿงฉ Monorepo structure with npm workspaces
  • โš›๏ธ Frontend: React + Vite + Tailwind CSS
  • ๐Ÿš€ Backend: Express + PostgreSQL (via pg)
  • ๐Ÿณ Docker-ready (docker-compose.yml for Postgres)
  • ๐Ÿงช Test-ready frontend structure
  • โšก Unified npm run dev to start both servers at once
  • ๐Ÿงฐ CLI-based scaffolding via npx

๐Ÿš€ Install

npm i -g create-sb-react-express

๐Ÿš€ Usage

npx create-sb-react-express my-app
cd my-app
npm install

Then:

npm run dev

This runs both frontend (Vite on :5173) and backend (Express on :3000) using concurrently.


๐Ÿ“ Folder Structure

my-app/
โ”œโ”€โ”€ client/               # React + Tailwind (Vite)
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/   # Reusable components
โ”‚   โ”‚   โ”œโ”€โ”€ context/      # React contexts & tests
โ”‚   โ”‚   โ”œโ”€โ”€ pages/        # Page-level components
โ”‚   โ”‚   โ”œโ”€โ”€ api/          # Fetch helpers
โ”‚   โ”‚   โ””โ”€โ”€ main.jsx
โ”‚   โ””โ”€โ”€ tailwind.config.js
โ”‚
โ”œโ”€โ”€ server/               # Express + PostgreSQL
โ”‚   โ”œโ”€โ”€ controllers/      # Route handlers
โ”‚   โ”œโ”€โ”€ db/               # Postgres pool, queries, seed
โ”‚   โ”œโ”€โ”€ routes/           # API routes
โ”‚   โ”œโ”€โ”€ expressInit.js
โ”‚   โ””โ”€โ”€ docker-compose.yml
โ”‚
โ”œโ”€โ”€ package.json          # Root workspace with scripts

๐Ÿ“ฆ Root package.json

The generated project uses npm workspaces and unified dev scripts:

{
  "name": "sb-react-express",
  "private": true,
  "workspaces": [
    "client",
    "server"
  ],
  "scripts": {
    "client": "npm run dev --prefix client",
    "server": "npm run dev --prefix server",
    "start": "concurrently \"npm run client\" \"npm run server\"",
    "dev": "concurrently \"npm run client\" \"npm run server\""
  },
  "devDependencies": {
    "concurrently": "^8.2.0",
    "nodemon": "^3.0.1"
  }
}

๐Ÿ› ๏ธ Development Setup

1. Start Postgres, Express, Nginx via Docker

docker-compose up -d

2. Visit localhost:8080

Visit http://localhost:8080, you can change the port at docker-compose.override.yml

โš ๏ธ Make sure the database service is up and reachable before running this script.


3. Rename .env.example to .env

In server and client there is .env.example files

cd client && mv .env.example .env && cd ..
cd server && mv .env.example .env && cd ..

4. Atlternative: Start both client/server (make sure you set up DB)

From root:

npm run dev

You can use the provided sserver/docker-compose.yml to setup a db quickly.

Production

docker-compose.ynml is ready for building the app.

๐Ÿ“ƒ License

MIT


๐Ÿ™Œ Author

Made by Mohammad Dahamshi

๐ŸŒ Website

Made with โค๏ธ by SaraWebs

mdahamshi/sb-react-express | GitHunt