Skip to content

A beginner-friendly step-by-step guide to setting up a full-stack project with Express.js, MongoDB, Vite, React, Tailwind CSS, and DaisyUI.

Notifications You must be signed in to change notification settings

MRaysa/Full-Stack_Project_Setup_Guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

⚑ Full-Stack Project Setup Guide

Modern Full-Stack Web Application Template

A production-ready starter template with React + Vite + Tailwind CSS frontend and Express.js + MongoDB backend using MVC architecture

Node.js React TypeScript Vite Tailwind CSS Express.js MongoDB pnpm

Location: D:\All website project\Full-Stack_Project_Setup_Guide

Features β€’ Quick Start β€’ Documentation β€’ API β€’ Contributing


πŸ“‘ Overview

This is a modern full-stack web application template, built with cutting-edge technologies. It provides a clean, maintainable architecture for building scalable web applications with best practices baked in.

Perfect for developers who want to quickly start a new project without the hassle of initial setup.


✨ Features

🎨 User Interface

  • βš›οΈ React 19 - Latest React with improved performance
  • ⚑ Vite - Lightning-fast build tool and dev server
  • 🎨 Tailwind CSS 4 - Utility-first CSS framework
  • 🌼 DaisyUI - Beautiful component library
  • 🎭 Framer Motion - Smooth animations
  • 🎯 React Icons - Comprehensive icon library
  • πŸ’« SweetAlert2 - Beautiful, responsive alerts

πŸ” Authentication & Services

  • πŸ”₯ Firebase - Authentication and backend services
  • πŸ”’ JWT Ready - Token-based authentication (planned)

🧭 Navigation & Routing

  • πŸ“± React Router 7 - Client-side routing
  • πŸ”„ Smooth Transitions - Page transition animations

πŸ—„οΈ Backend Architecture

  • 🟒 Node.js - JavaScript runtime
  • ⚑ Express.js 5 - Minimal web framework
  • πŸƒ MongoDB - NoSQL database
  • πŸ—οΈ MVC Pattern - Clean, organized code structure
  • πŸ”„ Nodemon - Auto-restart development server
  • 🌐 CORS - Cross-Origin Resource Sharing enabled
  • πŸ“ Request Logging - Built-in request logger
  • ⚠️ Error Handling - Global error handler

πŸ“¦ Package Management

  • πŸ“¦ pnpm - Fast, disk space efficient package manager

πŸ› οΈ Tech Stack

Frontend Backend Database Tools
React Node.js MongoDB Vite
TypeScript Express Firebase pnpm
Tailwind dotenv Git

πŸ“‹ Prerequisites

Before you begin, ensure you have the following installed:

Software Version Download
Node.js v18+ Download
pnpm v9+ npm install -g pnpm
MongoDB v6+ Download
Git Latest Download

πŸš€ Quick Start

1️⃣ Clone Repository

git clone https://github.com/MRaysa/Full-Stack_Project_Setup_Guide.git
cd Full-Stack_Project_Setup_Guide

2️⃣ Backend Setup

# Navigate to server directory
cd server-site

# Install dependencies
pnpm install

# Create environment file
cp .env.example .env

# Configure your .env file (see Backend Configuration below)

# Start development server
pnpm run dev

Expected Output:

πŸš€ Server Started Successfully!
⚑ Server is running on http://localhost:3000
πŸƒ MongoDB Connected Successfully

3️⃣ Frontend Setup

# Open a NEW terminal
cd client-cite

# Install dependencies
pnpm install

# Start development server
pnpm run dev

Expected Output:

VITE v6.3.5  ready in XXX ms

➜  Local:   http://localhost:5173/
➜  Network: use --host to expose

4️⃣ Access Application

Service URL
Frontend http://localhost:5173
Backend API http://localhost:3000
Health Check http://localhost:3000/api/health

πŸ“ Project Structure

