A complete, production-ready CRUD application for managing customers and generating invoices for a home maintenance business.
Version: 1.0.0
Status: Production Ready
Stack: MERN (MongoDB, Express, React, Node.js) + Tailwind CSS
A full-stack application for managing customers and invoices with professional features:
- API Versioning - RESTful API with
/api/v1/routing - Production Ready - Error handling, validation, security
- Well Documented - API docs, README files, inline comments
- Environment Configuration -
.envbased setup - Input Validation - Backend validation + frontend checks
- Backend Setup - Express API setup
- API Documentation - Complete API reference
- Frontend Setup - React app setup
- Node.js v14+
- MongoDB Atlas (or local MongoDB)
- npm/yarn
cd NODEAPI
npm install
cp .env.example .env
# Edit .env with your MongoDB URL
npm run dev
# Server runs on http://localhost:3000cd FRONTEND
npm install
cp .env.example .env.local
npm run dev
# App runs on http://localhost:5173| File | Purpose |
|---|---|
| NODEAPI/README.md | Backend setup, routes, validation |
| NODEAPI/API_DOCUMENTATION.md | Complete API reference with examples |
| FRONTEND/README.md | Frontend setup, components, configuration |
All endpoints use versioning: /api/v1/{resource}
Customer Endpoints:
GET /api/v1/customers # List
GET /api/v1/customers/:id # Get one
POST /api/v1/customers # Create
PUT /api/v1/customers/:id # Update
DELETE /api/v1/customers/:id # Delete
Invoice Endpoints:
GET /api/v1/invoices # List
POST /api/v1/invoices # Create
DELETE /api/v1/invoices/:id # Delete
Tax Endpoints:
POST /api/v1/tax/rate # Get rate
POST /api/v1/tax/calculate # Calculate
See API_DOCUMENTATION.md for complete reference.
CRUD1/
βββ NODEAPI/
β βββ controllers/ # Business logic
β βββ models/ # MongoDB schemas
β βββ routes/ # Route handlers
β βββ middlewares/ # Express middlewares
β βββ utils/ # Errors, validation, constants
β βββ server.js # Express app
β βββ package.json
β βββ .env.example
β βββ README.md
β βββ API_DOCUMENTATION.md
βββ FRONTEND/
β βββ src/
β β βββ components/ # React components
β β βββ pages/ # Page components
β β βββ config/ # API configuration
β β βββ App.jsx
β βββ package.json
β βββ .env.example
β βββ vite.config.js
β βββ tailwind.config.js
β βββ README.md
βββ README.md
MONGO_URL=mongodb+srv://...
PORT=3000
NODE_ENV=development
FRONTEND_URL=http://localhost:5173
API_VERSION=v1VITE_API_BASE_URL=http://localhost:3000Customer Management
- View customers with pagination
- Create with validation
- Edit profiles
- Delete confirmation
- Duplicate phone prevention
Invoice Management
- Generate invoices
- Tax calculations by state
- PDF exports
- Invoice history
User Interface
- Responsive design
- Toast notifications
- Sweet alerts
- Smooth animations
- Tailwind styling
Customer:
- Phone: Valid US format
- Email: Valid email (optional)
- Zip: 5 or 9 digits (optional)
- State: 2-letter code (optional)
Invoice:
- Phone: Valid US format
- Date: ISO format required
- Price: Positive number
# Get all customers
curl http://localhost:3000/api/v1/customers
# Create customer
curl -X POST http://localhost:3000/api/v1/customers \
-H "Content-Type: application/json" \
-d '{
"companyName": "Tech Corp",
"phoneNumber": "(555) 123-4567"
}'Success:
{
"success": true,
"message": "Operation completed",
"data": {},
"pagination": {}
}Error:
{
"success": false,
"message": "Error description",
"statusCode": 400,
"errors": ["Error 1", "Error 2"]
}Build Frontend:
cd FRONTEND
npm run build
# Creates dist/ folderDeploy to Vercel:
vercel
# Set VITE_API_BASE_URL environment variableDeploy Backend to Heroku:
heroku create
git push heroku main
# Set Config Vars in Heroku dashboardMongoDB connection error:
- Verify MONGO_URL in .env
- Check IP whitelist on MongoDB Atlas
CORS error:
- Verify FRONTEND_URL matches your frontend domain
- Both must be running
Validation error:
- Phone: Use "(555) 123-4567" format
- State: Use 2-letter code like "CA"
- Backend issues β NODEAPI/README.md
- Frontend issues β FRONTEND/README.md
- API questions β API_DOCUMENTATION.md
ISC
Released Features:
- API versioning (
/api/v1/) - Error handling improvements
- Input validation middleware
- Environment configuration
- Customer CRUD with validation
- Invoice management
- Tax calculations
- PDF exports
- Responsive UI
- Comprehensive documentation
Key Improvements:
- Centralized error handling
- Custom error classes
- Validation utilities
- Fixed CORS configuration
- API endpoint configuration
- Pagination support
- Duplicate prevention
- Production-ready setup