AI-powered invoice management built for modern freelancers & businesses.
Create, send, and track professional invoices — with AI that learns your workflow.
🚀 Get Started · ✨ Features · 📖 API Docs · 🚢 Deploy
- Overview
- Features
- Tech Stack
- Project Structure
- Quick Start
- Environment Variables
- API Reference
- Deployment
- Security
- Scripts
- Troubleshooting
- Contributing
- License
SmartInvoice is a production-ready SaaS application for creating, managing, and sending professional invoices. It blends a sleek Spotify-inspired dark UI with AI-powered features — from smart auto-fill to payment prediction — making it faster and smarter than traditional invoicing tools.
Built for: Freelancers, agencies, consultants, and small businesses that need a professional invoicing solution without the enterprise overhead.
| Feature | Description |
|---|---|
| Invoice Management | Create, edit, send, duplicate, and archive invoices |
| Smart Numbering | Auto-incremented invoice numbers with custom prefixes |
| PDF Generation | Branded, pixel-perfect PDF export via Puppeteer & jsPDF |
| Multi-Currency | Support for global currencies with per-client preferences |
| Tax & Discounts | GST/VAT calculations with line-item and invoice-level discounts |
| Payment Tracking | Mark invoices as paid, track payment method & date |
| Feature | Description |
|---|---|
| AI Chatbot Assistant | Floating conversational interface — create invoices via chat |
| Smart Suggestions | Auto-complete line items based on client history (Gemini AI) |
| Description Enhancer | Rewrite item descriptions in Formal or Friendly tone |
| Payment Predictor | Cash-flow forecast with confidence intervals |
| Expense Categorizer | AI categorizes uploaded receipts automatically |
- Revenue insights with interactive charts (Recharts)
- Invoice status breakdown — Draft, Sent, Paid, Overdue
- Cash-flow forecast dashboard widget
- CSV export for accounting tools
- Full client database with company, address, GST number, currency
- Per-client invoice history and tracking
- Smart client search with fuzzy matching
- Automated email delivery via Nodemailer (Gmail SMTP) or Resend
- Configurable payment reminder sequences
- Reminder history tracking per invoice
- JWT-based authentication with
bcryptjspassword hashing - ALTCHA CAPTCHA integration on auth flows
- Secure HTTP-only cookie sessions
- Input validation with Zod schemas
| Layer | Technology |
|---|---|
| Framework | Next.js 14 (App Router) |
| Language | TypeScript 5.2 |
| UI Components | Radix UI + shadcn/ui |
| Styling | Tailwind CSS + custom dark theme |
| Animations | Framer Motion |
| Charts | Recharts |
| Forms | React Hook Form + Zod |
| Icons | Lucide React |
| Layer | Technology |
|---|---|
| Runtime | Node.js ≥ 18 |
| Database | PostgreSQL via Neon serverless |
| Database Client | @neondatabase/serverless |
| Auth | JWT (jsonwebtoken) + bcryptjs |
| Nodemailer (SMTP) + Resend API | |
| Puppeteer + jsPDF + html2canvas | |
| AI | Google Gemini (@google/generative-ai) |
| Payments | Razorpay SDK |
| Layer | Technology |
|---|---|
| Hosting | Vercel (recommended) |
| Database | Neon (serverless Postgres) |
| Package Manager | Bun |
SmartInvoice/
├── app/
│ ├── api/ # API route handlers
│ │ ├── auth/ # Login, signup, logout
│ │ ├── invoices/ # CRUD + PDF + email
│ │ ├── clients/ # Client management
│ │ ├── reminders/ # Reminder scheduling & sending
│ │ ├── analytics/ # Revenue & stats
│ │ ├── ai/ # AI chatbot & suggestions
│ │ ├── expenses/ # Expense tracking & AI categorization
│ │ ├── export/ # CSV export
│ │ ├── proposals/ # Proposal management
│ │ ├── tax/ # Tax calculation
│ │ └── upload/ # File upload
│ ├── auth/ # Auth pages (login, signup)
│ ├── dashboard/ # Protected dashboard routes
│ │ ├── agent/ # AI agent interface
│ │ ├── analytics/ # Revenue analytics
│ │ ├── clients/ # Client list & detail
│ │ ├── create/ # Invoice creation wizard
│ │ ├── expenses/ # Expense management
│ │ ├── invoices/ # Invoice list & detail
│ │ ├── proposals/ # Proposals
│ │ ├── reminders/ # Reminder settings
│ │ ├── reports/ # Financial reports
│ │ ├── settings/ # User & business settings
│ │ ├── tax/ # Tax dashboard
│ │ └── components/ # Shared dashboard components
│ ├── globals.css # Global styles & design tokens
│ ├── layout.tsx # Root layout
│ └── page.tsx # Landing page
├── components/
│ ├── ai/ # AI chatbot & suggestion UI
│ ├── invoice/ # Invoice form & preview
│ ├── invoices/ # Invoice list components
│ ├── security/ # CAPTCHA & security
│ └── ui/ # Base UI primitives (shadcn)
├── lib/
│ ├── database.ts # DB queries & type interfaces
│ ├── auth.ts # JWT helpers
│ ├── ai-agent.ts # AI agent orchestration
│ ├── gemini.ts # Gemini AI client
│ ├── smart-suggestions.ts # AI suggestion engine
│ ├── email-service.ts # Email sending logic
│ ├── pdf-generator.ts # PDF generation
│ ├── invoice-generator.ts # Invoice number logic
│ ├── payment-service.ts # Razorpay integration
│ ├── reminder-service.ts # Reminder scheduling
│ └── error-handler.ts # Centralized error handling
├── types/ # Shared TypeScript types
├── hooks/ # Custom React hooks
├── contexts/ # React context providers
├── public/ # Static assets
└── supabase/ # Database migration files
- Node.js ≥ 18.0.0
- Bun (recommended) or npm ≥ 8.0.0
- PostgreSQL database — local or Neon for cloud
git clone https://github.com/your-username/SmartInvoice.git
cd SmartInvoicebun install
# or
npm installcp .env.local.example .env.local
# Fill in your values — see Environment Variables section belowRun the SQL migration files against your PostgreSQL instance:
psql -d your_database_url -f supabase/migrations/001_initial.sqlOr paste the SQL directly in the Supabase / Neon dashboard query editor.
bun dev
# or
npm run devOpen http://localhost:3000 — the app is live! 🎉
Create a .env.local file at the project root:
# ─── Application ──────────────────────────────────────────────
NODE_ENV=development
NEXT_PUBLIC_APP_URL=http://localhost:3000
# ─── Database (Required) ──────────────────────────────────────
DATABASE_URL=postgresql://username:password@host:5432/smartinvoice
# ─── Authentication (Required) ────────────────────────────────
# Generate: openssl rand -base64 32
JWT_SECRET=your-super-secret-jwt-key-min-32-chars
# ─── Email via SMTP (Optional) ────────────────────────────────
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_SECURE=false
EMAIL_USER=your-email@gmail.com
EMAIL_PASS=your-app-specific-password
EMAIL_FROM=noreply@yourdomain.com
# ─── Email via Resend (Alternative) ──────────────────────────
RESEND_API_KEY=re_your_api_key
# ─── Google Gemini AI (Required for AI features) ──────────────
GEMINI_API_KEY=your-gemini-api-key
# ─── Razorpay (Optional — payment links) ─────────────────────
RAZORPAY_KEY_ID=rzp_live_your_key
RAZORPAY_KEY_SECRET=your_razorpay_secretGmail Tip: Create an App Password — do not use your main account password.
All routes are under /api/. Protected routes require a valid JWT passed as a Bearer token in the Authorization header, or as a session cookie.
{
"name": "Jane Doe",
"email": "jane@example.com",
"password": "securepassword123",
"company": "Doe Studios"
}{
"email": "jane@example.com",
"password": "securepassword123"
}Clears the session cookie. No body required.
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/invoices |
List all invoices |
POST |
/api/invoices |
Create a new invoice |
GET |
/api/invoices/[id] |
Get invoice by ID |
PUT |
/api/invoices/[id] |
Update an invoice |
DELETE |
/api/invoices/[id] |
Delete an invoice |
POST |
/api/invoices/[id]/send |
Send invoice via email |
GET |
/api/invoices/[id]/pdf |
Download as PDF |
Create Invoice — Example Payload:
{
"clientName": "Acme Corp",
"clientEmail": "billing@acme.com",
"clientAddress": "123 Main St, New York, NY 10001",
"items": [
{ "description": "Web Design", "quantity": 1, "rate": 2500 },
{ "description": "SEO Setup", "quantity": 3, "rate": 150 }
],
"taxRate": 18,
"discountRate": 5,
"dueDate": "2026-09-01",
"notes": "Thank you for your business!",
"currency": "USD"
}| Method | Endpoint | Description |
|---|---|---|
GET |
/api/clients |
List all clients |
POST |
/api/clients |
Create a client |
PUT |
/api/clients/[id] |
Update client |
DELETE |
/api/clients/[id] |
Delete client |
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/analytics |
Revenue summary & KPIs |
GET |
/api/analytics/cashflow |
Cash-flow forecast data |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/ai/chat |
Send message to AI assistant |
GET |
/api/suggestions |
Smart line-item suggestions |
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/reminders |
List reminder config |
POST |
/api/reminders/send |
Manually trigger reminders |
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/export/invoices |
Export invoices as CSV |
GET |
/api/export/expenses |
Export expenses as CSV |
- Push your repository to GitHub.
- Go to vercel.com → New Project → import your repo.
- Add all environment variables in the Vercel dashboard under Settings → Environment Variables.
- Click Deploy.
# Or via CLI
npm i -g vercel
vercel --prodnpm i -g @railway/cli
railway login
railway init
railway upFROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]docker build -t smartinvoice .
docker run -p 3000:3000 --env-file .env.local smartinvoicenpm run build
pm2 start npm --name "smartinvoice" -- start
# Set up nginx as reverse proxy on port 3000SmartInvoice follows security best practices out of the box:
| Area | Implementation |
|---|---|
| Authentication | JWT tokens, configurable expiry, HTTP-only cookies |
| Passwords | bcryptjs hashing with ≥ 10 salt rounds |
| Bot Protection | ALTCHA CAPTCHA on registration |
| Input Validation | Zod schemas on all API endpoints |
| Secrets | No sensitive values in client bundle |
| Transport | HTTPS enforced in production |
- Rotate
JWT_SECRET—openssl rand -base64 32 - Set
NODE_ENV=production - Enable SSL on the database connection
- Use a strong, unique database password
- Configure CORS for your production domain
- Enable rate limiting on auth endpoints
- Set up automated database backups
| Command | Description |
|---|---|
bun dev |
Start the development server |
bun run build |
Build for production |
bun start |
Start the production server |
bun run lint |
Run ESLint |
bun run type-check |
TypeScript type check (tsc --noEmit) |
bun run clean |
Clear .next build cache |
bun run dev:clean |
Clean + start dev server |
npm run security-audit |
Run npm audit for vulnerabilities |
- Verify
DATABASE_URLformat:postgresql://user:pass@host:5432/dbname - If using Neon, use the pooled connection string
- Check that your IP is allowlisted in the database firewall settings
- For Gmail: use an App Password, not your account password
- Ensure
EMAIL_PORT=587andEMAIL_SECURE=falsefor STARTTLS - Test the mail config:
GET /api/test-email
- Verify
GEMINI_API_KEYis valid in Google AI Studio - Check API quota limits on your Google Cloud project
- AI features gracefully degrade — the app is fully functional without an AI key
- On Vercel/serverless:
jsPDFmode is used automatically (no Puppeteer) - On a VPS: install Chromium dependencies
apt-get install -y chromium libgbm-dev
# Clear all caches and reinstall
bun run clean
rm -rf node_modules
bun install
bun run buildContributions are welcome and appreciated! Please follow these steps:
- Fork this repository
- Create a feature branch:
git checkout -b feat/your-feature - Commit your changes using conventional commits:
feat: New feature fix: Bug fix docs: Documentation only refactor: Code refactoring chore: Build/tooling updates - Push your branch:
git push origin feat/your-feature - Open a Pull Request with a clear description of what changed and why
This project is licensed under the MIT License — see the LICENSE file for details.
Built with ❤️ using Next.js, TypeScript, and a lot of ☕