Full-Stack_Project_Setup_Guide/
β”‚
β”œβ”€β”€ πŸ“‚ client-cite/                 # Frontend Application
β”‚   β”œβ”€β”€ πŸ“‚ public/                  # Static assets
β”‚   β”œβ”€β”€ πŸ“‚ src/
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ components/         # Reusable React components
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ pages/              # Page components
β”‚   β”‚   β”œβ”€β”€ πŸ“„ App.jsx             # Main App component
β”‚   β”‚   └── πŸ“„ main.jsx            # Entry point
β”‚   β”œβ”€β”€ πŸ“„ .gitignore
β”‚   β”œβ”€β”€ πŸ“„ package.json
β”‚   β”œβ”€β”€ πŸ“„ vite.config.js          # Vite configuration
β”‚   └── πŸ“„ tailwind.config.js      # Tailwind configuration
β”‚
β”œβ”€β”€ πŸ“‚ server-site/                 # Backend Application (MVC)
β”‚   β”œβ”€β”€ πŸ“‚ config/
β”‚   β”‚   └── πŸ“„ database.js         # MongoDB connection
β”‚   β”œβ”€β”€ πŸ“‚ controllers/
β”‚   β”‚   └── πŸ“„ userController.js   # Business logic
β”‚   β”œβ”€β”€ πŸ“‚ models/
β”‚   β”‚   └── πŸ“„ User.js             # Database models
β”‚   β”œβ”€β”€ πŸ“‚ routes/
β”‚   β”‚   β”œβ”€β”€ πŸ“„ index.js            # Main router
β”‚   β”‚   └── πŸ“„ userRoutes.js       # User routes
β”‚   β”œβ”€β”€ πŸ“‚ middleware/
β”‚   β”‚   β”œβ”€β”€ πŸ“„ errorHandler.js     # Error handling
β”‚   β”‚   β”œβ”€β”€ πŸ“„ notFound.js         # 404 handler
β”‚   β”‚   └── πŸ“„ logger.js           # Request logger
β”‚   β”œβ”€β”€ πŸ“„ .env.example            # Environment template
β”‚   β”œβ”€β”€ πŸ“„ .gitignore
β”‚   β”œβ”€β”€ πŸ“„ server.js               # Entry point
β”‚   β”œβ”€β”€ πŸ“„ package.json
β”‚   └── πŸ“„ README.md               # Backend docs
β”‚
└── πŸ“„ README.md                    # This file

βš™οΈ Configuration

Backend Environment Variables

Create a .env file in server-site/ directory:

# Server Configuration
PORT=3000
NODE_ENV=development

# Database Configuration
MONGODB_URI=mongodb://localhost:27017
DB_NAME=your_database_name

# JWT Configuration
JWT_SECRET=your_super_secret_jwt_key_change_this
JWT_EXPIRE=7d

# CORS Configuration
CLIENT_URL=http://localhost:5173

# Email Configuration (Optional)
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USER=your_email@gmail.com
EMAIL_PASS=your_app_password

Frontend Environment Variables

Create a .env file in client-cite/ directory:

# API Configuration
VITE_API_URL=http://localhost:3000/api

# Firebase Configuration
VITE_FIREBASE_API_KEY=your_api_key
VITE_FIREBASE_AUTH_DOMAIN=your_auth_domain
VITE_FIREBASE_PROJECT_ID=your_project_id
VITE_FIREBASE_STORAGE_BUCKET=your_storage_bucket
VITE_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
VITE_FIREBASE_APP_ID=your_app_id

πŸ“œ Available Scripts

Backend Commands

pnpm install          # Install dependencies
pnpm run dev          # Start development server with auto-reload
pnpm start            # Start production server

Frontend Commands

pnpm install          # Install dependencies
pnpm run dev          # Start development server
pnpm run build        # Build for production
pnpm run preview      # Preview production build
pnpm run lint         # Run ESLint

πŸ“‘ API Documentation

Base URL

http://localhost:3000/api

πŸ₯ Health Check

GET /api/health

Response:

{
  "success": true,
  "message": "API is running",
  "timestamp": "2025-01-11T10:30:00.000Z"
}

πŸ‘₯ Users API

Method Endpoint Description
GET /api/users Get all users (paginated)
GET /api/users/:id Get user by ID
POST /api/users Create new user
PUT /api/users/:id Update user
DELETE /api/users/:id Delete user

Get All Users

GET /api/users?page=1&limit=10

Query Parameters:

  • page - Page number (default: 1)
  • limit - Items per page (default: 10)

Response:

{
  "success": true,
  "count": 10,
  "total": 100,
  "page": 1,
  "pages": 10,
  "data": [
    {
      "_id": "507f1f77bcf86cd799439011",
      "name": "John Doe",
      "email": "john@example.com",
      "phone": "+1234567890",
      "role": "user",
      "createdAt": "2025-01-11T10:00:00.000Z"
    }
  ]
}

