Skip to content

MatheusCastro99/Customer-Invoice-Maker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

65 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Ken-Tech Maintenance Management System

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

🎯 Project Overview

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 - .env based setup
  • Input Validation - Backend validation + frontend checks

πŸ“ Quick Navigation

πŸš€ Quick Start

Prerequisites

  • Node.js v14+
  • MongoDB Atlas (or local MongoDB)
  • npm/yarn

Backend Setup

cd NODEAPI
npm install
cp .env.example .env
# Edit .env with your MongoDB URL
npm run dev
# Server runs on http://localhost:3000

Frontend Setup

cd FRONTEND
npm install
cp .env.example .env.local
npm run dev
# App runs on http://localhost:5173

πŸ“š Key Documentation Files

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

πŸ”„ API Versioning

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.

πŸ“¦ Project Structure

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

πŸ” Configuration

Backend (.env)

MONGO_URL=mongodb+srv://...
PORT=3000
NODE_ENV=development
FRONTEND_URL=http://localhost:5173
API_VERSION=v1

Frontend (.env.local)

VITE_API_BASE_URL=http://localhost:3000

βœ… Features

Customer 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

πŸ“‹ Validation

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

πŸ§ͺ Testing

# 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"
  }'

πŸ“Š Response Format

Success:

{
  "success": true,
  "message": "Operation completed",
  "data": {},
  "pagination": {}
}

Error:

{
  "success": false,
  "message": "Error description",
  "statusCode": 400,
  "errors": ["Error 1", "Error 2"]
}

πŸš€ Deployment

Build Frontend:

cd FRONTEND
npm run build
# Creates dist/ folder

Deploy to Vercel:

vercel
# Set VITE_API_BASE_URL environment variable

Deploy Backend to Heroku:

heroku create
git push heroku main
# Set Config Vars in Heroku dashboard

πŸ†˜ Troubleshooting

MongoDB 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"

πŸ“ž Support

πŸ“ License

ISC

Version History

v1.0.0 (Current) - 2024

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

About

CRUD application using a MERN stack and Tailwind.css. Intended for local/closed network use as a web application. Application is intended to be a facilitator for company owners, allowing them to create and keep track of their customers and invoices

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages