A full-stack application for creating professional invoices and sending them to customers via email with PDF attachments.
- Invoice Management: Create, view, and manage invoices with a clean, modern interface
- Customer Management: Maintain a database of customers with complete contact information
- PDF Generation: Automatically generate professional PDF invoices with your company branding
- Email Integration: Send invoices directly to customers via email with PDF attachments
- Status Tracking: Track invoice status (Draft, Sent, Paid, Overdue)
- Calculations: Automatic calculation of subtotals, taxes, discounts, and totals
- Line Items: Add multiple line items with quantity and unit price
- Responsive Design: Modern, mobile-friendly UI built with React and Tailwind CSS
- Node.js with Express - RESTful API server
- SQLite with better-sqlite3 - Lightweight database
- PDFKit - PDF generation
- Nodemailer - Email sending
- dotenv - Environment configuration
- React 18 - UI framework
- Vite - Fast build tool
- Tailwind CSS - Modern styling
- React Router - Client-side routing
- Axios - HTTP client
- date-fns - Date formatting
invoice/
├── backend/
│ ├── src/
│ │ ├── config/ # Database and initialization
│ │ ├── controllers/ # Request handlers
│ │ ├── models/ # Data models
│ │ ├── routes/ # API routes
│ │ ├── services/ # PDF and email services
│ │ └── index.js # Server entry point
│ ├── package.json
│ └── .env.example
├── frontend/
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── pages/ # Page components
│ │ ├── services/ # API client
│ │ ├── App.jsx # Main app component
│ │ └── main.jsx # Entry point
│ ├── package.json
│ └── index.html
└── README.md
- Node.js (v16 or higher)
- npm or yarn
- Navigate to the backend directory:
cd backend- Install dependencies:
npm install- Create a
.envfile from the example:
cp .env.example .env- Configure your environment variables in
.env:
PORT=3001
DATABASE_PATH=./database.sqlite
# Email Configuration (Gmail example)
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_SECURE=false
EMAIL_USER=your-email@gmail.com
EMAIL_PASSWORD=your-app-password
# Company Information
COMPANY_NAME=Your Company Name
COMPANY_EMAIL=info@yourcompany.com
COMPANY_ADDRESS=123 Business Street, City, State 12345
COMPANY_PHONE=+1 (555) 123-4567
COMPANY_WEBSITE=www.yourcompany.com- Initialize the database:
npm run init-db- Start the backend server:
npm run devThe backend API will be running at http://localhost:3001
- Navigate to the frontend directory:
cd frontend- Install dependencies:
npm install- Start the development server:
npm run devThe frontend will be running at http://localhost:3000
- Enable 2-Factor Authentication on your Google account
- Generate an App Password:
- Go to Google Account Settings → Security
- Select "2-Step Verification"
- At the bottom, select "App passwords"
- Generate a new app password for "Mail"
- Use the generated password in your
.envfile asEMAIL_PASSWORD
Update the .env file with your SMTP provider's settings:
- EMAIL_HOST: SMTP server hostname
- EMAIL_PORT: SMTP port (usually 587 or 465)
- EMAIL_SECURE: true for port 465, false for other ports
- EMAIL_USER: Your email username
- EMAIL_PASSWORD: Your email password or app-specific password
GET /api/customers- Get all customersGET /api/customers/:id- Get customer by IDPOST /api/customers- Create new customerPUT /api/customers/:id- Update customerDELETE /api/customers/:id- Delete customer
GET /api/invoices- Get all invoicesGET /api/invoices/:id- Get invoice by IDPOST /api/invoices- Create new invoicePUT /api/invoices/:id- Update invoiceDELETE /api/invoices/:id- Delete invoiceGET /api/invoices/:id/pdf- Download invoice as PDFPOST /api/invoices/:id/email- Send invoice via email
- Navigate to the "Customers" tab
- Click "Add Customer"
- Fill in customer details (name and email are required)
- Click "Create Customer"
- Navigate to the "Invoices" tab
- Click "Create Invoice"
- Select a customer from the dropdown
- Set issue date and due date
- Add line items with description, quantity, and unit price
- Optionally add tax rate, discount, notes, and terms
- Click "Create Invoice"
- From the invoice list, click "Send Email" on any invoice
- The system will generate a PDF and email it to the customer
- The invoice status will be updated to show it was sent
- From the invoice list, click "Download PDF" on any invoice
- The PDF will be generated and downloaded to your computer
cd backend
npm run dev # Runs with nodemon for auto-reloadcd frontend
npm run dev # Runs with Vite HMRBackend:
cd backend
npm startFrontend:
cd frontend
npm run build
npm run preview- Professional layout with company branding
- Customer billing information
- Itemized line items with quantities and prices
- Subtotal, tax, discount, and total calculations
- Notes and terms sections
- Clean, print-ready format
- HTML email with responsive design
- Invoice summary with key details
- Professional branding with company information
- PDF attachment
- Clean, modern design with Tailwind CSS
- Responsive layout for mobile and desktop
- Status badges for invoice tracking
- Real-time calculation of totals
- Form validation and error handling
- Verify your SMTP credentials in
.env - Check if you're using an app-specific password (required for Gmail)
- Ensure your email provider allows SMTP access
- Check firewall settings
- Run
npm run init-dbto recreate the database - Check file permissions on the database file
- Ensure DATABASE_PATH in
.envis correct
- Check that the output directory has write permissions
- Verify all invoice data is properly formatted
- Check console logs for specific errors
Deploy both the backend API and frontend to Render with a single click!
Quick Deploy (Both Services):
- Push your code to GitHub/GitLab
- Sign up at Render
- Create a new "Blueprint" and select your repository
- Render will automatically detect
render.yamland deploy both services:- Backend API (Node.js web service)
- Frontend (Static site)
- Configure email credentials in the backend service
- Access your app at the provided URLs!
What Gets Deployed:
- ✅ Backend API at
https://invoice-backend.onrender.com/api - ✅ Frontend at
https://invoice-frontend.onrender.com - ✅ Automatic HTTPS/SSL
- ✅ Auto-deploy on git push
- ✅ Free tier available
Cost: 100% Free for testing! (Backend sleeps after 15 min inactivity, frontend is always on)
Detailed Instructions: See DEPLOY_TO_RENDER.md for complete deployment guide including:
- Step-by-step deployment instructions (Blueprint & Manual)
- Email configuration (Gmail, SendGrid, Mailgun)
- Database persistence options
- Environment variable setup
- Frontend-backend connection
- Troubleshooting tips
- Security best practices
The frontend can also be deployed separately to:
- Vercel (recommended for React apps)
- Netlify
- GitHub Pages
Set the VITE_API_URL environment variable to point to your deployed backend.
MIT
Contributions are welcome! Please feel free to submit a Pull Request.