Mail'O is a professional, AI-powered email writing assistant designed to streamline the process of drafting polished, context-aware emails. By entering a recipient's name, a brief description of the message, and selecting a desired tone, users can instantly generate high-quality email drafts. Mail'O is built with a modern React frontend and a robust Java Spring Boot backend, utilizing Spring AI to communicate with Google's Gemini models for prompt completion and content generation.
Note
The screenshots below illustrate the responsive UI, tone-switching features, and generated email drafts. Please place your actual screenshots in the docs/screenshots/ folder to activate the visual showcase.
- AI-Powered Email Generation: Formulates structured, context-aware email subjects and bodies using Google's Gemini model.
- Multiple Email Tones: Establishes context-appropriate greetings and writing styles based on the selected tone:
- Professional: Formal, structured, business-ready language.
- Simple & Direct: Fluff-free, clear, and concise messaging.
- Friendly: Conversational, warm, and approachable language.
- Recipient and Context Customization: Tailors the email's greetings, style, and sign-offs dynamically based on the recipient's identity and description.
- Input Validation: Enforces parameters on both frontend fields and backend DTOs to maintain database and API integrity.
- Actionable Output: Includes one-click copy to clipboard and a pre-filled compose button to export drafts directly to Gmail.
- Responsive User Interface: Features a responsive layout with theme toggle (Light and Dark mode) using Tailwind CSS and DaisyUI.
- API Documentation: Integrates Swagger UI/OpenAPI to allow developers to interact with the endpoints directly.
- User Input: The user inputs the recipient's name, selects a tone, describes the email's content (minimum 10 characters), and submits the form.
- Frontend Validation: React validates the input lengths and formatting to prevent invalid API requests.
- HTTP POST Request: Axios transmits the validated data in JSON format to the
/api/generateMailendpoint. - Backend Bean Validation: Spring Boot interceptors validate the incoming request properties against Jakarta Bean Validation annotations.
- Service Processing: The backend service layer constructs a structured instruction prompt containing the name, description, selected tone, and today's date.
- Spring AI Chat Client: The ChatClient formats and transmits the prompt securely to the Google Gemini model.
- AI Generation: Google Gemini analyzes the prompt and returns a tailored subject line and email body.
- UI Rendering & Toasts: The backend returns the email payload, React updates the local states to display the split subject/body layout, and triggers a success toast notification.
graph TD
classDef client fill:#3b82f6,stroke:#1d4ed8,stroke-width:2px,color:#fff;
classDef server fill:#10b981,stroke:#047857,stroke-width:2px,color:#fff;
classDef external fill:#f59e0b,stroke:#d97706,stroke-width:2px,color:#fff;
A[React Frontend]:::client -->|Axios HTTP POST| B[Spring Boot REST API]:::server
B -->|Jakarta Bean Validation| C[AppController]:::server
C -->|MailRequest DTO| D[AppService]:::server
D -->|Spring AI ChatClient| E[Google Gemini API]:::external
E -->|Generated Email Response| D
D -->|MailResponse DTO| C
C -->|JSON Payload Response| A
- React 19 - User interface rendering
- Vite 8 - Frontend building and local dev server
- Tailwind CSS v3 - Utility-first styling framework
- DaisyUI v4 - Tailwind-based UI components
- React Router v7 - Client-side page navigation
- Axios - HTTP client request handling
- React Hot Toast - Non-blocking system notifications
- React Icons - Vector icons library
- Java 21 - Runtime environment and compile target
- Spring Boot 4.1.1 - Main application framework
- Spring Web MVC - RESTful controller endpoints routing
- Spring AI (Google GenAI Starter v2.0.0) - Model configuration and prompt management
- Jakarta Bean Validation - DTO attribute validation
- Springdoc OpenAPI v3 (v3.0.3) - Automated Swagger documentation
- Lombok - Automatic builder, getter, and setter generation
- Maven - Build tool and dependency manager
- Google Gemini 3.6 Flash (
gemini-3.6-flash)
Mail'O leverages Google's gemini-3.6-flash model through the Spring AI framework. In the backend AppService.java class, the application compiles user input into a clean instruction prompt:
Write an email based on the following instructions:
From Name: Rajeev
Recipient Name: [toName]
Tone: [tone]
Today's Date: [currentDate]
Description of what to say: [description]
Please provide a suitable Subject line, followed by the email body.
Address the email to the recipient provided. Use [Your Name] as a placeholder for the sender.
Do not include any extra conversational text outside of the email itself.
The model returns a plain text response containing the subject and body. The frontend parses this structure using a newline search to display the Subject and Body in separate copy-friendly fields.
Mail'O/
βββ client/ # React Frontend (Vite)
β βββ src/
β β βββ components/ # Reusable UI components (Navbar, EmailForm, EmailResult, ThemeToggle)
β β βββ layouts/ # Layout wrappers (MainLayout)
β β βββ pages/ # Full page views (Home, EmailGenerator, Features, NotFound)
β β βββ services/ # Network API services (emailService.js)
β β βββ main.jsx # Frontend entry point
β βββ package.json # Frontend scripts and dependencies
β βββ vite.config.js # Vite build settings
β
βββ server/ # Spring Boot Backend (Maven)
βββ src/main/java/com/rj/mailO/
β βββ config/ # System configurations (CorsConfig)
β βββ controller/ # REST Endpoint controllers (AppController)
β βββ dto/ # Data Transfer Objects (MailRequest, MailResponse)
β βββ service/ # AI prompt handling and business services (AppService)
βββ src/main/resources/
β βββ application.properties # Server properties and Spring AI model variables
βββ pom.xml # Maven dependencies configuration
Make sure you have the following installed on your machine:
- Node.js (v18.0.0 or higher)
- JDK 21
- Google Gemini API Key (Obtain one from Google AI Studio)
Configure your credentials in the server folder. Create a .env file in server/:
GEMINI_API_KEY=your_actual_gemini_api_key_hereWarning
Security Warning: Never commit your .env file or raw API keys to Git. The project's root .gitignore file is pre-configured to ignore all .env files.
- Navigate to the server directory:
cd server - Start the Spring Boot server using the Maven wrapper:
- Windows:
./mvnw.cmd spring-boot:run
- macOS/Linux:
./mvnw spring-boot:run
http://localhost:8080. - Windows:
- Navigate to the client directory:
cd client - Install the required packages:
npm install
- Launch the Vite local server:
The application will run locally at
npm run dev
http://localhost:5173.
- Open the application by visiting
http://localhost:5173. - Go to the Email Generator page.
- Enter the Recipient Name (e.g., Hiring Manager, Support Team).
- Enter the Email Description explaining what the email is about (minimum 10 characters).
- Select a Tone (Professional, Simple & Direct, or Friendly).
- Click Generate AI Email.
- Review the subject line and body output.
- Click Copy to copy the content to your clipboard, or Send Email to open the pre-filled message in Gmail.
To maintain data integrity and avoid unnecessary AI API consumption, validation rules are enforced at both layers:
toName(@NotNull): The recipient name field is required and cannot be null.description(@NotBlank,@Size): The description field is required and must contain between 10 and 2000 characters.tone(@NotNull): A valid tone parameter matching one of theToneEnumvalues is required.
- HTTP 400 Bad Request: If any validation rules are breached, the backend rejects the payload and returns an error array with descriptions.
- Frontend Alerts: The Axios service layer catches HTTP failures, formats nested validation constraints, and surfaces them using React Hot Toast messages and a visual error banner in the UI.
- Swagger Interactive UI:
http://localhost:8080/swagger-ui/index.html - OpenAPI Specification JSON:
http://localhost:8080/v3/api-docs
- Endpoint:
/api/generateMail - Method:
POST - Content-Type:
application/json
| Field | Type | Required | Description / Constraints |
|---|---|---|---|
toName |
String | Yes | Name of the recipient |
description |
String | Yes | Core email context (10 to 2000 characters) |
tone |
String | Yes | Selected tone: PROFESSIONAL, SIMPLE, FRIENDLY |
{
"toName": "Support Team",
"description": "Requesting an extension on the project deadline due to server downtime.",
"tone": "PROFESSIONAL"
}{
"result": "Subject: Request for Deadline Extension - Server Downtime\n\nDear Support Team,\n\nI hope this email finds you well. I am writing to request a short extension on the project deadline..."
}To package the React frontend, navigate to the client/ directory and run:
npm run buildThis generates optimized, minified production assets in the client/dist/ directory.
To package the Spring Boot backend into an executable JAR, navigate to the server/ directory and run:
./mvnw clean packageThe standalone executable JAR will be generated under server/target/.
When deploying to cloud providers:
- Configure the database or target profiles using Spring profiles (
spring.profiles.active). - Ensure that the
GEMINI_API_KEYis configured as a secure system environment variable rather than hardcoded.
- AI email generation using Google Gemini model
- Multiple email tones (Professional, Simple, Friendly)
- Jakarta Bean DTO validation and Axios error formatting
- Direct clipboard copy integration
- Responsive layout with Light/Dark mode switcher
- Email history persistence (Database integration)
- OAuth2 Authentication (Google/GitHub sign-in)
- Direct Gmail API integration (Drafting/sending without redirects)
- Multi-LLM provider support (switching between OpenAI, Anthropic, Gemini)
- RAG-based email replies using historical threads or files
- Fork the repository.
- Create a feature branch:
git checkout -b feature/your-feature-name. - Commit your changes:
git commit -m 'Add some feature'. - Push to the branch:
git push origin feature/your-feature-name. - Submit a Pull Request.
No license is currently specified for this project.


