Skip to content

atharv96k/SEW-BACKEND

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Smart Email Writer Backend

This repository contains the Java-based Spring Boot backend for the Smart Email Writer application. It acts as a bridge between the user interface (Chrome Extension/Web App) and the Google Gemini AI, providing an API to generate context-aware email replies.

๐Ÿ› ๏ธ Technical Overview

The backend is built using the following stack:

  • Framework: Spring Boot 3.2.1
  • Language: Java 17
  • AI Integration: Google Gemini API (via Spring WebClient)
  • Networking: Reactive WebClient for asynchronous API calls

๐Ÿ—๏ธ Core Architecture

1. Model (EmailRequest.java)

Defines the structure of incoming data from the frontend.

  • emailContent: The original email body to be replied to.
  • tone: The desired style for the response (e.g., Professional, Casual).

2. Service (EmailGeneratorService.java)

The core logic layer that communicates with Google's Generative Language API.

  • Prompt Engineering: It constructs a specialized prompt instructing the AI to generate a reply based on the provided email content and tone.
  • Response Parsing: It uses ObjectMapper to traverse the complex JSON response from Gemini and extract only the generated text.
  • API Configuration: Dynamically fetches the API Key and URL from environment properties.

3. Controller (EmailGeneratorController.java)

Exposes the REST endpoint for generation.

  • Endpoint: POST /api/email/generate.
  • CORS: Configured with @CrossOrigin to allow requests from the Chrome Extension and local development environments.

๐Ÿ“‹ API Specification

Generate Email Reply

Endpoint: POST http://localhost:8080/api/email/generate

Request Body:

{
    "emailContent": "Hi, are we still meeting today at 3 PM?",
    "tone": "professional"
}

Response:

"Subject: Re: Meeting Confirmation

Dear [Name],
Yes, we are still scheduled to meet today at 3 PM. I look forward to our discussion.
Best regards, [Your Name]"

๐Ÿš€ Getting Started

Prerequisites

  • JDK 17 or higher.
  • Maven installed.
  • A valid Google Gemini API Key.

Configuration

  1. Navigate to src/main/resources/application.properties.
  2. Set your API key:
gemini.api.key=YOUR_ACTUAL_API_KEY
gemini.api.url=https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent

Running the Application

  1. Clone the repository.
  2. Run the following command in the terminal:
mvn spring-boot:run

๐Ÿ–ผ๏ธ Working Images

1. Backend Startup

//To Do

2. Request Processing

//To Do

3. Successful Generation

//To Do

About

๐Ÿ“ง Spring Boot backend for Smart Email Writer. Integrates Google Gemini AI to generate context-aware, tone-specific email replies via a RESTful API. Designed for Chrome Extensions and Web Apps.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors