How codebangla/invoicika works
Purpose and Runtime
Invoicika is a full-stack invoice-management system: Angular 16 browser client, ASP.NET Core Web API 10 backend, and PostgreSQL persistence. It supports authentication/roles, customers, catalog items and groups, VAT, and invoice lifecycle operations including PDF/email capabilities. Docker orchestration is provided by docker-compose.yml; independent images are defined in Frontend/Dockerfile and WebAPI/Dockerfile.
Application Entry Points
The Angular bootstrap is Frontend/src/main.ts, which loads the root module at Frontend/src/app/app.module.ts; global navigation begins in Frontend/src/app/app-routing.module.ts. The API host and dependency pipeline begin at WebAPI/Program.cs. Runtime configuration and connection/service settings reside in WebAPI/appsettings.json and WebAPI/appsettings.Development.json.
Frontend Shell, Navigation, and Security
The root component supplies the application shell in Frontend/src/app/app.component.ts. Feature areas are independently routed Angular modules, allowing navigation among login/signup, dashboard, and domain management pages. Route protection is enforced by Frontend/src/app/guards/auth.guard.ts; outbound API calls cross Frontend/src/app/interceptors/auth.interceptor.ts, the main client-side authentication boundary. Authentication state is centralized under Frontend/src/app/states/auth/auth.state.ts, while API login/session operations are in Frontend/src/app/services/auth.service.ts.
Frontend Domain Workflows
CRUD-oriented feature modules represent the user-facing business flows: customers (Frontend/src/app/pages/customer/customer.module.ts), invoices (Frontend/src/app/pages/invoice/invoice.module.ts), item groups (Frontend/src/app/pages/group/group.module.ts), plus items, VAT, users, and roles. Invoice creation, edit, display, and list screens form the central workflow, notably Frontend/src/app/pages/invoice/invoice-add/invoice-add.component.ts, Frontend/src/app/pages/invoice/invoice-show/invoice-show.component.ts, and Frontend/src/app/services/customerinvoice.service.ts. NG-Zorro integration is consolidated in Frontend/src/app/modules/ng-zorro/ng-zorro.module.ts.
HTTP API and Business Layer
Controllers expose resource-specific API endpoints and delegate domain behavior to services: authentication through WebAPI/Controllers/AuthController.cs and WebAPI/Services/AuthService.cs; invoices through WebAPI/Controllers/CustomerInvoicesController.cs and WebAPI/Services/CustomerInvoiceService.cs; customers through WebAPI/Controllers/CustomersController.cs and WebAPI/Services/CustomerService.cs. This controller-to-service boundary separates HTTP concerns from business and persistence operations. DTOs define transport shapes where present, including WebAPI/Dtos/AuthDto.cs and WebAPI/Dtos/CustomerInvoiceDto.cs.
Invoice Domain and Persistence
Entity Framework Core persists the relational invoice model through WebAPI/Data/InvocikaDbContext.cs to PostgreSQL. The aggregate spans invoice headers, status, direct item lines, grouped-item lines, customers, items, groups, and VAT; core representations are WebAPI/Models/CustomerInvoice.cs, WebAPI/Models/CustomerInvoiceLine.cs, and WebAPI/Models/CustomerInvoiceGroupLine.cs. Schema evolution is code-first via WebAPI/Migrations/20251223191043_Initial.cs; startup seed behavior is represented by WebAPI/Data/SeedData.cs.
External Boundaries and Delivery
The browser communicates with the ASP.NET API using environment-specific frontend configuration in Frontend/src/environments/environment.ts. The backend owns database access and exposes uploaded static content beneath WebAPI/wwwroot/uploads. PostgreSQL is the required durable store; SMTP configuration in backend settings enables email delivery, and the documented backend endpoint exposes Swagger for API inspection. Containerized deployment links frontend, backend, and database through docker-compose.yml.
Main entry points: app-routing.module.ts Application routing · CustomerInvoiceService.cs Domain services · auth.guard.ts Auth state, guard & interceptor · docker-compose.yml Docker Compose
Components 19
Angular client
- Angular bootstrap
Frontend/src/main.ts - Root module & shell
Frontend/src/app/app.module.ts - Application routing
Frontend/src/app/app-routing.module.ts - Auth state, guard & interceptor · Maintains session state, protects routes, and attaches auth to API requests.
Frontend/src/app/guards/auth.guard.ts - Auth API client
Frontend/src/app/services/auth.service.ts - Invoice workflow · Invoice add, display, and list flows use the invoice client service.
Frontend/src/app/pages/invoice/invoice.module.ts - Customer management
Frontend/src/app/pages/customer/customer.module.ts - API environment config
Frontend/src/environments/environment.ts
ASP.NET Core API
- API host & pipeline · Configures dependency injection, middleware, and HTTP endpoints.
WebAPI/Program.cs - Resource controllers · Auth, invoice, and customer controllers expose resource endpoints.
WebAPI/Controllers/CustomerInvoicesController.cs - Domain services · Authentication, invoice, and customer behavior is separated from controllers.
WebAPI/Services/CustomerInvoiceService.cs - API DTOs
WebAPI/Dtos/CustomerInvoiceDto.cs - Uploaded static content
WebAPI/wwwroot/uploads
Persistence
- Invoice DbContext · Persists the invoice aggregate and related customer, catalog, group, and VAT data.
WebAPI/Data/InvocikaDbContext.cs - Invoice aggregate · Invoice headers include direct-item and grouped-item lines.
WebAPI/Models/CustomerInvoice.cs - Schema migrations & seed
WebAPI/Migrations/20251223191043_Initial.cs
Deployment & externals
- PostgreSQL · Durable application store.
- SMTP delivery
- Docker Compose · Connects frontend, API, and database containers.
docker-compose.yml
Connections 21
- Angular bootstrap → Root module & shell: boots
- Root module & shell → Application routing: loads routes
- Application routing → Auth state, guard & interceptor: protects routes
- Auth state, guard & interceptor → Auth API client: session operations
- Application routing → Invoice workflow: navigates
- Application routing → Customer management: navigates
- Invoice workflow → Auth state, guard & interceptor: authenticated requests
- Auth state, guard & interceptor → API environment config: API base URL
- API environment config → API host & pipeline: HTTPS API calls
- API host & pipeline → Resource controllers: maps endpoints
- Resource controllers → API DTOs: uses contracts
- Resource controllers → Domain services: delegates
- Domain services → Invoice DbContext: reads and writes
- Invoice DbContext → Invoice aggregate: maps aggregate
- Invoice DbContext → PostgreSQL: EF Core persistence
- Schema migrations & seed → PostgreSQL: initializes schema
- Domain services → Uploaded static content: serves upload-related content
- Domain services → SMTP delivery: sends invoice email
- Docker Compose → Angular bootstrap: runs frontend image
- Docker Compose → API host & pipeline: runs API image
- Docker Compose → PostgreSQL: runs database