# saravanan-ganesan/outlook-exchange-send-mail architecture

> Architecture diagram of the GitHub repository saravanan-ganesan/outlook-exchange-send-mail, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saravanan-ganesan/outlook-exchange-send-mail
- Repository: https://github.com/saravanan-ganesan/outlook-exchange-send-mail

## Overview

#### Purpose and Entry Point
A Spring Boot service that sends email through Microsoft Outlook/Exchange Web Services (EWS). The application starts from `src/main/java/com/sara/mail/OutlookExchangeSendMailApplication.java` and exposes an HTTP endpoint for mail submission.

#### HTTP API Boundary
`src/main/java/com/sara/mail/controller/SendMailController.java` is the inbound REST/controller boundary. Requests to the documented `/sendMail` endpoint are translated into the application’s EWS send-mail operation rather than directly exposing EWS to callers.

#### Exchange/EWS Integration
The core external dependency is Outlook Exchange Web Services, authenticated using supplied email credentials. The controller/configuration layer establishes or consumes an EWS client/session to execute send and potentially other mailbox operations, as described by the README.

#### Mail Configuration and Credentials
`src/main/java/com/sara/mail/config/MailConfig.java` centralizes mail-service setup, likely including EWS client construction and credential/property binding. `src/main/resources/mail.properties` is the configuration boundary for Exchange connection and account settings; credentials should remain environment-specific rather than embedded in code.

#### Primary Control Flow
1. Spring Boot initializes the application and mail configuration.
2. Mail properties are loaded into the EWS/mail setup.
3. A client calls the controller’s `/sendMail` route.
4. `SendMailController` invokes the configured Outlook/EWS service client.
5. EWS authenticates to Exchange and submits the message; the controller returns the operation result over HTTP.

#### Runtime and Infrastructure
The service runs on the JVM with Maven dependency management (`pom.xml`) and Spring Boot’s embedded HTTP server, as implied by the `localhost:8080` endpoint. Its material external infrastructure is a reachable Outlook/Exchange EWS endpoint and valid mailbox credentials.

#### Package Structure and Ownership Boundary
Application code is under `src/main/java/com/sara/mail`, with clear bootstrap, configuration, and transport-controller separation. Note that the test package uses a different root (`src/test/java/com/matson/mail`), which may affect component/test discovery alignment if tests depend on Spring package scanning.

