Skip to content

dev-08/MailCraft-AI

Repository files navigation

PromptMail

Overview

PromptMail is an AI-powered smart email generation platform built as a distributed .NET Aspire application. The project is designed to show how a modern cloud-style application can combine a frontend, backend services, service orchestration, and OpenAI-based text generation into one connected system.

Instead of being built as a single monolithic application, PromptMail is structured as a small distributed system. Each project in the solution has a specific responsibility, and Aspire coordinates how those parts run together.

The core idea is simple: a user enters email details such as subject, purpose, audience, tone, and call to action through the web interface, and the backend uses prompt engineering plus OpenAI to generate a polished email draft.


Project Purpose

The goal of PromptMail is to demonstrate practical prompt engineering inside a real software system.

This project is not only about generating email text. It is also about showing how AI can be integrated into a distributed application architecture using:

  • a web frontend for user interaction
  • an API service for business logic
  • shared service defaults for observability and reliability
  • an app host for orchestration
  • OpenAI for intelligent content generation

This makes the project a strong portfolio example because it connects AI concepts with system design and modern backend architecture.


High-Level Architecture

PromptMail contains four main projects:

  • PromptEngineering_Web
  • PromptEngineering_ApiService
  • PromptEngineering_AppHost
  • PromptEngineering_ServiceDefaults

These projects work together like a small distributed application.

1. PromptEngineering_Web

This is the user-facing frontend built with Blazor.

Its job is to:

  • display the input form
  • collect subject, purpose, tone, audience, role, and call to action
  • send the request to the backend API service
  • display the generated email result to the user

The web project is the entry point for the user, but it does not directly contain the AI logic. It acts as the presentation layer.

2. PromptEngineering_ApiService

This is the backend service that handles the application logic.

Its job is to:

  • receive requests from the web frontend
  • build the prompt template
  • apply role-based and instruction-based prompting
  • call the OpenAI API
  • receive the generated response
  • return the formatted email result back to the frontend

This project is the intelligence layer of the system. It connects user input with OpenAI and transforms simple form data into a structured AI prompt.

3. PromptEngineering_AppHost

This is the orchestration layer provided by .NET Aspire.

Its job is to:

  • start all services together
  • connect the web project with the API service
  • manage environment variables and secrets
  • provide a single place to run the distributed system
  • coordinate service discovery between projects

The AppHost makes the solution feel like one connected application even though it is split into multiple projects.

4. PromptEngineering_ServiceDefaults

This project provides shared infrastructure settings across the distributed system.

Its job is to:

  • apply common service defaults
  • support health checks
  • support observability and diagnostics
  • provide shared configuration patterns for services

This keeps the solution consistent and easier to maintain as the system grows.


How the Projects Connect to Each Other

The projects are connected in a layered flow.

Step 1: User interacts with the Web project

A user opens the PromptMail page in the Blazor frontend and fills in the email generation form.

Step 2: Web sends the request to the API service

The frontend sends the email request to the API service through the distributed service connection managed by Aspire.

Step 3: API service prepares the AI prompt

The API service takes the raw input and transforms it into a structured prompt. This includes:

  • system instruction or role prompt
  • user content prompt
  • template-based formatting
  • prompt engineering rules such as tone, audience, and output style

Step 4: API service calls OpenAI

The API service sends the final prompt to OpenAI using the configured API key.

Step 5: OpenAI generates the response

OpenAI returns generated text based on the instructions and user input.

Step 6: API service returns the result

The API service packages the generated content into a response object and sends it back to the frontend.

Step 7: Web displays the generated email

The user sees the generated email draft, suggested subject, and any additional rewritten output on the page.

This is the full distributed request flow across the system.


Why This Is a Distributed System

PromptMail is a small distributed system because the responsibilities are separated across multiple services and coordinated through Aspire.

Instead of putting everything into one project, the solution splits concerns into:

  • frontend user experience
  • backend business logic
  • orchestration and environment management
  • shared cross-cutting infrastructure

This separation provides several benefits:

  • easier maintenance
  • cleaner architecture
  • clearer ownership of responsibilities
  • better scalability for future growth
  • more realistic cloud-native design

Even though the project is simple in functionality, the architecture reflects the same design style used in larger modern applications.


How OpenAI Fits Into the System

OpenAI is used as the intelligence engine inside the API service.

The frontend does not talk directly to OpenAI. Instead, the backend acts as the secure middle layer.

This design is important because:

  • the API key stays on the server side
  • business logic remains controlled in one place
  • prompt templates can be managed centrally
  • the frontend stays simple and focused on user experience

The OpenAI integration is responsible for:

  • understanding the user’s email request
  • following prompt instructions
  • generating polished email content
  • adapting to tone, role, and purpose

This makes the AI integration secure, flexible, and production-friendly.


Prompt Engineering in the Project

PromptMail is also a prompt engineering project, not just a UI project.

The backend uses prompt engineering concepts such as:

  • instruction prompting
  • role prompting
  • template-based prompts
  • structured output requests
  • iterative refinement for future versions

This means the project demonstrates how prompt engineering can be embedded inside a backend service rather than being used manually in a chat interface.

That is one of the strongest aspects of the application.


Example Functional Flow

A typical usage flow looks like this:

  1. The user enters a subject such as a meeting request.
  2. The user selects a tone such as professional or friendly.
  3. The user provides the purpose and call to action.
  4. The frontend submits the form to the API service.
  5. The API service creates a structured prompt.
  6. OpenAI generates the final email.
  7. The result is sent back and shown in the UI.

This makes the system easy to understand while still showing real distributed communication.


Role of Aspire in the Project

Aspire is the glue that holds the distributed system together.

It helps the project by:

  • running multiple services together
  • simplifying service-to-service communication
  • making environment setup easier
  • centralizing secret handling and orchestration
  • improving the developer experience for distributed applications

Without Aspire, each project would still work, but the integration and orchestration would require more manual setup.


Security and API Key Handling

The OpenAI API key should be kept outside the frontend and outside hardcoded source files.

The secure approach is:

  • keep the key in a secret store or user secrets during development
  • let the AppHost pass it to the API service through environment configuration
  • ensure only the API service can use it

This is important because the frontend should never expose secret credentials.


Why This Project Is Strong for Portfolio Use

PromptMail is a strong project because it demonstrates both application engineering and AI integration.

It shows:

  • distributed application design with Aspire
  • frontend and backend separation
  • secure service-to-service communication
  • OpenAI integration in a backend service
  • practical prompt engineering
  • reusable architecture for future AI features

This makes it more valuable than a simple single-page demo.


Possible Future Expansion

The project can grow naturally into a more advanced AI writing platform.

Possible next steps include:

  • multiple email templates
  • role-based email generation
  • rewrite and refine actions
  • history of generated emails
  • saved drafts
  • database support
  • analytics and usage tracking
  • template management for admins

This means the current system can act as version 1 of a broader AI productivity product.


Final Summary

PromptMail is an AI-powered email generation platform built as a distributed .NET Aspire application. The Blazor frontend collects user input, the API service applies prompt engineering and communicates with OpenAI, the AppHost orchestrates the distributed services, and ServiceDefaults provides shared infrastructure behavior.

Together, these parts create a clean example of how distributed systems and AI services can be combined into one modern application.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors