Imported from Tayne78/finsight-agent (
AGENTS.md). Install upstream withnpx skills add Tayne78/finsight-agent. Copyright stays with the author.
AGENTS.md
This file is for AI coding agents working in this repository. Read this first and keep context usage low by following the entry points below.
Mission
Build and evolve a reliable FastAPI backend for FinSight Agent:
- accept a company name and ticker from a frontend
- collect market data and recent news
- coordinate specialist research agents and a supervisor agent with Amazon Bedrock
- return JSON and PDF outputs
First Files To Read
Only read these files first unless the task requires more:
README.mdbackend/app/main.pybackend/app/schemas/analysis.pybackend/app/agents/orchestrator.pyfrontend/src/api/finsight.jsif the task touches frontend/backend integration- the specific file you need to change
Do not load the whole repo by default.
Local Dev Entry Points
Use these scripts instead of retyping setup commands:
./scripts/dev_setup.sh./scripts/dev_backend.sh./scripts/dev_frontend.sh
Port overrides:
PORT=8010 ./scripts/dev_backend.shFRONTEND_PORT=5174 ./scripts/dev_frontend.sh
Architectural Boundaries
Keep these boundaries stable:
backend/app/main.pyRoute registration and HTTP concerns only.backend/app/schemas/Pydantic input/output contracts.backend/app/agents/Orchestration and report assembly flow. Specialist agents run in parallel via ThreadPoolExecutor.backend/app/tools/Data fetching from external sources such as finance APIs or search.backend/app/services/Provider integrations and rendering, such as Bedrock and PDF generation.
Do not mix these concerns unless there is a clear refactor plan.
Current Flow
/analyze and /analyze/pdf call app.agents.orchestrator.run_analysis().
run_analysis() currently:
- collects metrics from
app.tools.finance_tools - collects headlines from
app.tools.search_tools - runs 4 specialist agents (news, fundamentals, risk, comparison) in parallel via
ThreadPoolExecutor - sends their outputs to the supervisor agent
- returns a normalized report dictionary
/analyze/pdf additionally passes that dictionary to services.pdf_service.
Rules For New Work
- Keep route handlers thin.
- When adding response fields, update
backend/app/schemas/analysis.pyfirst. - When adding a new data source, place the fetch logic in
backend/app/tools/or a dedicatedbackend/app/services/module. - When Bedrock prompt logic becomes large, move prompts into dedicated constants or a
prompts/package. - Prefer additive changes over broad rewrites during the hackathon window.
- Preserve backward compatibility for
/analyzeunless the API contract is intentionally changed.
Preferred Growth Path
Add modules in this order when complexity increases:
backend/app/services/analysis_service.pybackend/tests/backend/app/prompts/frontend/src/pages/
Only add these once the current multi-agent scaffold becomes a real bottleneck.
Bedrock Implementation Notes
- Bedrock access is environment-driven through
backend/app/config.pywhich loadsbackend/.env. - Validate credentials and model access before changing prompts.
- If a model call fails, inspect region, model ID, and access permissions first.
- Keep prompt outputs machine-parseable.
PDF Output Rules
- PDF generation must remain deterministic from the analysis result dictionary.
- Do not let PDF code fetch data or call Bedrock.
- Keep presentation logic in
backend/app/services/pdf_service.py.
Frontend Contract
The frontend should only need:
GET /healthPOST /analyzePOST /analyze/pdf
Avoid forcing frontend changes unless necessary for product value.
Hackathon Constraints
Optimize for:
- reliable end-to-end demo flow
- clear Amazon Nova usage
- visible specialist-agent collaboration
- clean architecture judges can understand quickly
Avoid:
- unnecessary infra complexity
- premature microservices
- large refactors close to demo time
If You Need More Structure
Use this decision rule:
- new HTTP shape ->
backend/app/schemas/ - new report assembly logic ->
backend/app/agents/ - new external fetcher ->
backend/app/tools/ - new provider or renderer ->
backend/app/services/
If a change does not fit one of these buckets, document why before introducing a new top-level directory.