# Enterprise Outlook AI Assistant

This repository contains the source code for the Professional Microsoft Outlook COM/VSTO Add-in powered by AI.

## Architecture

*   **Desktop Integration:** VSTO COM (.NET Framework 4.8)
*   **UI:** WPF (Modern Dark/Light Mode)
*   **Backend:** FastAPI (Python) + Celery (Background Tasks)
*   **AI Orchestrator:** LangChain (Support for OpenAI, Azure, DeepSeek, Claude, Gemini, Groq, Ollama)
*   **Database:** PostgreSQL + `pgvector` for semantic search / memory
*   **Local Cache:** SQLite for offline AI fallback and draft recovery
*   **Auth:** JWT Authentication

## Folder Structure

*   `AddIn/`: Contains the C# VSTO Project (`.sln` and `.csproj`).
    *   `UI/`: WPF Task Pane components.
    *   `Services/`: C# HTTP Clients, SQLite Cache Managers, and Outlook COM Object wrappers.
*   `Backend/`: Contains the Python FastAPI Project.
    *   `services/`: LangChain orchestration logic.
    *   `db/`: SQLAlchemy and `pgvector` models.

## Deployment & Setup

### 1. Outlook VSTO Add-In

1.  Open `AddIn\OutlookAIAssistant.sln` in **Visual Studio 2022**.
2.  Ensure you have the "Office/SharePoint development" workload installed in Visual Studio.
3.  Right-click the `OutlookAIAssistant` project and select **Rebuild**.
4.  Press `F5` to build, register the COM Add-in locally, and launch Outlook automatically.
5.  *Installer:* To create an MSI installer, add a "Visual Studio Installer Project" to the solution and set its output to the primary output of the VSTO Add-In.

### 2. FastAPI Backend

1.  Navigate to the `Backend` folder.
2.  Create a virtual environment: `python -m venv venv`
3.  Activate the environment: `.\venv\Scripts\activate` (Windows)
4.  Install dependencies: `pip install -r requirements.txt`
5.  Start the API: `uvicorn main:app --reload`
6.  The Swagger UI will be available at `http://localhost:8000/docs`.

### 3. Local Offline AI (Ollama)

To use the Add-in completely offline:
1.  Install [Ollama](https://ollama.com/).
2.  Pull a local model: `ollama run llama3`
3.  The Add-in will automatically route requests to `http://localhost:11434` when `UseOfflineMode = true`.

## Future Proofing (Office.js)

While VSTO is used for deep desktop integration and `Redemption.dll` compatibility, the UI and API logic are fully decoupled via WPF and FastAPI. This allows for a future transition to Office.js Web Add-ins when Microsoft deprecates COM entirely.
