# eliran-turgeman/collecto architecture

> Architecture diagram of the GitHub repository eliran-turgeman/collecto, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/eliran-turgeman/collecto
- Repository: https://github.com/eliran-turgeman/collecto

## Overview

##### Main Components Identification

a. Frontend Layer:
- Web UI (Pages directory with Razor Pages)
- Identity Management UI (Areas/Identity)
- Swagger UI for API documentation

b. Backend Layer:
- API Controllers
- Services Layer
- Repository Layer
- Domain Layer
- Authentication/Authorization
- Email Processing
- Export Services

c. Data Layer:
- Database (Entity Framework Core with migrations)
- File System Storage (for templates)

d. External Services:
- SMTP Server Integration
- Payment Processing (LemonSqueezy)
- reCAPTCHA Integration

**┌─────────────────────────────────────────────────────┐**
- Client Layer                       │
- (Web UI, API Consumers, Swagger UI)                │
- ┤
- API Layer                          │
- (Controllers, Authentication, CORS, Middleware)     │
- ┤
- Service Layer                       │
- (Email, Forms, Templates, Exports, Validations)    │
- ┤
- Repository Layer                      │
- (Data Access, Entity Framework Core)               │
- ┤
- Data Layer                         │
- (Database, File System)                            │
- ┘

##### Component Relationships

a. Data Flow:
- Client → API (REST calls)
- API → Services (Business logic)
- Services → Repositories (Data access)
- Repositories → Database (CRUD operations)

b. External Interactions:
- Email Service → SMTP Server
- Payment Service → LemonSqueezy
- Validation Service → reCAPTCHA

##### Key Features to Highlight

Specialized components for:
- Email Template Management
- Export Functionality (CSV/JSON)
- Custom Email Validation
- API Key Authentication
- CORS Management
- User Management

##### Specific Implementation Details

Important architectural patterns:
- Repository Pattern implementation
- Service Layer abstraction
- Feature Toggle system
- Export Strategy Pattern
- Template Storage Provider abstraction

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        WebUI["Web UI"]:::frontend
        SwaggerUI["Swagger UI"]:::frontend
        APIConsumers["API Consumers"]:::frontend
    end

    subgraph APILayer
        Controllers["API Controllers"]:::api
        Auth["Authentication"]:::security
        CORS["CORS Management"]:::security
        Middleware["Middleware"]:::api
    end

    subgraph ServiceLayer
        EmailService["Email Service"]:::service
        FormService["Forms Service"]:::service
        TemplateService["Template Service"]:::service
        ExportService["Export Service"]:::service
        ValidationService["Validation Service"]:::service
        PaymentService["Payment Service"]:::service
        FeatureToggles["Feature Toggles"]:::service
    end

    subgraph RepositoryLayer
        EmailRepo["Email Repository"]:::repo
        FormRepo["Form Repository"]:::repo
        TemplateRepo["Template Repository"]:::repo
        UserRepo["User Repository"]:::repo
    end

    subgraph DataLayer
        DB[(Database)]:::database
        FileSystem[("File System")]:::database
    end

    subgraph ExternalServices
        SMTP["SMTP Server"]:::external
        LemonSqueezy["LemonSqueezy"]:::external
        ReCAPTCHA["reCAPTCHA"]:::external
    end

    %% Client Layer Connections
    WebUI --> Controllers
    SwaggerUI --> Controllers
    APIConsumers --> Controllers

    %% API Layer Connections
    Controllers --> Auth
    Controllers --> CORS
    Controllers --> Middleware
    Controllers --> ServiceLayer

    %% Service Layer Connections
    EmailService --> EmailRepo
    FormService --> FormRepo
    TemplateService --> TemplateRepo
    ExportService --> EmailRepo
    ValidationService --> ReCAPTCHA
    PaymentService --> LemonSqueezy
    EmailService --> SMTP

    %% Repository Layer Connections
    EmailRepo --> DB
    FormRepo --> DB
    TemplateRepo --> FileSystem
    UserRepo --> DB

    %% Click Events
    click WebUI "https://github.com/Eliran-Turgeman/Collecto/tree/master/EmailCollector.Api/Pages"
    click Auth "https://github.com/Eliran-Turgeman/Collecto/tree/master/EmailCollector.Api/Authentication"
    click Controllers "https://github.com/Eliran-Turgeman/Collecto/tree/master/EmailCollector.Api/Controllers"
    click CORS "https://github.com/Eliran-Turgeman/Collecto/blob/master/EmailCollector.Api/Middlewares/AllowedOriginsFilter.cs"
    click EmailService "https://github.com/Eliran-Turgeman/Collecto/tree/master/EmailCollector.Api/Services/EmailSender"
    click ValidationService "https://github.com/Eliran-Turgeman/Collecto/tree/master/EmailCollector.Api/Services/EmailValidations"
    click ExportService "https://github.com/Eliran-Turgeman/Collecto/tree/master/EmailCollector.Api/Services/Exports"
    click TemplateService "https://github.com/Eliran-Turgeman/Collecto/tree/master/EmailCollector.Api/Services/CustomEmailTemplates"
    click EmailRepo "https://github.com/Eliran-Turgeman/Collecto/tree/master/EmailCollector.Api/Repositories"
    click DB "https://github.com/Eliran-Turgeman/Collecto/tree/master/EmailCollector.Api/Migrations"
    click PaymentService "https://github.com/Eliran-Turgeman/Collecto/blob/master/EmailCollector.Payments"
    click SwaggerUI "https://github.com/Eliran-Turgeman/Collecto/tree/master/EmailCollector.Api/wwwroot/swagger-ui"
    click FeatureToggles "https://github.com/Eliran-Turgeman/Collecto/tree/master/EmailCollector.Api/Configurations"

    %% Styling
    classDef frontend fill:#2196F3,stroke:#fff,stroke-width:2px,color:#fff
    classDef api fill:#4CAF50,stroke:#fff,stroke-width:2px,color:#fff
    classDef service fill:#3F51B5,stroke:#fff,stroke-width:2px,color:#fff
    classDef repo fill:#9C27B0,stroke:#fff,stroke-width:2px,color:#fff
    classDef database fill:#607D8B,stroke:#fff,stroke-width:2px,color:#fff
    classDef external fill:#FF9800,stroke:#fff,stroke-width:2px,color:#fff
    classDef security fill:#F44336,stroke:#fff,stroke-width:2px,color:#fff

    %% Legend
    subgraph Legend
        Frontend["Frontend"]:::frontend
        API["API"]:::api
        Service["Service"]:::service
        Repository["Repository"]:::repo
        Database["Database"]:::database
        External["External Service"]:::external
        Security["Security"]:::security
    end
```
