Skip to content

Commit a6f2ea9

Browse files
committed
Finalised Projects
1 parent 6395f10 commit a6f2ea9

File tree

18 files changed

+406
-61
lines changed

18 files changed

+406
-61
lines changed

.github/workflows/backend-cd.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: cd
2+
on:
3+
push:
4+
paths:
5+
- 'backend/**'
6+
branches:
7+
- main
8+
jobs:
9+
deploy:
10+
name: deploy
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v2
16+
17+
- id: 'auth'
18+
uses: 'google-github-actions/auth@v2'
19+
with:
20+
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
21+
22+
- name: 'Set up Cloud SDK'
23+
uses: 'google-github-actions/setup-gcloud@v2'
24+
25+
- name: 'Build and Deploy Image To Artifact Registry'
26+
run: |
27+
cd backend
28+
gcloud builds submit --tag asia-northeast1-docker.pkg.dev/my-backends-459605/noirvest-backend-repo/noirvest-backend:latest
29+
30+
- name: Deploy to Cloud Run
31+
run: gcloud run deploy noirvest-backend --image asia-northeast1-docker.pkg.dev/my-backends-459605/noirvest-backend-repo/noirvest-backend:latest --region asia-northeast1 --allow-unauthenticated --project my-backends-459605 --max-instances=4 --set-secrets=GOOGLE_API_KEY=NOIRVEST_GEMINI_KEY:latest,FINANCIAL_PREP_API_KEY=NOIRVEST_FINANCIAL_API_KEY:latest --set-env-vars=GOOGLE_GENAI_USE_VERTEXAI=FALSE

Pipfile

Lines changed: 0 additions & 11 deletions
This file was deleted.

README.md

