User Billing Management System is a full-stack billing dashboard for managing customers, invoices, payments, and billing summaries. The application includes an authenticated admin interface, a Next.js frontend, and an Express/MongoDB backend API.
- Admin login with JWT-based authentication
- Customer management with name, email, country, and profile image upload
- Bill creation, editing, listing, and deletion
- Bill payment tracking with paid, partial, and unpaid statuses
- Add payments to existing bills
- Search and filter users and bills
- User detail pages with related bills and payment summary
- Dashboard statistics for users, bills, paid totals, and remaining balances
- Cloudinary-backed user image uploads
- Next.js 15
- React 19
- Tailwind CSS
- Axios / Fetch API
- React Hook Form
- Zod
- Framer Motion
- Lucide React
- Radix UI
- Node.js
- Express.js
- MongoDB
- Mongoose
- JSON Web Tokens
- Multer
- Cloudinary
- CORS
- dotenv
userbilling-main/
|-- backend/
| |-- controllers/ # API request handlers
| |-- lib/ # Shared backend utilities
| |-- middleware/ # Auth middleware
| |-- models/ # Mongoose models
| |-- public/ # Legacy static image assets
| |-- routes/ # Express API routes
| |-- .env.example # Backend environment example
| |-- package.json
| `-- server.js # Express app entry point
|-- frontend/
| |-- public/ # Frontend static assets
| |-- src/
| | |-- app/ # Next.js app routes/pages
| | |-- components/ # Reusable UI components
| | `-- lib/ # Frontend API/auth helpers
| |-- .env.example # Frontend environment example
| `-- package.json
|-- .gitignore
`-- README.md
- Node.js 18 or newer
- npm or pnpm
- MongoDB running locally or a MongoDB connection string
- Cloudinary account if you want customer image uploads
git clone <repository-url>
cd userbilling-main
cd backend
npm install
cd ../frontend
npm installCreate backend and frontend environment files from the examples:
cd backend
cp .env.example .env
cd ../frontend
cp .env.example .env.localOn Windows PowerShell, use:
Copy-Item backend\.env.example backend\.env
Copy-Item frontend\.env.example frontend\.env.localcd backend
npm startThe backend runs on:
http://localhost:5000
Health check:
GET http://localhost:5000/api/health
Open a second terminal:
cd frontend
npm run devThe frontend runs on:
http://localhost:3000
Create backend/.env:
DB_URL=mongodb://localhost:27017/userbilling
PORT=5000
ADMIN_EMAIL=admin@example.com
ADMIN_PASSWORD=change-me
JWT_SECRET=replace-with-a-long-random-string
CORS_ORIGINS=http://localhost:3000,http://localhost:3001
CLOUDINARY_CLOUD_NAME=
CLOUDINARY_API_KEY=
CLOUDINARY_API_SECRET=Notes:
DB_URLcan also be provided asMONGODB_URI.ADMIN_EMAILandADMIN_PASSWORDare used for the single admin login.JWT_SECRETshould be a long random value in production.CORS_ORIGINSshould include the frontend URL.- Cloudinary values are required for profile image uploads.
Create frontend/.env.local:
NEXT_PUBLIC_API_BASE_URL=http://localhost:5000Base URL:
http://localhost:5000
Public routes:
GET /api/healthPOST /api/auth/login
Authenticated routes require:
Authorization: Bearer <token>
Main API routes:
GET /api/auth/meGET /api/usersGET /api/users/:idGET /api/users/:id/billsGET /api/users/:id/detailsPOST /api/usersPUT /api/users/:idDELETE /api/users/:idGET /api/billsGET /api/bills/:idPOST /api/billsPUT /api/bills/:idDELETE /api/bills/:idPOST /api/bills/:id/paymentsGET /api/stats
Backend behavior:
- The backend connects to MongoDB using
DB_URLorMONGODB_URI. - User images are uploaded with
multipart/form-dataand stored in Cloudinary. - Bill payment status is derived from the payments list.
- Legacy bill fields are still handled for backward compatibility.
Add your name here.