AWS Builder Center
InvestMate AI: Building a NSE Investment Research Agent on AWS

InvestMate AI: Building a NSE Investment Research Agent on AWS

Meet InvestMate AI, your AWS-powered NSE research companion. Explore market data, understand stock movements, and get beginner-friendly explanations with transparent sources and honest insights.

Sharing, Learning, Growing Together
The stock market can feel overwhelming when every chart, financial term, and market movement raises more questions than answers. I wanted to make investment research simpler for beginners, so I built InvestMate AI - an AI-powered investment research agent on AWS. It explains market data in plain English, separates verified facts from assumptions, and helps users discover what to research next. Because a great AI agent doesn't just provide answers - it helps people understand them with confidence.

What My Agent Does

Understanding the stock market can be overwhelming for beginners. Financial ratios, historical charts, company announcements, and unfamiliar terminology can make it difficult to understand what market movements actually mean.
That inspired me to build InvestMate AI, an AI-powered investment research companion for Indian retail investors who want to explore NSE-listed stocks and understand market information in simple language.
Instead of simply returning numbers, InvestMate AI takes a user's research question, selects an appropriate data tool, retrieves available evidence, and generates an explanation grounded in the returned results. The interface displays data sources, timestamps, and whether the information is live or demonstration data.
The goal is not to tell people which stocks to buy or sell. It is to help them understand available information and ask better research questions.
The application's signature feature is Beginner Mode: “Explain It Like I'm New to Investing.” Every answer is structured into three sections:
  • What the data shows: Available facts, numbers, and historical observations.
  • What it might mean: Possible interpretations, clearly distinguished from confirmed facts.
  • What to research next: A useful follow-up question or direction for further investigation.
This makes the experience more approachable without sacrificing transparency.

Architecture

Technology Stack

I chose a serverless AWS architecture to keep the application manageable, scalable, and cost-conscious.
ComponentTechnologyPurpose
FrontendReact, TypeScript, ViteInteractive web application
UI and chartsTailwind CSS, RechartsResponsive interface and market visualizations
Frontend hostingAmazon S3, Amazon CloudFrontStatic hosting and HTTPS delivery
APIAmazon API GatewayReceives frontend requests
BackendAWS Lambda, PythonAgent orchestration and business logic
AI modelAmazon Bedrock, Nova LiteTool selection and natural-language explanations
DatabaseAmazon DynamoDBWatchlists and user preferences
Infrastructure as codeAWS SAMResource definitions and deployment
MonitoringAmazon CloudWatchOperational logs
SecurityAWS IAMScoped permissions for AWS resources
Market-data integrationOfficial NSE MCP endpointsIntended access to supported market-data tools
The backend coordinates the AI model and available tools. The model can select an appropriate tool, while the backend executes the operation and returns the retrieved evidence to the model for its final response.
The application was deployed in the AWS Mumbai Region (ap-south-1). Nova Lite invocation uses the APAC inference profile apac.amazon.nova-lite-v1:0.

How I Built It

I started by building the React frontend and Python backend, then connected the frontend to API Gateway and Lambda. Amazon Bedrock provides the AI capabilities, while DynamoDB supports saved watchlists and preferences.
I used AWS SAM to define the serverless infrastructure and least-privilege IAM permissions. CloudWatch supports operational logging, and API Gateway throttling helps control request volume.
The development process focused on one complete journey: a user asks a stock research question, the backend selects a suitable tool, the agent processes the available evidence, and the frontend displays a clear explanation with source and timestamp information.
The application also includes a portfolio risk explorer, historical charts where data is available, connection-health information, and graceful loading and error states.

Troubleshooting and Coding Lessons

Challenge 1: Amazon Bedrock model invocation in Mumbai

During deployment, I discovered that Nova Lite could not be invoked on-demand using its raw model ID in the Mumbai Region.
The solution was to use the cross-region inference profile apac.amazon.nova-lite-v1:0 and configure the IAM permissions for the inference profile and underlying foundation models.
This taught me to distinguish between a model being listed in a region and having the correct invocation configuration and permissions.

Challenge 2: Official NSE MCP connection timeouts

I investigated the official NSE MCP endpoints:
  • NSE CM Market: https://mcp.nseindia.in/cmmkt/mcp
  • NSE Bhavcopy: https://mcp.nseindia.in/bhavcopy/cm/mcp
I tested connectivity using curl, httpx, and the official MCP Python SDK. My headless server-side requests repeatedly timed out with a 504 Gateway Time-out response.
Rather than invent live market information, I implemented an MCP Streamable HTTP client with tool discovery, timeouts, bounded retries, and connection cleanup. I also implemented a deterministic sample-data provider that clearly labels its results as demonstration data.
The deployed application therefore remains usable without pretending that the official NSE endpoints are returning live data through Lambda. The integration still requires a compatible, permitted connection path before live NSE data can be claimed.

Challenge 3: Preventing misleading AI responses

An AI-generated explanation is only as reliable as the evidence available to it.
I designed the agent to distinguish retrieved facts from interpretations and to handle missing data explicitly. Historical volatility is withheld when there are insufficient observations, and failures preserve the user's question so it can be retried.
I tested these behaviours with 36 automated tests: 31 backend tests and five frontend tests. Coverage includes tool selection, invalid symbols, error handling, protection against fabricated results, historical date retention, and sample-data labelling.

The Experience: Explain It Like I'm New to Investing

