RESTful API for automatic invoice generation with sequential numbering and customizable templates. Built with .NET 10 and designed to be simple, flexible, and easy to implement.
- β¨ Customizable templates with flexible format patterns
- π’ Automatic sequential numbering with leading zeros
- πΎ JSON storage with no database dependencies
- ποΈ Clean layered architecture that's maintainable
- π Structured logging with Serilog
- π Reset system to restart number sequences
- π Interactive documentation with Scalar
- π 100% Open Source and free to use
-
Clone the repository
git clone https://github.com/JSAcodev/InvoiceGenerator-API.git cd invoice-generator-api -
Run the application
cd InvoiceGenerator dotnet run -
Access the API
https://localhost:PORT http://localhost:PORT -
Interactive documentation
https://localhost:PORT/scalar/v1
Interactive API documentation with all available endpoints
Example of creating a custom invoice template
Example response when generating a new invoice
POST /invoice/newtemplate
Content-Type: application/json
{
"name": "Invoice USA",
"pattern": "USA-{year}{month}-{number:5}",
"description": "Template for US market"
}POST /invoice/nextinvoice
Content-Type: application/json
{
"id": "11571eff-5e2c-4a62-ba9a-098384d408d6"
}Result:
USA-202512-00001
USA-202512-00002
USA-202512-00003
...
Create your own invoice formats using these tokens:
| Token | Description | Example |
|---|---|---|
{year} or {yyyy} |
Year (4 digits) | 2025 |
{month} or {mm} |
Month (2 digits) | 12 |
{day} or {dd} |
Day (2 digits) | 25 |
{number:x} |
Sequential number with x digits |
{number:5} β 00001 |
"USA-{year}{month}-{number:3}" β USA-202512-001
"INV-{dd}-{number:15}" β INV-25-000000000000001
"FAC-{yyyy}-{mm}-{dd}-{number:4}" β FAC-2025-12-25-0001
"INVC-{yyyy}-USA-{number:6}" β INVC-2025-USA-000001
| Method | Endpoint | Description |
|---|---|---|
POST |
/invoice/newtemplate |
Create a new template |
GET |
/invoice/templates |
Get all templates |
GET |
/invoice/template |
Get a template by ID |
POST |
/invoice/nextinvoice |
Generate next invoice |
GET |
/invoice/invoices |
Get all invoices |
GET |
/invoice/invoice/{name} |
Get last invoice by name |
POST |
/invoice/resettemplate |
Reset template counter |
The project follows a clean layered architecture:
βββββββββββββββββββββββ
β InvoiceGenerator β β API Layer (Controllers, Middleware)
βββββββββββββββββββββββ
β
βββββββββββββββββββββββ
β Business β β Business Logic
βββββββββββββββββββββββ
β
βββββββββββββββββββββββ
β Domain β β Entities
βββββββββββββββββββββββ
β
βββββββββββββββββββββββ
β Data β β Repositories (JSON)
βββββββββββββββββββββββ
- .NET 10 - Main framework
- ASP.NET Core - REST API
- Mapster - Object mapping
- Serilog - Structured logging
- Scalar - Interactive documentation
InvoiceGenerator/
βββ Business/ # Business logic, DTOs, Services
βββ Data/ # Repositories, Interfaces
βββ Domain/ # Domain entities
βββ InvoiceGenerator/ # API, Controllers, Middleware
βββ Storage/ # JSON files
- π Small businesses that need to generate simple invoices
- π¨βπΌ Freelancers for billing management
- πͺ POS systems requiring automatic numbering
- π¦ E-commerce to generate unique order numbers
- π§ͺ Educational projects to learn layered architecture
- π API Documentation
- π Report an Issue
If you find this project useful, consider giving it a star β on GitHub. Help other developers discover it!


