How shivanshsinghal107/investment-portfolio works
Project Type and Purpose
• This is a full-stack web application built with Flask, focused on student investment portfolio optimization.
• Purpose: let users (students/low-income) register/login, input holdings, run three portfolio-optimization algorithms (Markowitz, Minimum Variance, Sharpe Ratio via Monte Carlo), view results and track investments with live stats.
File Structure
• Top-level files:
• app.py – Flask application entrypoint and route definitions (controllers).
• data.py – core business logic module (data access, optimization algorithms).
• Procfile – deployment instructions for Heroku.
• requirements.txt – Python dependencies.
• stock data.csv – local sample dataset.
• Directories:
• templates/ – Jinja2 HTML templates (views).
• static/ – Bootstrap CSS, JS, video demos, images.
• No separate “services” or microservices – it’s a monolithic Flask app.
README
• Confirms tech stack: Flask (Python), Bootstrap, PostgreSQL.
• Describes features: registration/login, tracking, optimization, live stats.
• Mentions three in-house optimization techniques.
Main Components
a. Client Layer
– Web browser (renders HTML/CSS/JS)
b. Web Server Layer (Flask monolith)
– Routing & Controllers (app.py)
– Business Logic / Optimization Engine (data.py)
– Template Renderer (Jinja2)
– Static File Server (videos, CSS, JS)
c. Persistence Layer
– PostgreSQL database (user profiles, investment history, optimization results)
– Local CSV store for offline data
d. External Services
– Live Stock Data API (for up-to-date quotes)
e. Deployment Platform
– Heroku (Procfile)
Component Interactions & Data Flow
• User → HTTP(s) → Flask routes
• Flask controllers call:
• data.py to fetch/process data & run optimization
• SQLAlchemy/psycopg2 to query/update PostgreSQL
• External API client to fetch live stock prices
• Flask → Jinja2 → rendered HTML → User
• Flask → Static files (CSS/JS/Video) → User
• Async or synchronous calls between layers are all handled in the same process.
Key Architectural Patterns & Design Principles
• MVC-style separation:
• Models/business logic in data.py
• Views in templates/ (HTML + Bootstrap)
• Controllers in app.py
• Single-page-style flows per route (no separate SPA framework).
• Monolithic deployment – easy to evolve but not microservices.