Create User

POST /api/users
Content-Type: application/json

Request Body:

{
  "name": "John Doe",
  "email": "john@example.com",
  "password": "securePassword123",
  "phone": "+1234567890",
  "role": "user"
}

Response:

{
  "success": true,
  "message": "User created successfully",
  "data": {
    "_id": "507f1f77bcf86cd799439011",
    "name": "John Doe",
    "email": "john@example.com",
    "phone": "+1234567890",
    "role": "user"
  }
}

Response Formats

βœ… Success Response

{
  "success": true,
  "message": "Operation successful",
  "data": { }
}

❌ Error Response

{
  "success": false,
  "message": "Error message",
  "error": "Detailed error (development only)"
}

πŸ“„ Paginated Response

{
  "success": true,
  "count": 10,
  "total": 100,
  "page": 1,
  "pages": 10,
  "data": []
}

HTTP Status Codes

Code Status Description
200 Success Request succeeded
201 Created Resource created
400 Bad Request Invalid request
404 Not Found Resource not found
500 Server Error Internal error

πŸ› Troubleshooting

πŸ”΄ Port Already in Use

Error: Port 3000 is already in use

Solution:

# Windows
netstat -ano | findstr :3000
taskkill /PID <PID> /F

# Mac/Linux
lsof -i :3000
kill -9 <PID>

# Or change PORT in .env
PORT=3001
πŸ”΄ MongoDB Connection Error

Error: MongoNetworkError: failed to connect to server

Solutions:

  • βœ… Ensure MongoDB is running
  • βœ… Verify MONGODB_URI in .env
  • βœ… Check firewall settings
  • βœ… For Atlas: Check IP whitelist
πŸ”΄ Module Not Found

Error: Cannot find module 'express'

Solution:

rm -rf node_modules pnpm-lock.yaml
pnpm install
πŸ”΄ CORS Errors

Error: Access blocked by CORS policy

Solution:

  • βœ… Ensure CLIENT_URL in .env matches frontend
  • βœ… Default: CLIENT_URL=http://localhost:5173
  • βœ… Restart server after changes
πŸ”΄ pnpm Command Not Found

Solution:

npm install -g pnpm
pnpm --version

🀝 Contributing

Contributions are welcome! Here's how you can help:

Steps to Contribute

  1. Fork the repository
  2. Clone your fork
    git clone https://github.com/YOUR_USERNAME/Full-Stack_Project_Setup_Guide.git
  3. Create a feature branch
    git checkout -b feature/amazing-feature
  4. Commit your changes
    git commit -m "Add: amazing feature"
  5. Push to your fork
    git push origin feature/amazing-feature
  6. Open a Pull Request

Contribution Guidelines

  • βœ… Follow existing code structure
  • βœ… Use MVC pattern for backend
  • βœ… Write meaningful commit messages
  • βœ… Test before submitting
  • βœ… Update documentation
  • βœ… Keep PRs focused

πŸ“š Documentation & Resources

Official Documentation

Learning Resources


πŸ” Security

  • βœ… Never commit .env files
  • βœ… Use strong JWT secrets in production
  • βœ… Validate all user inputs
  • βœ… Use HTTPS in production
  • βœ… Keep dependencies updated
  • βœ… Use environment variables for secrets

πŸ“„ License

ISC License - Feel free to use this template for your projects!

πŸ‘€ Author

MRaysa

GitHub Repository


🌟 Show Your Support

If you found this project helpful:

Star Fork Issues

⭐ Star this repository β€’ πŸ› Report issues β€’ 🀝 Contribute


πŸ“ž Support

Need help?

  1. πŸ“– Check the Troubleshooting section
  2. πŸ” Search GitHub Issues
  3. πŸ’¬ Create a new issue

🎯 Quick Reference

# Clone and setup
git clone https://github.com/MRaysa/Full-Stack_Project_Setup_Guide.git
cd Full-Stack_Project_Setup_Guide

# Backend
cd server-site && pnpm install && cp .env.example .env && pnpm run dev

# Frontend (new terminal)
cd client-cite && pnpm install && pnpm run dev

Made with ❀️ by MRaysa

Happy Coding! πŸš€

About

A beginner-friendly step-by-step guide to setting up a full-stack project with Express.js, MongoDB, Vite, React, Tailwind CSS, and DaisyUI.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages