Skip to content

qyqyardy/invoice-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧾 Invoice Management System

A full-stack Invoice Management System built with Golang Backend, Vue 3 Frontend, and PostgreSQL Database. Fully containerized with Docker for easy deployment.

✨ Features

  • πŸ” Authentication & Authorization - JWT-based authentication with bcrypt password hashing
  • πŸ“„ Invoice Management - Full CRUD operations with automatic invoice numbering
  • πŸ”’ Auto Invoice Numbering - Format: INV-YYYY-MM-DD-XXXX
  • πŸ“‘ PDF Generation - Automatic invoice PDF generation
  • πŸ“§ Email Notifications - Send invoices via email with PDF attachments
  • 🏦 Multiple Bank Accounts - Manage multiple bank accounts per user
  • πŸ“Š Dashboard Analytics - Track total invoices, paid/unpaid status, and revenue statistics
  • πŸ”’ Security - Rate limiting, CORS, XSS protection, and SQL injection prevention
  • 🎨 Responsive UI - Modern design with Tailwind CSS

πŸš€ Quick Start

Prerequisites

  • Docker & Docker Compose
  • Gmail Account (for SMTP)

Setup Gmail App Password

  1. Login to your Gmail account
  2. Go to: https://myaccount.google.com/apppasswords
  3. Generate an App Password for "Mail"
  4. Copy the 16-digit password generated

Installation

# Clone repository
git clone https://github.com/qyqyardy/invoice-app.git
cd invoice-app

# Create .env file
cat > .env << 'EOF'
SMTP_FROM=your-email@gmail.com
SMTP_PASSWORD=your-16-digit-app-password
EOF

# Build and run
docker compose up -d --build

# Access application
# Frontend: http://localhost:8081
# Backend API: http://localhost:8080/api

πŸ“ Project Structure

invoice-app/
β”œβ”€β”€ backend/              # Golang backend
β”œβ”€β”€ frontend/             # Vue 3 frontend
β”œβ”€β”€ nginx/                # Nginx reverse proxy config
β”œβ”€β”€ docker-compose.yml    # Docker orchestration
└── .env                  # Environment variables

🎯 Usage

First Time Setup

  1. Open http://localhost:8081
  2. Click "Register" to create a new account
  3. Login with your newly created credentials
  4. Navigate to "Bank Accounts" to add payment information
  5. Start creating invoices!

Creating an Invoice

  1. Dashboard β†’ "Create New Invoice"
  2. Fill in client information
  3. Select a bank account for payment
  4. Add invoice items (description, quantity, unit price)
  5. Review totals
  6. Submit

Managing Bank Accounts

  1. Navigate to "/bank-accounts"
  2. Add multiple bank accounts
  3. Set a default bank (auto-selected when creating invoices)
  4. Edit or delete existing bank accounts

Invoice Actions

  • View - See complete invoice details
  • Download PDF - Generate and download invoice PDF
  • Send Email - Send invoice to client via email
  • Update Status - Mark as paid/unpaid
  • Delete - Remove invoice

πŸ” Security Features

Backend Security

  • βœ… Password hashing (bcrypt cost 14)
  • βœ… JWT Authentication
  • βœ… Rate Limiting (100 requests per minute)
  • βœ… SQL Injection Prevention (prepared statements)
  • βœ… CORS Configuration
  • βœ… Input Validation

Frontend Security

  • βœ… XSS Prevention (Vue's built-in escaping)
  • βœ… CSRF Protection (JWT in headers)
  • βœ… Route Guards (authentication required)

Nginx Security

  • βœ… Security Headers (X-Frame-Options, X-XSS-Protection)
  • βœ… Rate Limiting
  • βœ… SSL/TLS Ready

πŸ”„ API Endpoints

Authentication

POST   /api/register              Register new user
POST   /api/login                 Login user

User Management

GET    /api/me                    Get current user
PUT    /api/me                    Update current user

Bank Accounts

GET    /api/bank-accounts         List all bank accounts
POST   /api/bank-accounts         Create bank account
PUT    /api/bank-accounts/:id     Update bank account
DELETE /api/bank-accounts/:id     Delete bank account
POST   /api/bank-accounts/:id/set-default  Set default bank

Invoices

GET    /api/dashboard             Get dashboard statistics
GET    /api/invoices              List all invoices
GET    /api/invoices/:id          Get invoice details
POST   /api/invoices              Create new invoice
PUT    /api/invoices/:id          Update invoice status
DELETE /api/invoices/:id          Delete invoice
GET    /api/invoices/:id/pdf      Download invoice PDF
POST   /api/invoices/:id/send-email  Send invoice via email

πŸ—„οΈ Database Schema

Users Table

id              SERIAL PRIMARY KEY
email           VARCHAR(255) UNIQUE NOT NULL
password_hash   VARCHAR(255) NOT NULL
name            VARCHAR(255) NOT NULL
bank_account    VARCHAR(255)
created_at      TIMESTAMP

Bank Accounts Table

id              SERIAL PRIMARY KEY
user_id         INTEGER REFERENCES users(id)
bank_name       VARCHAR(100) NOT NULL
account_number  VARCHAR(50) NOT NULL
account_holder  VARCHAR(255) NOT NULL
is_default      BOOLEAN
created_at      TIMESTAMP

Invoices Table

id              SERIAL PRIMARY KEY
invoice_number  VARCHAR(50) UNIQUE NOT NULL
user_id         INTEGER REFERENCES users(id)
bank_account_id INTEGER REFERENCES bank_accounts(id)
client_name     VARCHAR(255) NOT NULL
client_email    VARCHAR(255) NOT NULL
client_address  TEXT
issue_date      DATE NOT NULL
due_date        DATE NOT NULL
subtotal        DECIMAL(15,2) NOT NULL
tax             DECIMAL(15,2)
total           DECIMAL(15,2) NOT NULL
status          VARCHAR(20) DEFAULT 'unpaid'
notes           TEXT
created_at      TIMESTAMP
updated_at      TIMESTAMP

Invoice Items Table

id              SERIAL PRIMARY KEY
invoice_id      INTEGER REFERENCES invoices(id)
description     TEXT NOT NULL
quantity        INTEGER NOT NULL
unit_price      DECIMAL(15,2) NOT NULL
amount          DECIMAL(15,2) NOT NULL

πŸ› Troubleshooting

Container Issues

# Check container status
docker compose ps

# View logs
docker compose logs backend
docker compose logs frontend
docker compose logs postgres

# Restart specific service
docker compose restart backend

# Rebuild specific service
docker compose up -d --build backend

Database Connection Issues

# Check if postgres is healthy
docker compose ps postgres

# Connect to postgres
docker exec -it invoice_postgres psql -U invoiceapp -d invoicedb

# Reset database
docker compose down -v
docker compose up -d

Email Sending Issues

  • Ensure SMTP_FROM and SMTP_PASSWORD are correct in .env
  • Use App Password, not your regular Gmail password
  • Check backend logs: docker compose logs backend

πŸ“š Documentation

πŸ› οΈ Tech Stack

Backend:

  • Golang 1.21
  • Gin Framework
  • PostgreSQL 15
  • JWT Authentication
  • GOFPDF (PDF generation)
  • SMTP (Email sending)

Frontend:

  • Vue 3 (Composition API)
  • Vue Router
  • Pinia (State Management)
  • Tailwind CSS
  • Axios
  • Vite

Infrastructure:

  • Docker & Docker Compose
  • Nginx (Reverse Proxy)
  • PostgreSQL (Database)

πŸ“Š Performance

  • Backend: Gin framework with response time < 50ms
  • Frontend: Vue 3 Composition API with lazy loading
  • Database: PostgreSQL with proper indexing
  • Caching: Nginx static file caching

πŸ“ License

MIT License - Free to use for personal and commercial projects.

πŸ‘¨β€πŸ’» Author

Created by Rizki

🀝 Contributing

Contributions, issues, and feature requests are welcome!

Feel free to check the issues page.

⭐ Show your support

Give a ⭐️ if this project helped you!

πŸ“§ Contact

For questions or support, please open an issue in the repository.


Made with ❀️

About

Invoice APP mini

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors