π§ A powerful AI-powered email assistant that integrates with Gmail to help you write better emails. This project includes:
- A Chrome Extension that adds an "AI Reply" button directly in Gmail
- A standalone web application for composing emails
- A Spring Boot backend that handles the AI processing using Google's Gemini AI
An intelligent email composition and reply generation system powered by AI. This project consists of a Chrome extension, a React-based frontend, and a Spring Boot backend that work together to provide smart email assistance.
- AI-Powered Email Generation: Generate intelligent email replies and compositions using Google's Gemini AI
- Chrome Extension Integration: Seamless integration with Gmail through a modern Chrome extension with popup interface
- Automatic Email Detection: Smart detection and extraction of email content from Gmail
- Multiple Tone Options: Choose from different writing tones (formal, casual, friendly, etc.)
- Modern Web Interface: Clean and intuitive React frontend with Material-UI components and Vite build system
- RESTful API: Robust Spring Boot backend with REST endpoints
- Real-time Processing: Fast email generation with loading states and error handling
- Cross-Platform: Works across different email platforms and browsers
- Secure API Key Management: Safe handling of API credentials with template-based configuration
The project follows a microservices architecture with three main components:
Smart Email Assistant/
βββ email-writer-backend/ # Spring Boot REST API
βββ email-writer-frontend/ # React Web Application
βββ email-writer-extension/ # Chrome Extension
- Technology: Java 21, Spring Boot 3.5.4
- Features: RESTful API, CORS support, Lombok integration
- Endpoints: Email generation and health check APIs
- Technology: React 19.1.0, Vite 7.0.4, Material-UI 7.2.0
- Features: Modern UI components, responsive design, routing, styled-components
- Build System: Vite for fast development and optimized builds
- Styling: Material-UI with emotion and styled-components integration
- HTTP Client: Axios for API communication
- Technology: Vanilla JavaScript, Manifest V3, React components
- Features: Gmail integration, content script injection, popup interface with React
- Capabilities: Email content detection, tone selection, real-time generation
- Permissions: Active tab access, storage, scripting for Gmail integration
Before running this project, make sure you have the following installed:
- Java 21 or higher
- Node.js (v18 or higher)
- npm or yarn
- Maven (for Spring Boot backend)
- Google Chrome (for extension testing)
- Gemini API Key (from Google AI Studio)
git clone https://github.com/Minulck/Smart-Email-Assistant.git
cd Smart-Email-Assistant# Navigate to backend directory
cd email-writer-backend
# For Windows
mvnw.cmd clean install
# For Unix/Linux/MacOS
./mvnw clean install- Set up environment variables for Gemini AI:
On Windows (PowerShell):
$env:GEMINI_API_KEY="your-actual-api-key-here"
$env:GEMINI_API_URL="https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent"On Windows (Command Prompt):
set GEMINI_API_KEY=your-actual-api-key-here
set GEMINI_API_URL=https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContentOn Unix/Linux/MacOS:
export GEMINI_API_KEY="your-actual-api-key-here"
export GEMINI_API_URL="https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent"For permanent setup:
- Windows: Add these variables in System Properties > Environment Variables
- Unix/Linux/MacOS: Add to
~/.bashrcor~/.zshrc
# For Windows
mvnw.cmd spring-boot:run
# For Unix/Linux/MacOS
./mvnw spring-boot:run
# The backend will start on http://localhost:8080# Test the health endpoint
curl http://localhost:8080/api/email/hello
# Should return: "hello world"# Navigate to frontend directory
cd email-writer-frontend
# Install dependencies
npm install
# Create development build
npm run build
# Start development server
npm run dev
# The frontend will start on http://localhost:5173Create .env.local for environment variables:
# Windows
copy nul .env.local
# Unix/Linux/MacOS
touch .env.localAdd the following variables if needed:
VITE_API_URL=http://localhost:8080- Open
http://localhost:5173in your browser - You should see the email composition interface
- Try generating an email to test the connection to the backend
# Navigate to extension directory
cd email-writer-extension
# Install dependencies
npm install
# Build the extension
npm run build- Open Chrome and navigate to
chrome://extensions/ - Enable "Developer mode" by toggling the switch in the top right corner
- Click "Load unpacked" button that appears after enabling developer mode
- Select the extension folder:
- If you built the extension: Select the
distfolder insideemail-writer-extension - If using directly: Select the
email-writer-extensionfolder
- If you built the extension: Select the
- The extension will be installed and you'll see its icon in your Chrome toolbar
- After making changes to the extension code:
cd email-writer-extension npm run build - Go to
chrome://extensions/ - Find the Smart Email Assistant extension
- Click the refresh icon (π) to reload the extension
- If the extension doesn't appear, make sure all files in
manifest.jsonare present - Check Chrome's developer console for any errors
- Try removing and re-adding the extension if updates aren't showing
- Ensure the backend server is running for the extension to work properly
The backend uses environment variables for configuration. Here's how to set them up:
-
Required Environment Variables:
GEMINI_API_KEY=your-actual-api-key-here GEMINI_API_URL=https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent
-
Setting Environment Variables:
Windows (PowerShell):
$env:GEMINI_API_KEY="your-actual-api-key-here" $env:GEMINI_API_URL="https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent"
Windows (Command Prompt):
set GEMINI_API_KEY=your-actual-api-key-here set GEMINI_API_URL=https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent
Unix/Linux/MacOS:
export GEMINI_API_KEY="your-actual-api-key-here" export GEMINI_API_URL="https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent"
-
Permanent Setup:
Windows:
- Open System Properties (Win + Pause/Break)
- Click "Environment Variables"
- Add under "System variables" or "User variables"
Unix/Linux/MacOS:
- Add to your shell's configuration file:
# Add to ~/.bashrc or ~/.zshrc export GEMINI_API_KEY="your-actual-api-key-here" export GEMINI_API_URL="https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent"
-
Important Security Notes:
- Never commit your actual API keys to the repository
- Keep your API keys secure and do not share them publicly
- Consider using a key management service in production
The backend is configured through environment variables and application properties.
Located at email-writer-backend/src/main/resources/application.properties:
spring.application.name=email-writer
server.port=8080
# These values are replaced by environment variables
gemini.api.url=${GEMINI_API_URL}
gemini.api.key=${GEMINI_API_KEY}If using Docker, you can pass environment variables in the docker run command:
docker run -e GEMINI_API_KEY="your-key" -e GEMINI_API_URL="your-url" -p 8080:8080 email-writer-backendOr using docker-compose:
services:
backend:
build: ./email-writer-backend
environment:
- GEMINI_API_KEY=your-key
- GEMINI_API_URL=your-url
ports:
- "8080:8080"The frontend uses Vite for development. Configuration can be found in vite.config.js:
// Vite configuration
export default defineConfig({
plugins: [react()],
// Add other configurations
})The extension configuration is in manifest.json:
{
"name": "Email Writer Assistant",
"description": "AI Powered Email Composition",
"version": "1.0",
"manifest_version": 3,
"permissions": ["activeTab", "storage", "scripting"],
"host_permissions": ["http://localhost:8000/*", "*://mail.google.com/*"],
"action": {
"default_title": "Email Writer Assistant",
"default_popup": "popup.html"
}
}POST /api/email/generate
Generate an intelligent email reply based on the provided context and tone preference.
Request Body:
{
"subject": "Email subject",
"content": "Original email content",
"context": "Additional context for generation",
"tone": "formal" // Options: formal, casual, friendly, professional
}Response:
{
"generatedReply": "AI-generated email content based on input parameters"
}GET /api/email/hello
Health check endpoint that returns a simple greeting.
Response:
{
"message": "Hello from Email Writer API!"
}The extension adds several features to Gmail:
-
AI Reply Button:
- Appears in Gmail's compose window
- Click to generate AI-powered responses
- Supports multiple email tones
-
Popup Interface:
- Access via the extension icon in Chrome toolbar
- Features:
- Email content detection
- Tone selection (formal, casual, friendly, etc.)
- One-click generation
- Copy to clipboard functionality
- Open Gmail in Chrome
- Start composing or replying to an email
- Use the extension in two ways:
- Click the "AI Reply" button in Gmail's compose toolbar
- Or use the extension popup from Chrome's toolbar
- Select your preferred tone
- Click "Generate Reply"
- Review and edit the generated content as needed
- Ensure the backend server is running
- Check Chrome's console (F12) if the button doesn't appear
- Allow up to 5 seconds for AI generation
- Review and customize generated content before sending
- Start the backend and frontend servers as described in the setup section
- Open your browser and go to
http://localhost:5173 - Use the React frontend to interact with the email generation features
- Input email content and select desired tone
- Generate and refine email replies using the AI capabilities
cd email-writer-backend
./mvnw testcd email-writer-frontend
npm run testSmart-Email-Assistant/
βββ email-writer-backend/
β βββ src/
β β βββ main/
β β β βββ java/com/email/writer/
β β β β βββ EmailWriterApplication.java
β β β β βββ replygenerte/
β β β β βββ EmailGeneratorController.java
β β β β βββ EmailGeneratorService.java
β β β β βββ EmailRequest.java
β β β βββ resources/
β β β βββ application.properties
β β β βββ api-keys.properties.template
β β β βββ api-keys.properties (created by user)
β β βββ test/
β βββ pom.xml
β βββ mvnw / mvnw.cmd
β βββ target/
βββ email-writer-frontend/
β βββ src/
β β βββ App.jsx
β β βββ main.jsx
β β βββ App.css
β β βββ index.css
β β βββ assets/
β βββ package.json
β βββ vite.config.js
β βββ eslint.config.js
β βββ index.html
βββ email-writer-extension/
β βββ manifest.json
β βββ background.js
β βββ content.js
β βββ content.css
β βββ popup.html
β βββ popup-app.jsx
β βββ index.html
β βββ assets/
β βββ index-C4djW0Rs.js
βββ README.md
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions, please:
- Check the existing Issues
- Create a new issue if your problem isn't already reported
- Provide detailed information about your environment and the issue
- v1.0.0 - Initial release with:
- Basic email generation functionality using Gemini AI
- Chrome extension with popup interface
- React frontend with Material-UI components
- Spring Boot backend with REST API
- Automatic email detection from Gmail
- Multiple tone options for email generation
- Secure API key management
Happy Emailing! π§β¨