Lines changed: 187 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,187 @@
1-
# NoirVest
2-
Making investing Easy
1+
# NoirVest - AI-Powered Investment Assistant
2+
3+
[![Python](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
4+
[![Next.js](https://img.shields.io/badge/Next.js-13+-black.svg)](https://nextjs.org/)
5+
[![FastAPI](https://img.shields.io/badge/FastAPI-0.100+-green.svg)](https://fastapi.tiangolo.com/)
6+
7+
NoirVest is an intelligent investment platform that leverages AI to simplify and enhance your investment journey. Whether you're a seasoned investor or just getting started, NoirVest provides personalized investment recommendations, market analysis, and portfolio management tools powered by advanced AI agents.
8+
9+
I had the idea to build this because I recently earned some money and was like "I should invest this money", but I am lazy and didn't want to do research so I build this app instead.
10+
11+
## 🚀 Features
12+
13+
- **AI-Powered Investment Analysis**: Get real-time market insights and analysis using advanced AI models
14+
- **Personalized Portfolio Recommendations**: Receive tailored investment suggestions based on your risk profile and financial goals
15+
- **Multi-Agent System**: Utilizes specialized AI agents for different aspects of investment management
16+
- **Interactive Dashboards**: Visualize your portfolio performance and market trends with beautiful, interactive charts
17+
- **Real-time Market Data**: Stay updated with the latest market information and price movements
18+
19+
## 🛠️ Tech Stack
20+
21+
### Frontend
22+
- **Next.js 13+** - React framework for building the user interface
23+
- **TypeScript** - Type-safe JavaScript for better developer experience
24+
- **Radix UI** - Accessible, unstyled UI components
25+
- **Tailwind CSS** - Utility-first CSS framework for styling
26+
- **Chart.js** - Interactive data visualization
27+
- **Next Themes** - For dark/light mode support
28+
29+
### Backend
30+
- **Python 3.9+** - Core programming language
31+
- **FastAPI** - Modern, fast web framework for building APIs
32+
- **Google Cloud AI** - For advanced AI/ML capabilities
33+
- **Google Gemini** - AI models for natural language understanding and generation
34+
- **Google Cloud Services** - For storage, logging, and deployment
35+
- **Uvicorn** - ASGI server for running FastAPI applications
36+
37+
### Infrastructure
38+
- **Docker** - Containerization for consistent development and deployment
39+
- **Google Cloud Platform** - Hosting and cloud services
40+
- **Firebase** - Authentication and real-time database (if applicable)
41+
42+
## 🏗️ Project Structure
43+
44+
```
45+
NoirVest/
46+
├── backend/ # Backend services
47+
│ ├── investment_agent/ # AI investment agent implementation
48+
│ │ ├── agent.py # Main agent definitions
49+
│ │ ├── helper_tool.py # Helper functions and tools
50+
│ │ └── instructions/ # Agent instructions and prompts
51+
│ ├── main.py # FastAPI application entry point
52+
│ ├── requirements.txt # Python dependencies
53+
│ └── Dockerfile # Container configuration
54+
55+
├── frontend/ # Frontend application
56+
│ ├── components/ # Reusable UI components
57+
│ ├── pages/ # Next.js pages
58+
│ ├── public/ # Static assets
59+
│ ├── styles/ # Global styles
60+
│ ├── package.json # Frontend dependencies
61+
│ └── next.config.js # Next.js configuration
62+
63+
└── README.md # Project documentation (you are here)
64+
```
65+
66+
## 🚀 Getting Started
67+
68+
### Prerequisites
69+
70+
- Python 3.9 or higher
71+
- Node.js 18+ and npm/yarn
72+
- Google Cloud SDK (for deployment)
73+
- Docker (optional, for containerized development)
74+
75+
### Local Development
76+
77+
1. **Clone the repository**
78+
```bash
79+
git clone https://github.com/yourusername/NoirVest.git
80+
cd NoirVest
81+
```
82+
83+
2. **Set up the backend**
84+
```bash
85+
cd backend
86+
python -m venv venv
87+
source venv/bin/activate # On Windows: .\venv\Scripts\activate
88+
pip install -r requirements.txt
89+
```
90+
91+
3. **Set up the frontend**
92+
```bash
93+
cd ../frontend
94+
npm install
95+
```
96+
97+
4. **Configure environment variables**
98+
99+
Create `.env` files in both the backend and frontend directories with the required environment variables.
100+
101+
**Frontend (`.env.local`):**
102+
```env
103+
# Firebase Configuration
104+
NEXT_PUBLIC_FIREBASE_APP_ID=your_firebase_app_id
105+
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_messaging_sender_id
106+
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your_storage_bucket
107+
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_id
108+
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_auth_domain
109+
NEXT_PUBLIC_FIREBASE_API_KEY=your_firebase_api_key
110+
111+
# API Configuration
112+
NEXT_PUBLIC_AGENT_API_URL=your_backend_api_url
113+
```
114+
115+
**Backend (`.env` in the backend directory):**
116+
```env
117+
# Google Cloud & AI Configuration
118+
GOOGLE_GENAI_USE_VERTEXAI=false
119+
GOOGLE_API_KEY=your_google_api_key
120+
121+
# Financial Data API
122+
FINANCIAL_PREP_API_KEY=your_financial_prep_api_key
123+
124+
# Server Configuration
125+
PORT=8000
126+
DEBUG=true
127+
```
128+
129+
> **Note**: Replace all placeholder values with your actual configuration. Never commit the actual `.env` files to version control.
130+
131+
5. **Run the development servers**
132+
- Backend:
133+
```bash
134+
cd backend
135+
uvicorn main:app --reload
136+
```
137+
- Frontend:
138+
```bash
139+
cd frontend
140+
npm run dev
141+
```
142+
143+
6. **Access the application**
144+
- Frontend: http://localhost:3000
145+
- API Docs: http://localhost:8000/docs
146+
147+
## 🤖 AI Agents Overview
148+
149+
NoirVest utilizes a multi-agent system where each agent specializes in a specific aspect of investment management:
150+
151+
1. **Planner Agent**: Develops the overall investment strategy
152+
2. **Asset Selector**: Identifies promising investment opportunities
153+
3. **Market Analyzer**: Analyzes market conditions and trends
154+
4. **Portfolio Recommender**: Suggests optimal portfolio allocations
155+
5. **Explainer Agent**: Provides clear explanations of investment concepts
156+
6. **Graph Generator**: Creates visual representations of data and trends
157+
158+
## 🌟 Why NoirVest?
159+
160+
- **Democratizing Investment**: Makes sophisticated investment strategies accessible to everyone
161+
- **Data-Driven Decisions**: Leverages real-time market data and AI analysis
162+
- **Transparent**: Clear explanations for all recommendations
163+
- **Customizable**: Adapts to your unique financial situation and goals
164+
- **Secure**: Built with security best practices in mind
165+
166+
## 📄 License
167+
168+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
169+
170+
## 🙏 Acknowledgments
171+
172+
- Built with ❤️ using cutting-edge AI and web technologies
173+
- Special thanks to the open-source community for their invaluable contributions
174+
175+
## 🤝 Contributing
176+
177+
Contributions are welcome! Please read our [contributing guidelines](CONTRIBUTING.md) to get started.
178+
179+
## 📧 Contact
180+
181+
For any inquiries or support, please contact [[email protected]](mailto:[email protected]).
182+
183+
---
184+
185+
<div align="center">
186+
Made with 💙 by Sparsh Jain
187+
</div>

backend/Dockerfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
FROM python:3.13-alpine AS builder
2+
3+
# Install build dependencies only in builder
4+
RUN apk add --no-cache \
5+
build-base \
6+
libffi-dev \
7+
musl-dev \
8+
gcc \
9+
python3-dev \
10+
linux-headers
11+
12+
WORKDIR /app
13+
14+
COPY requirements.txt .
15+
16+
# Install dependencies in a virtual environment
17+
RUN python -m venv /opt/venv && \
18+
/opt/venv/bin/pip install --no-cache-dir --upgrade pip && \
19+
/opt/venv/bin/pip install --no-cache-dir -r requirements.txt
20+
21+
# ---- Final image ----
22+
FROM python:3.13-alpine
23+
24+
# Install runtime dependencies only (no build tools)
25+
RUN apk add --no-cache libffi
26+
27+
# Create user
28+
RUN adduser -D myuser
29+
30+
WORKDIR /app
31+
32+
COPY --from=builder /opt/venv /opt/venv
33+
COPY . .
34+
35+
# Set permissions
36+
RUN chown -R myuser:myuser /app
37+
38+
USER myuser
39+
40+
ENV PATH="/opt/venv/bin:$PATH"
41+
42+
EXPOSE 8000
43+
44+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
GOOGLE_GENAI_USE_VERTEXAI=FALSE
2+
GOOGLE_API_KEY=YOUR_GOOGLE_API_KEY
3+
4+
FINANCIAL_PREP_API_KEY=YOUR_FINANCIAL_PREP_API_KEY
-214 Bytes
Binary file not shown.
-2.45 KB
Binary file not shown.
-5.61 KB
Binary file not shown.
-7.94 KB
Binary file not shown.

backend/investment_agent/helper_tool.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1+
import os
2+
from typing import Dict, List, Union
13
import requests
4+
from dotenv import load_dotenv
5+
6+
# Load environment variables from .env file
7+
load_dotenv()
8+
9+
# Get API key from environment variables
10+
FINANCIAL_PREP_API_KEY = os.getenv('FINANCIAL_PREP_API_KEY')
11+
if not FINANCIAL_PREP_API_KEY:
12+
raise ValueError("FINANCIAL_PREP_API_KEY not found in environment variables")
213

314
def get_stock_sentiment(ticker: str) -> dict:
415
"""
@@ -34,8 +45,7 @@ def get_stock_sentiment(ticker: str) -> dict:
3445
}
3546
"""
3647

37-
api_key = "WVfrB6TsRBPL0Xq3ejhdfEpTWLlfT7iN"
38-
url = f"https://financialmodelingprep.com/stable/grades-consensus?symbol={ticker}&apikey={api_key}"
48+
url = f"https://financialmodelingprep.com/stable/grades-consensus?symbol={ticker}&apikey={FINANCIAL_PREP_API_KEY}"
3949
try:
4050
response = requests.get(url)
4151
response.raise_for_status() # Raise an exception for bad status codes
@@ -49,7 +59,7 @@ def get_stock_sentiment(ticker: str) -> dict:
4959
return {"error": f"Failed to parse JSON response: {str(e)}"}
5060

5161

52-
def get_market_data_for_assets(tickers: list[str]) -> dict:
62+
def get_market_data_for_assets(tickers: List[str]) -> Dict[str, Dict[str, List[Dict]]]:
5363
"""
5464
Fetches comprehensive financial data for one or more stock tickers from the Financial Modeling Prep API.
5565
@@ -105,8 +115,7 @@ def get_market_data_for_assets(tickers: list[str]) -> dict:
105115
"cash-flow-statement", "shares-float", "market-capitalization", "earnings", "enterprise-value",
106116
"quote", "owners-earning", "income-statement-growth", "balance-sheet-statement-growth",
107117
"cash-flow-statement-growth", "financial-scores-growth","analyst-estimates"]
108-
api_key = "WVfrB6TsRBPL0Xq3ejhdfEpTWLlfT7iN"
109-
118+
api_key = FINANCIAL_PREP_API_KEY
110119
data = {}
111120

112121
for ticker in tickers:

0 commit comments

Comments
 (0)