# ahm3dramad3n/emailybackend architecture

> Architecture diagram of the GitHub repository ahm3dramad3n/emailybackend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ahm3dramad3n/emailybackend
- Repository: https://github.com/ahm3dramad3n/emailybackend

## Overview

Emaily is an email-delivery API with account, project, service, template, submission, billing, and administration features. The principal workflow is a client submitting an email request; the submission service handles validation and attachments, sends email, and records operational results. The graph also preserves documented-by-tree capability branches, but several controllers and services were not sampled, so their connections are omitted or marked unverified rather than inferred. The sampled business services use a unit-of-work persistence layer; attachment storage uses Azure Blob Storage.

Main entry points: [`Emaily.API/Controllers`](https://github.com/ahm3dramad3n/emailybackend/tree/main/Emaily.API/Controllers) (API controllers), [`Emaily.DAL/Interfaces/IUnitOfWork.cs`](https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.DAL/Interfaces/IUnitOfWork.cs) (Unit of work), [`Emaily.BLL/Services/AuthService.cs`](https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Services/AuthService.cs) (Authentication), [`Emaily.BLL/Services/SubmissionService.cs`](https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Services/SubmissionService.cs) (Email submissions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API surface"]
  node_controllers["API controllers<br/>[Controllers]"]
end

subgraph group_domain["Business workflows"]
  node_auth["Authentication<br/>[AuthService.cs]"]
  node_projects["Project management<br/>[ProjectsService.cs]"]
  node_services["Mail services<br/>[ServiceManager.cs]"]
  node_submissions["Email submissions"]
  node_templates["Templates<br/>[TemplateService.cs]"]
  node_integrations["Integrations"]
  node_billing["Billing and plans<br/>[BillingService.cs]"]
  node_analytics["Analytics"]
  node_admin["Administration<br/>[AdminService.cs]"]
end

subgraph group_infra["Shared infrastructure"]
  node_email["Email delivery"]
  node_attachments["Attachment handling"]
  node_tokens["Token service<br/>[TokenService.cs]"]
  node_result["Result envelope<br/>[Result.cs]"]
end

subgraph group_data["Persistence"]
  node_uow["Unit of work<br/>[IUnitOfWork.cs]"]
  node_context["Entity context<br/>[EmailyDbContext.cs]"]
end

node_client(("API client"))
node_blob[("Azure Blob Storage")]

node_client -->|"sends requests"| node_controllers
node_controllers -->|"calls"| node_auth
node_controllers -->|"calls"| node_projects
node_controllers -->|"calls"| node_admin
node_controllers -.->|"routes to"| node_submissions
node_controllers -.->|"routes to"| node_services
node_controllers -.->|"routes to"| node_templates
node_controllers -.->|"routes to"| node_integrations
node_controllers -.->|"routes to"| node_billing
node_controllers -.->|"routes to"| node_analytics
node_auth -->|"reads and saves"| node_uow
node_auth -->|"generates tokens"| node_tokens
node_auth -->|"sends messages"| node_email
node_projects -.->|"persists data"| node_uow
node_services -->|"reads and saves"| node_uow
node_submissions -->|"persists submissions"| node_uow
node_submissions -->|"sends email"| node_email
node_submissions -->|"handles files"| node_attachments
node_attachments -->|"uploads and downloads"| node_blob
node_templates -.->|"persists data"| node_uow
node_integrations -.->|"persists data"| node_uow
node_billing -.->|"persists data"| node_uow
node_analytics -.->|"reads data"| node_uow
node_admin -.->|"manages records"| node_uow
node_uow -->|"uses context"| node_context
node_controllers -.->|"returns results"| node_result

click node_controllers "https://github.com/ahm3dramad3n/emailybackend/tree/main/Emaily.API/Controllers"
click node_auth "https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Services/AuthService.cs"
click node_projects "https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Services/ProjectsService.cs"
click node_services "https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Services/ServiceManager.cs"
click node_submissions "https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Services/SubmissionService.cs"
click node_templates "https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Services/TemplateService.cs"
click node_integrations "https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Services/IntegrationService.cs"
click node_billing "https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Services/BillingService.cs"
click node_analytics "https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Services/AnalyticsService.cs"
click node_admin "https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Services/AdminService.cs"
click node_uow "https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.DAL/Interfaces/IUnitOfWork.cs"
click node_context "https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.DAL/Entities/EmailyDbContext.cs"
click node_email "https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Helpers/Interfaces/IEmailSenderService.cs"
click node_attachments "https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Helpers/Services/AttachmentManager.cs"
click node_tokens "https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Helpers/Services/TokenService.cs"
click node_result "https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/DTOs/Result.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_controllers,node_client toneBlue
class node_auth,node_projects,node_services,node_submissions,node_templates,node_integrations,node_billing,node_analytics,node_admin,node_blob toneAmber
class node_email,node_attachments,node_tokens,node_result toneMint
class node_uow,node_context toneRose
```

## Components

### API surface

- [API controllers](https://github.com/ahm3dramad3n/emailybackend/tree/main/Emaily.API/Controllers): `Emaily.API/Controllers`

### Business workflows

- [Authentication](https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Services/AuthService.cs): `Emaily.BLL/Services/AuthService.cs`
- [Project management](https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Services/ProjectsService.cs): `Emaily.BLL/Services/ProjectsService.cs`
- [Mail services](https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Services/ServiceManager.cs): `Emaily.BLL/Services/ServiceManager.cs`
- [Email submissions](https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Services/SubmissionService.cs): `Emaily.BLL/Services/SubmissionService.cs`
- [Templates](https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Services/TemplateService.cs): `Emaily.BLL/Services/TemplateService.cs`
- [Integrations](https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Services/IntegrationService.cs): `Emaily.BLL/Services/IntegrationService.cs`
- [Billing and plans](https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Services/BillingService.cs): `Emaily.BLL/Services/BillingService.cs`
- [Analytics](https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Services/AnalyticsService.cs): `Emaily.BLL/Services/AnalyticsService.cs`
- [Administration](https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Services/AdminService.cs): `Emaily.BLL/Services/AdminService.cs`

### Shared infrastructure

- [Email delivery](https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Helpers/Interfaces/IEmailSenderService.cs): `Emaily.BLL/Helpers/Interfaces/IEmailSenderService.cs`
- [Attachment handling](https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Helpers/Services/AttachmentManager.cs): `Emaily.BLL/Helpers/Services/AttachmentManager.cs`
- [Token service](https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/Helpers/Services/TokenService.cs): `Emaily.BLL/Helpers/Services/TokenService.cs`
- [Result envelope](https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.BLL/DTOs/Result.cs): `Emaily.BLL/DTOs/Result.cs`

### Persistence

- [Unit of work](https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.DAL/Interfaces/IUnitOfWork.cs): `Emaily.DAL/Interfaces/IUnitOfWork.cs`
- [Entity context](https://github.com/ahm3dramad3n/emailybackend/blob/main/Emaily.DAL/Entities/EmailyDbContext.cs): `Emaily.DAL/Entities/EmailyDbContext.cs`

### Other components

- **API client**
- **Azure Blob Storage**

## Connections

- API client → API controllers: sends requests
- API controllers → Authentication: calls (evidence: `Emaily.API/Controllers/AuthController.cs`)
- API controllers → Project management: calls (evidence: `Emaily.API/Controllers/ProjectsController.cs`)
- API controllers → Administration: calls (evidence: `Emaily.API/Controllers/AdminController.cs`)
- API controllers → Email submissions: routes to
- API controllers → Mail services: routes to
- API controllers → Templates: routes to
- API controllers → Integrations: routes to
- API controllers → Billing and plans: routes to
- API controllers → Analytics: routes to
- Authentication → Unit of work: reads and saves (evidence: `Emaily.BLL/Services/AuthService.cs`)
- Authentication → Token service: generates tokens (evidence: `Emaily.BLL/Services/AuthService.cs`)
- Authentication → Email delivery: sends messages (evidence: `Emaily.BLL/Services/AuthService.cs`)
- Project management → Unit of work: persists data
- Mail services → Unit of work: reads and saves (evidence: `Emaily.BLL/Services/ServiceManager.cs`)
- Email submissions → Unit of work: persists submissions (evidence: `Emaily.BLL/Services/SubmissionService.cs`)
- Email submissions → Email delivery: sends email (evidence: `Emaily.BLL/Services/SubmissionService.cs`)
- Email submissions → Attachment handling: handles files (evidence: `Emaily.BLL/Services/SubmissionService.cs`)
- Attachment handling → Azure Blob Storage: uploads and downloads (evidence: `Emaily.BLL/Helpers/Services/AttachmentManager.cs`)
- Templates → Unit of work: persists data
- Integrations → Unit of work: persists data
- Billing and plans → Unit of work: persists data
- Analytics → Unit of work: reads data
- Administration → Unit of work: manages records
- Unit of work → Entity context: uses context (evidence: `Emaily.BLL/DependencyInjection.cs`)
- API controllers → Result envelope: returns results