The feature I focused on most was making financial research approachable.
Beginner Mode structures explanations into three simple sections: what the data shows, what it might mean, and what to research next.
For example, when a user asks why a stock fell, the agent should investigate the available evidence rather than immediately inventing a reason. It explains the observed movement and distinguishes confirmed information from possible explanations.
The interface also provides loading skeletons, empty states, error messages, retry controls, source information, and data freshness indicators.
If a model or data service fails, the application explains the problem and preserves the user's question. It does not silently replace failed live-data requests with sample prices.
I validated these behaviours through automated tests and deployment checks. This reflects my central design principle: an enjoyable agent should not just produce a polished answer; it should also be honest about what it cannot verify.

Coding Reference and Project Repository

The complete project source code, deployment instructions, infrastructure definition, and tests are available in my public GitHub repository.
Useful implementation references in the project include:
  • AWS SAM template: Serverless resource definitions and permissions.
  • Backend implementation: Agent orchestration, API handlers, and data-provider integration.
  • Frontend implementation: Dashboard, research chat, charts, and connection-health interface.
  • Automated tests: Backend and frontend behaviour verification.
  • Deployment guide: Setup, AWS deployment, verification, and cleanup.
  • Architecture diagrams and screenshots: Application architecture and deployed interface.
These references help readers understand how the application is structured and reproduce the development workflow.

Proof It Works

InvestMate AI is deployed on AWS.
During deployment verification, the frontend returned successfully over HTTPS, the API CORS preflight succeeded, and the single-page application routing fallback worked.
A research request for TCS returned a Beginner Mode answer whose reported metrics matched the accompanying evidence. The response also included isSample: true and source timestamps, clearly identifying the demonstration data.
The application is deployed and its core workflow has been tested. However, the official NSE MCP endpoints are not currently supplying live market data through the deployed Lambda environment. I have kept this limitation visible rather than claiming an integration that has not succeeded.

Deployment (reference)

Prerequisites

  • AWS CLI v2, AWS SAM CLI, Node.js 18+, Python 3.13.
  • AWS credentials with permission to deploy CloudFormation, Lambda, API Gateway, DynamoDB, IAM, S3, CloudFront, and to invoke Amazon Bedrock.
  • Amazon Bedrock model access for Nova Lite in your target region.

Deploy the backend (SAM)

1
2
3
4
5
6
7
8
9
cd backend
sam build --manifest requirements-lambda.txt
sam deploy \
--stack-name investmate-ai \
--region ap-south-1 \
--resolve-s3 \
--capabilities CAPABILITY_IAM \
--no-confirm-changeset \
--parameter-overrides "BedrockModelId=apac.amazon.nova-lite-v1:0 NseMcpEnabled=false"

Deploy the frontend (S3 + CloudFront)

1
2
3
4
5
6
7
8
9
cd frontend
# Point the build at your deployed API:
echo "VITE_API_BASE_URL=<ApiBaseUrl>" > .env.production
npm run build

# Create a private bucket and upload the build:
aws s3api create-bucket --bucket <your-bucket> --region ap-south-1 \
--create-bucket-configuration LocationConstraint=ap-south-1
aws s3 sync dist s3://<your-bucket> --delete

Operations and security notes

  • IAM is least-privilege: Lambda may invoke only the Nova foundation models and inference profiles, and read/write only the one DynamoDB table.
  • Health and integration endpoints return sanitized data (host only, no URLs or secrets, no stack traces).
  • API Gateway stage throttling is set to 10 rps / burst 20.
  • CloudWatch logs are emitted by Lambda and API Gateway.

The NSE MCP integration

The official NSE MCP endpoints (cm-market, nse-bhavcopy, transport streamable-http, no auth) sit behind Akamai bot management and respond only to interactive browser/desktop clients (Claude Desktop, Claude.ai, ChatGPT). A headless Lambda receives 504 Gateway Time-out. This was verified during development with curl, httpx, and the official MCP Python SDK.

 Teardown (remove all billable resources)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Backend stack
sam delete --stack-name investmate-ai --region ap-south-1

# Frontend: disable then delete the CloudFront distribution
# (fetch ETag, set Enabled=false via update-distribution, wait Deployed, then:)
aws cloudfront delete-distribution --id <distribution-id> --if-match <etag>

# Delete the Origin Access Control
aws cloudfront delete-origin-access-control --id <oac-id> --if-match <etag>

# Empty and remove the bucket
aws s3 rb s3://<your-bucket> --force

# Remove the budget
aws budgets delete-budget --account-id <account-id> --budget-name investmate-ai-monthly

Cost

All resources are serverless and pay-per-use (Lambda, API Gateway, DynamoDB on-demand, Bedrock per token, CloudFront per request). There are no always-on components, so idle cost is effectively zero. A $5/month AWS Budget named investmate-ai-monthly was created for visibility.

Conclusion

Building InvestMate AI reinforced an important lesson: an AI agent needs more than a language model connected to an API. It needs reliable tools, verifiable evidence, thoughtful error handling, and an experience designed around real people.
Amazon Bedrock provides the AI capabilities, AWS serverless services provide the application infrastructure, and the agent workflow connects the two. AWS SAM also helped me define and deploy the application through infrastructure as code.
The biggest lesson was that reliability includes knowing when not to answer. When data is missing or a service is unavailable, an honest explanation is more valuable than a confident but unsupported response.
I built InvestMate AI to make stock research more approachable for Indian retail investors while helping them distinguish facts from interpretations.
For me, that is what makes an agent enjoyable to use: it helps people understand what is known, what remains uncertain, and what they can investigate next.
InvestMate AI is for educational purposes only and does not provide personalized investment advice.
Thank you for taking the time to read my article! If you found it helpful, feel free to like, share, and drop your thoughts in the comments; I’d love to hear from you.
If you want to connect or dive deeper into cloud, AI and DevOps, feel free to follow me on my socials:
👨‍💻 DEV Community  
🛡️Medium  
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article