# karelkalata/invoicedesigner architecture

> Architecture diagram of the GitHub repository karelkalata/invoicedesigner, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/karelkalata/invoicedesigner
- Repository: https://github.com/karelkalata/invoicedesigner

## Overview

##### Key Relationships and Flows

a. Authentication Flow
- JWT token handling
- User authorization paths
- Multi-company access control

b. Invoice Management Flow
- Connection between FormDesigner and PDF generation
- Multi-currency handling
- Company-bank-currency relationships

c. Data Flow
- CRUD operations flow
- Activity logging
- Form designer customization flow

##### Specific Elements

a. External Integrations
- QuestPDF integration for PDF generation
- Localization system with multiple languages
- Database (SQLite) connection

b. Cross-Cutting Concerns
- Activity logging system
- Multi-currency support
- Authorization filters

##### Important Details
- JWT authentication flow
- Multi-company data isolation
- Form designer customization flow
- PDF generation pipeline
- Activity logging system
- Multi-currency handling

##### Architectural Patterns to Highlight
- Clean Architecture pattern
- Repository pattern
- Service layer pattern
- MVC pattern in the API
- Component-based UI architecture

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        UI[UI Components]:::frontend
        Layout[Layout Components]:::frontend
        AuthPages[Authorization Pages]:::frontend
        Pages[Main Pages]:::frontend
        UI --> Layout
        UI --> AuthPages
        UI --> Pages
    end

    subgraph API
        AdminCtrl[Admin Controllers]:::api
        UserCtrl[User Controllers]:::api
        AuthCtrl[Auth Controllers]:::api
        FormCtrl[Form Designer Controller]:::api
        InvCtrl[Invoice Controller]:::api
        LogCtrl[Activity Log Controller]:::api
    end

    subgraph Application
        Services[Services Layer]:::service
        Auth[Authorization]:::security
        Mappers[Mappers]:::service
        FormService[Form Designer Service]:::service
        InvService[Invoice Service]:::service
        PrintService[Print Service]:::service
        LogService[Activity Log Service]:::service
    end

    subgraph Infrastructure
        DB[(Database Context)]:::database
        Repos[Repositories]:::database
        Migrations[Migrations]:::database
    end

    subgraph Domain
        Models[Core Models]:::model
        DTOs[DTOs]:::model
        Interfaces[Interfaces]:::model
    end

    subgraph External
        QuestPDF[QuestPDF]:::external
        Localization[Localization System]:::external
        SQLite[(SQLite)]:::external
    end

    %% Relationships
    UI --> API
    API --> Services
    Services --> Repos
    Repos --> DB
    DB --> SQLite
    Services --> Models
    Services --> DTOs
    PrintService --> QuestPDF
    Services --> Localization

    %% Click Events
    click UI "https://github.com/karelkalata/InvoiceDesigner/tree/main/InvoiceDesigner.WebApp/Components"
    click Layout "https://github.com/karelkalata/InvoiceDesigner/tree/main/InvoiceDesigner.WebApp/Components/Layout"
    click Pages "https://github.com/karelkalata/InvoiceDesigner/tree/main/InvoiceDesigner.WebApp/Components/Pages"
    click AuthPages "https://github.com/karelkalata/InvoiceDesigner/tree/main/InvoiceDesigner.WebApp/Components/Pages/Authorization"
    click AdminCtrl "https://github.com/karelkalata/InvoiceDesigner/tree/main/InvoiceDesigner.API/Controllers/Admin"
    click UserCtrl "https://github.com/karelkalata/InvoiceDesigner/tree/main/InvoiceDesigner.API/Controllers/User"
    click AuthCtrl "https://github.com/karelkalata/InvoiceDesigner/tree/main/InvoiceDesigner.API/Controllers/UnauthorizedAccess"
    click FormCtrl "https://github.com/karelkalata/InvoiceDesigner/blob/main/InvoiceDesigner.API/Controllers/FormDesignerController.cs"
    click InvCtrl "https://github.com/karelkalata/InvoiceDesigner/blob/main/InvoiceDesigner.API/Controllers/InvoicesController.cs"
    click LogCtrl "https://github.com/karelkalata/InvoiceDesigner/blob/main/InvoiceDesigner.API/Controllers/UserActivityLogController.cs"
    click Services "https://github.com/karelkalata/InvoiceDesigner/tree/main/InvoiceDesigner.Application/Services"
    click Auth "https://github.com/karelkalata/InvoiceDesigner/tree/main/InvoiceDesigner.Application/Authorization"
    click Mappers "https://github.com/karelkalata/InvoiceDesigner/tree/main/InvoiceDesigner.Application/Mapper"
    click FormService "https://github.com/karelkalata/InvoiceDesigner/tree/main/InvoiceDesigner.Application/Services/ServiceFormDesigner"
    click InvService "https://github.com/karelkalata/InvoiceDesigner/blob/main/InvoiceDesigner.Application/Services/InvoiceService.cs"
    click PrintService "https://github.com/karelkalata/InvoiceDesigner/blob/main/InvoiceDesigner.Application/Services/PrintInvoiceService.cs"
    click LogService "https://github.com/karelkalata/InvoiceDesigner/blob/main/InvoiceDesigner.Application/Services/UserActivityLogService.cs"
    click DB "https://github.com/karelkalata/InvoiceDesigner/blob/main/InvoiceDesigner.Infrastructure/Data/DataContext.cs"
    click Repos "https://github.com/karelkalata/InvoiceDesigner/tree/main/InvoiceDesigner.Infrastructure/Repositories"
    click Migrations "https://github.com/karelkalata/InvoiceDesigner/tree/main/InvoiceDesigner.Infrastructure/Migrations"
    click Models "https://github.com/karelkalata/InvoiceDesigner/tree/main/InvoiceDesigner.Models/Models"
    click DTOs "https://github.com/karelkalata/InvoiceDesigner/tree/main/InvoiceDesigner.Models/DTOs"
    click Interfaces "https://github.com/karelkalata/InvoiceDesigner/tree/main/InvoiceDesigner.Models/Interfaces"
    click Localization "https://github.com/karelkalata/InvoiceDesigner/blob/main/InvoiceDesigner.Localization"

    %% Styles
    classDef frontend fill:#2196F3,stroke:#1565C0,color:white
    classDef api fill:#4CAF50,stroke:#2E7D32,color:white
    classDef service fill:#FF9800,stroke:#EF6C00,color:white
    classDef database fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef model fill:#795548,stroke:#4E342E,color:white
    classDef external fill:#9E9E9E,stroke:#616161,color:white
    classDef security fill:#F44336,stroke:#C62828,color:white

    %% Legend
    subgraph Legend
        Frontend[Frontend]:::frontend
        API[API Layer]:::api
        Service[Services]:::service
        Database[Data Access]:::database
        Model[Domain Model]:::model
        External[External Systems]:::external
        Security[Security]:::security
    end
```