Main entry points: [`src/main/java/com/sara/mail/controller/SendMailController.java`](https://github.com/saravanan-ganesan/outlook-exchange-send-mail/blob/main/src/main/java/com/sara/mail/controller/SendMailController.java) (Send Mail Controller), [`src/main/java/com/sara/mail/OutlookExchangeSendMailApplication.java`](https://github.com/saravanan-ganesan/outlook-exchange-send-mail/blob/main/src/main/java/com/sara/mail/OutlookExchangeSendMailApplication.java) (Application Bootstrap), [`src/main/java/com/sara/mail/config/MailConfig.java`](https://github.com/saravanan-ganesan/outlook-exchange-send-mail/blob/main/src/main/java/com/sara/mail/config/MailConfig.java) (Mail Configuration), [`src/main/resources/mail.properties`](https://github.com/saravanan-ganesan/outlook-exchange-send-mail/blob/main/src/main/resources/mail.properties) (Mail Properties)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Spring Boot Service"]
  node_boot{{"Application Bootstrap<br/>Spring Boot entry point"}}
  node_controller["Send Mail Controller<br/>REST controller"]
  node_mailconfig["Mail Configuration<br/>Spring configuration<br/>[MailConfig.java]"]
  node_properties["Mail Properties<br/>connection settings<br/>[mail.properties]"]
end

subgraph group_integration["Exchange Integration"]
  node_ewsclient["EWS Client Session<br/>Exchange client"]
  node_credentials["Mailbox Credentials<br/>secret input"]
  node_exchange{{"Outlook / Exchange EWS<br/>external mail service"}}
end

subgraph group_runtime["Runtime &amp; Infrastructure"]
  node_maven["Maven Build<br/>[pom.xml]"]
  node_jvm{{"JVM Process<br/>runtime"}}
  node_http["Embedded HTTP Server<br/>Spring Boot server"]
end

node_caller(("HTTP Client<br/>API consumer"))
node_result["HTTP Operation Result<br/>API response"]

node_maven -->|"packages dependencies"| node_jvm
node_jvm -->|"starts"| node_boot
node_boot -->|"initializes"| node_http
node_boot -->|"loads configuration"| node_mailconfig
node_properties -->|"binds settings"| node_mailconfig
node_mailconfig -->|"constructs"| node_ewsclient
node_credentials -->|"authenticates"| node_ewsclient
node_caller -->|"POST /sendMail"| node_http
node_http -->|"routes request"| node_controller
node_controller -->|"submits mail operation"| node_ewsclient
node_ewsclient -->|"EWS request"| node_exchange
node_exchange -->|"operation outcome"| node_controller
node_controller -->|"returns HTTP response"| node_result

click node_maven "https://github.com/saravanan-ganesan/outlook-exchange-send-mail/blob/main/pom.xml"
click node_boot "https://github.com/saravanan-ganesan/outlook-exchange-send-mail/blob/main/src/main/java/com/sara/mail/OutlookExchangeSendMailApplication.java"
click node_controller "https://github.com/saravanan-ganesan/outlook-exchange-send-mail/blob/main/src/main/java/com/sara/mail/controller/SendMailController.java"
click node_mailconfig "https://github.com/saravanan-ganesan/outlook-exchange-send-mail/blob/main/src/main/java/com/sara/mail/config/MailConfig.java"
click node_properties "https://github.com/saravanan-ganesan/outlook-exchange-send-mail/blob/main/src/main/resources/mail.properties"

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_boot,node_controller,node_mailconfig,node_properties toneBlue
class node_ewsclient,node_credentials,node_exchange toneAmber
class node_maven,node_jvm,node_http toneMint
class node_caller,node_result toneNeutral
```

## Components

### Spring Boot Service

- [Application Bootstrap](https://github.com/saravanan-ganesan/outlook-exchange-send-mail/blob/main/src/main/java/com/sara/mail/OutlookExchangeSendMailApplication.java): Spring Boot entry point · `src/main/java/com/sara/mail/OutlookExchangeSendMailApplication.java`
- [Send Mail Controller](https://github.com/saravanan-ganesan/outlook-exchange-send-mail/blob/main/src/main/java/com/sara/mail/controller/SendMailController.java): REST controller · Handles the /sendMail submission route. · `src/main/java/com/sara/mail/controller/SendMailController.java`
- [Mail Configuration](https://github.com/saravanan-ganesan/outlook-exchange-send-mail/blob/main/src/main/java/com/sara/mail/config/MailConfig.java): Spring configuration · Builds or supplies the EWS mail client. · `src/main/java/com/sara/mail/config/MailConfig.java`
- [Mail Properties](https://github.com/saravanan-ganesan/outlook-exchange-send-mail/blob/main/src/main/resources/mail.properties): connection settings · Environment-specific Exchange account and endpoint settings. · `src/main/resources/mail.properties`

### Exchange Integration

- **EWS Client Session**: Exchange client · Authenticated client used for mailbox operations.
- **Mailbox Credentials**: secret input · Supplied credentials authenticate the Exchange account.
- **Outlook / Exchange EWS**: external mail service · Accepts authenticated message submissions.

### Runtime & Infrastructure

- [Maven Build](https://github.com/saravanan-ganesan/outlook-exchange-send-mail/blob/main/pom.xml): build · Manages Spring Boot and EWS dependencies. · `pom.xml`
- **JVM Process**: runtime
- **Embedded HTTP Server**: Spring Boot server · Serves the API on the application process.

### Other components

- **HTTP Client**: API consumer
- **HTTP Operation Result**: API response

## Connections

- Maven Build → JVM Process: packages dependencies
- JVM Process → Application Bootstrap: starts
- Application Bootstrap → Embedded HTTP Server: initializes
- Application Bootstrap → Mail Configuration: loads configuration
- Mail Properties → Mail Configuration: binds settings
- Mail Configuration → EWS Client Session: constructs
- Mailbox Credentials → EWS Client Session: authenticates
- HTTP Client → Embedded HTTP Server: POST /sendMail
- Embedded HTTP Server → Send Mail Controller: routes request
- Send Mail Controller → EWS Client Session: submits mail operation
- EWS Client Session → Outlook / Exchange EWS: EWS request
- Outlook / Exchange EWS → Send Mail Controller: operation outcome
- Send Mail Controller → HTTP Operation Result: returns HTTP response
