An advanced AI-powered investment analysis platform that leverages multi-agent workflows to perform comprehensive analysis of investment opportunities. This sample application demonstrates how to build sophisticated agentic AI systems using the Microsoft Agent Framework, Azure services, and modern web technologies.
This application provides an intelligent system for analyzing investment opportunities through automated document processing, multi-agent analysis workflows, and interactive "what-if" scenario planning. The system orchestrates specialized AI agents that collaborate to provide comprehensive investment insights from multiple perspectives: financial, risk, market, and compliance.
- Multi-Agent Investment Analysis: Orchestrates specialized AI agents (Financial Analyst, Risk Analyst, Market Analyst, Compliance Analyst) that work together to provide comprehensive investment analysis
- Document Intelligence: Automated processing and analysis of investment documents (financial statements, pitch decks, market research, etc.)
- Real-Time Streaming: Server-Sent Events (SSE) architecture for live streaming of agent progress and analysis results
- Interactive What-If Scenarios: Chat-based interface for exploring hypothetical scenarios and getting instant analysis
- Workflow Visualization: Visual representation of agent workflows and their execution status
- Investment Opportunity Management: Full CRUD operations for managing investment opportunities and their associated documents
A FastAPI-based REST API that serves as the orchestration layer for the AI agents and data management.
Core Technologies:
- FastAPI: Modern, high-performance web framework
- Microsoft Agent Framework: Powers the multi-agent workflow orchestration
- Azure Cosmos DB: NoSQL database for storing opportunities, analyses, and documents
- Azure Blob Storage: Document storage and retrieval
- Azure OpenAI: LLM provider for AI agent capabilities
Key Modules:
-
Workflow System (
app/workflow/):investment_workflow.py: Main investment analysis workflow orchestrating multiple specialized agentsinvestment_executors.py: Individual agent implementations (Financial, Risk, Market, Compliance analysts)prompts/: Agent-specific prompt templates for consistent analysis
-
What-If Chat System (
app/what_if_chat/):what_if_workflow.py: Interactive chat workflow for scenario explorationwhat_if_executors.py: Specialized agents for handling hypothetical scenarios
-
Services (
app/services/):analysis_workflow_executor_service.py: Manages workflow execution and event streamingdocument_processing_service.py: Handles multi-stage document processinganalysis_service.py: CRUD operations for investment analysesopportunity_service.py: Management of investment opportunities
-
API Routers (
app/routers/):analysis.py: Endpoints for starting/monitoring analyses with SSE streamingchat.py: Interactive chat interface for what-if scenariosopportunity.py: Investment opportunity management endpoints
-
Data Models (
app/models/):- Pydantic models for type-safe data handling
- Document, Opportunity, Analysis, User models
A modern React-based single-page application providing an intuitive user interface.
Core Technologies:
- React 18 with TypeScript
- Vite: Fast build tool and dev server
- Shadcn/ui: Beautiful, accessible UI component library
- Tailwind CSS: Utility-first CSS framework
- Lucide React: Icon library
Key Features:
- Dashboard for managing investment opportunities
- Document upload and processing interface
- Real-time analysis progress visualization with agent workflow diagrams
- Interactive chat interface for what-if scenarios
- Responsive design for desktop and mobile
Main Pages:
Index.tsx: Landing page with feature showcaseNewOpportunity.tsx/EditOpportunity.tsx: Opportunity managementProcessDocuments.tsx: Document upload and processingAnalysis.tsx: Analysis execution and visualization
The system uses a sophisticated multi-agent architecture:
Investment Analysis Workflow:
Data Preparation β [Financial Analyst, Risk Analyst, Market Analyst, Compliance Analyst]
β Analysis Aggregator β Investment Debate Executor β Summary Report Generator
Each agent:
- Has specialized knowledge and analysis focus
- Receives contextual prompts from prompt templates
- Processes in parallel where possible (fan-out pattern)
- Results are aggregated and synthesized
- Agents engage in a debate to challenge assumptions
- Final summary report is generated
What-If Chat Workflow:
Planning Agent β [Financial, Risk, Market, Compliance Agents] β Analysis Summarizer
- Interprets user questions and scenarios
- Routes to relevant specialist agents
- Synthesizes responses into coherent answers
- Maintains conversation context across turns
The application uses Server-Sent Events (SSE) for real-time updates:
- Event Queue System (
app/utils/sse_stream_event_queue.py): In-memory queue for managing events per analysis - Event Types: workflow_started, agent_started, agent_progress, agent_completed, workflow_completed
- Client Subscription: Frontend subscribes to
/api/analysis/{id}/eventsendpoint - Historical Events: New subscribers receive historical events before live updates
- Background Processing: Analysis runs in FastAPI background tasks while streaming events
- Python 3.11+ (3.13 recommended)
- Node.js 18+ and npm
- Azure Account with:
- Azure Cosmos DB instance
- Azure Blob Storage account
- Azure OpenAI service with a deployed chat model
- Environment Variables: See Configuration section below
Create a .env file in the api-app/ directory:
# API Server Settings
API_SERVER_HOST=0.0.0.0
API_SERVER_PORT=8084
API_SERVER_WORKERS=1
LOG_LEVEL=DEBUG
DEBUG=True
ENVIRONMENT=development
# Azure Cosmos DB
COSMOS_DB_ENDPOINT=https://<your-cosmos-account>.documents.azure.com:443/
COSMOS_DB_DATABASE_NAME=ai-investment-analysis-sample
# Azure Blob Storage
AZURE_STORAGE_ACCOUNT_NAME=your-storage-account
AZURE_STORAGE_CONTAINER_NAME=opportunity-documents
# Azure OpenAI
AZURE_OPENAI_ENDPOINT=https://<ai-foundry-resource>.cognitiveservices.azure.com/openai/deployments/<deployment_name>/chat/completions?api-version=2025-01-01-preview
AZURE_OPENAI_DEPLOYMENT_NAME=<model-deployment-name>
Create a .env file in the web-app/ directory:
VITE_API_BASE_URL=http://localhost:8084/api# Navigate to the api-app directory
cd api-app
# Create and activate a virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Ensure your .env file is configured (see Configuration section)
# Run the FastAPI server
python main.py
# The API will be available at http://localhost:8084
# API documentation at http://localhost:8084/docsAlternative: Run with uvicorn directly
uvicorn main:app --host 0.0.0.0 --port 8084 --reloadOpen a new terminal window:
# Navigate to the web-app directory
cd web-app
# Install dependencies
npm install
# Ensure your .env file is configured (see Configuration section)
# Start the development server
npm run dev
# The web app will be available at http://localhost:8080Cosmos DB:
-
Create a Cosmos DB account with NoSQL API
-
The application will automatically create the database and containers on first run
-
Ensure your connection endpoint is in the
.envfile -
Ensure proper access permissions on Cosmos DB account:
Follow the steps in this article: Connect to Azure Cosmos DB for NoSQL using role-based access control and Microsoft Entra ID
Blob Storage:
- Create a Storage Account
- Create a container named
opportunity-documents(or your chosen name) - Ensure proper access permissions (Storage Blob Data Contributor role)
Azure AI Foundry:
- Deploy an Azure AI Foundry resource - or connect directly to an existing one if available
- Deploy a chat model (e.g., GPT-4.1, GPT-4.1-mini)
- Note the endpoint and deployment name
- Ensure proper access permissions (Azure AI User role)
For local development with Azure services, authenticate using Azure CLI:
az loginThe application uses DefaultAzureCredential which supports:
- Azure CLI authentication (for local development)
- Managed Identity (for Azure deployments)
- Environment variables
- Interactive browser authentication
- Navigate to the home page
- Click "New Opportunity" or go to
/opportunity/new - Fill in the investment details:
- Company name
- Investment hypothesis
- Investment stage
- Industry
- Initial investment amount
- Description
- After creating an opportunity, upload relevant documents:
- Financial statements
- Pitch decks
- Market research
- Due diligence documents
- The system will automatically extract and analyze the content
- Monitor real-time processing progress
- From the opportunity detail page, click "Start Analysis"
- Watch as specialized AI agents analyze the opportunity:
- Data preparation and context loading
- Parallel analysis by Financial, Risk, Market, and Compliance agents
- Agent debate to challenge assumptions
- Final summary report generation
- View real-time progress and intermediate results via SSE streaming
- After analysis completes, use the chat interface
- Ask hypothetical questions like:
- "What if the market growth is 10% slower?"
- "How would a 20% increase in costs affect the ROI?"
- "What are the compliance risks if we expand to Europe?"
- Get instant analysis from relevant specialist agents
agentic-ai-investment-analysis-sample/
βββ api-app/ # Backend FastAPI application
β βββ main.py # Application entry point
β βββ requirements.txt # Python dependencies
β βββ run_investment_workflow.py # Workflow testing script
β βββ run_what_if_chat.py # Chat testing script
β βββ app/
β βββ core/ # Core configuration
β βββ database/ # Database clients and repositories
β βββ models/ # Pydantic data models
β βββ routers/ # FastAPI route handlers
β βββ services/ # Business logic layer
β βββ utils/ # Utility functions
β βββ workflow/ # Investment analysis workflow
β β βββ investment_workflow.py
β β βββ investment_executors.py
β β βββ investment_models.py
β β βββ prompts/ # Agent prompt templates
β βββ what_if_chat/ # What-if scenario workflow
β βββ what_if_workflow.py
β βββ what_if_executors.py
β
βββ web-app/ # Frontend React application
βββ package.json # Node dependencies
βββ vite.config.ts # Vite configuration
βββ tsconfig.json # TypeScript configuration
βββ tailwind.config.ts # Tailwind CSS configuration
βββ index.html # HTML entry point
βββ src/
βββ App.tsx # Main application component
βββ components/ # Reusable React components
β βββ AgentWorkflow.tsx # Workflow visualization
β βββ ChatInterface.tsx # What-if chat UI
β βββ ui/ # Shadcn/ui components
βββ pages/ # Page components
β βββ Index.tsx # Landing page
β βββ Analysis.tsx # Analysis page
β βββ NewOpportunity.tsx # Create opportunity
β βββ ProcessDocuments.tsx
βββ hooks/ # Custom React hooks
βββ lib/
βββ api/ # API client functions
Backend:
- FastAPI 0.116+
- Microsoft Agent Framework
- Azure Cosmos DB SDK
- Azure Blob Storage SDK
- Azure OpenAI SDK
- Pydantic 2.11+
- Uvicorn (ASGI server)
Frontend:
- React 18
- TypeScript
- Vite
- Shadcn/ui + Radix UI
- Tailwind CSS
- React Router
AI:
- Microsoft Agent Framework for multi-agent orchestration
- Azure OpenAI (GPT-4.1/GPT-5)
- Custom agent executors with specialized prompts
Infrastructure:
- Azure Cosmos DB (NoSQL)
- Azure Blob Storage
- Azure OpenAI Service
- Azure Entra ID (authentication)
Cosmos DB Connection Errors:
- Verify
COSMOS_DB_ENDPOINTis correct - Check Azure CLI authentication:
az login - Verify firewall rules allow your IP
- Ensure proper RBAC roles assigned
Agent Framework Import Errors:
- Ensure
agent-frameworkis installed:pip install agent-framework - Check Python version is 3.11+
OpenAI API Errors:
- Verify deployment name matches your Azure OpenAI deployment
- Check API quotas and rate limits
- Ensure proper authentication
API Connection Errors:
- Verify
VITE_API_BASE_URLpoints to correct backend URL - Check CORS settings in backend
.env - Ensure backend is running
This is a sample application designed to demonstrate agentic AI patterns. Feel free to fork and adapt for your use cases.
This sample code is provided as-is for demonstration purposes.
For issues and questions, please refer to the repository's issue tracker or documentation.