# darrassipro/smtp_send_back architecture

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

- Interactive diagram: https://gitdiagram.com/darrassipro/smtp_send_back
- Repository: https://github.com/darrassipro/smtp_send_back

## Overview

##### Project type and purpose
- This is a server-side Node.js/Express application focused on email operations (sending emails, storing drafts and attachments, SMTP relay).
- It exposes HTTP endpoints handled by controllers, applies middleware, delegates to services, stores uploaded files locally, and talks to an external SMTP provider.

##### File structure
- Entry point: server.js
- config/default.js for environment settings (e.g., SMTP credentials, storage paths)
- middleware/ for cross-cutting logic (admin-auth, error-handler)
- controllers/ for HTTP route handlers (attachment, draft, email, smtp)
- services/ for business logic (email.service, store.service)
- uploads/ for persisted files (PDF attachments)
- vercel.json indicates Vercel deployment

##### Main components
- Client (e.g., Web app or API consumer)
- Express HTTP Server (server.js)
- Middleware layer (admin-auth, error-handler)
- Controller layer
- Service layer
- Local storage (uploads directory)
- External SMTP service (3rd-party email relay)
- Configuration module

##### Relationships and data flow
- Client → HTTP Server
- Server invokes Middleware → Controllers
- Controllers call Services
- Services read/write local storage or call external SMTP
- Config is used by Server, Controllers, Services

##### Architectural patterns & design principles
- Layered architecture: HTTP → middleware → controllers → services → data/external systems
- Separation of concerns: authentication, error handling, business logic, data/storage
- Configuration centralization

## Diagram (Mermaid)

```mermaid
graph TB
  A["Client\n(Web or API)"]:::external
  B(("Express Server")):::internal

  A -->|"HTTP Request"| B

  subgraph "Middleware Layer"
    D["admin-auth"]:::internal
    E["error-handler"]:::internal
  end

  B --> D
  B --> E

  subgraph "Controller Layer"
    G["attachment.controller.js"]:::internal
    H["draft.controller.js"]:::internal
    I["email.controller.js"]:::internal
    J["smtp.controller.js"]:::internal
  end

  D --> G
  E --> G
  D --> H
  E --> H
  D --> I
  E --> I
  D --> J
  E --> J

  subgraph "Service Layer"
    K["store.service.js"]:::internal
    M["email.service.js"]:::internal
  end

  G --> K
  H --> K
  I --> K
  J --> M

  K --> L[("Local Storage\nuploads/")]:::external
  M --> N(("External SMTP Provider")):::external

  subgraph "Config Layer"
    O["config/default.js"]:::external
  end

  B --> O
  G --> O
  H --> O
  I --> O
  J --> O
  K --> O
  M --> O

  classDef internal fill:#f9f,stroke:#333,stroke-width:1px;
  classDef external fill:#bbf,stroke:#333,stroke-width:1px,stroke-dasharray:5 5;

  click B "https://github.com/darrassipro/smtp_send_back/blob/master/server.js"
  click O "https://github.com/darrassipro/smtp_send_back/blob/master/config/default.js"
  click D "https://github.com/darrassipro/smtp_send_back/blob/master/middleware/admin-auth.js"
  click E "https://github.com/darrassipro/smtp_send_back/blob/master/middleware/error-handler.js"
  click G "https://github.com/darrassipro/smtp_send_back/blob/master/controllers/attachment.controller.js"
  click H "https://github.com/darrassipro/smtp_send_back/blob/master/controllers/draft.controller.js"
  click I "https://github.com/darrassipro/smtp_send_back/blob/master/controllers/email.controller.js"
  click J "https://github.com/darrassipro/smtp_send_back/blob/master/controllers/smtp.controller.js"
  click K "https://github.com/darrassipro/smtp_send_back/blob/master/services/store.service.js"
  click M "https://github.com/darrassipro/smtp_send_back/blob/master/services/email.service.js"
  click L "https://github.com/darrassipro/smtp_send_back/tree/master/uploads/"
```
