AlphaPredict is an advanced, full-stack stock analysis platform featuring a decoupled, cloud-native architecture. It leverages a high-performance LightGBM model for predictions, served via a FastAPI backend that is automatically built, containerized, and deployed to Microsoft Azure using a complete CI/CD pipeline.
- Azure-Native Backend: The containerized FastAPI backend is deployed to Azure App Service, demonstrating enterprise-grade cloud skills.
- Automated CI/CD Pipeline: On every push to
main, a GitHub Actions workflow automatically builds a Docker image, pushes it to Azure Container Registry, and deploys the new version to production. - Advanced ML Model: Utilizes a LightGBM Gradient Boosting model for superior prediction accuracy.
- Decoupled Data Pipeline: A separate, scheduled GitHub Action handles all data ingestion, ensuring the live API is never impacted by heavy data-fetching tasks.
- Interactive UI: A sleek, modern dashboard built with React and TailwindCSS, hosted on Vercel's global edge network.
The application is composed of distinct services that work in concert. This decoupled design is a key feature, enhancing scalability, resilience, and performance.
graph TD
subgraph "User Interaction"
A[User] -->|Visits Site| FE(React Frontend @ Vercel)
end
subgraph "Live Application (Microsoft Azure)"
FE -->|API Calls| BE(FastAPI Backend @ Azure App Service)
BE -->|Reads Data| DB[(PostgreSQL @ Supabase)]
end
subgraph "CI/CD & Automation (GitHub Actions)"
GHA_Data(Data Pipeline) -->|Writes Daily Prices| DB
GHA_CICD(Backend CI/CD) -->|Deploys Container| BE
end
style FE fill:#61DAFB,stroke:#000,stroke-width:2px
style BE fill:#0078D4,stroke:#000,stroke-width:2px
style DB fill:#336791,stroke:#000,stroke-width:2px
style GHA_Data fill:#2088FF,stroke:#000,stroke-width:2px
style GHA_CICD fill:#2088FF,stroke:#000,stroke-width:2px
This project demonstrates several core DevOps principles:
- CI/CD for Applications: The
.github/workflows/deploy-to-azure.ymlworkflow automates the build, test, and deployment of the containerized backend to Azure on every push tomain. - CI/CD for Data: The
.github/workflows/daily_data_fetch.ymlpipeline manages the automated, scheduled ingestion of data, treating data operations as a first-class citizen. - Infrastructure as Code (IaC): The database schema is version-controlled (
data_pipeline/db_setup.sql), and the entire cloud deployment is defined as code within GitHub Actions workflows. - Containerization: The backend is fully containerized with Docker, ensuring consistency from local development to production on Azure.
- Configuration Management: All secrets are managed securely using GitHub Secrets and Azure App Service configuration, following 12-Factor App principles.
| Category | Technology |
|---|---|
| Frontend | React 19, Vite, TailwindCSS, Recharts |
| Backend | FastAPI, Python 3.11, Docker |
| Database | PostgreSQL (hosted on Supabase) |
| ML Model | LightGBM, Scikit-learn, Pandas |
| CI/CD | GitHub Actions |
| Deployment | Vercel (Frontend), Azure App Service (Backend), Azure Container Registry |
This project is deployed as a set of independent, communicating services.
The backend is deployed automatically by the .github/workflows/deploy-to-azure.yml workflow.
Setup required:
- Create Azure Resources:
- An Azure Container Registry (ACR) to store the Docker images.
- An Azure App Service configured to run Docker containers.
- Create Azure Credentials: Generate a Service Principal for GitHub Actions to use.
# Install Azure CLI, then run: az login az ad sp create-for-rbac --name "GitHubActions-StockPredictor" --role contributor --scopes /subscriptions/{your-subscription-id} --sdk-auth
- Configure GitHub Secrets:
- In your GitHub repo, go to Settings > Secrets and variables > Actions.
- Create
AZURE_CREDENTIALSand paste the JSON output from the previous step. - Create
DATABASE_URL,SECRET_KEY, etc., which will be used by the data pipeline.
- Configure App Service: In the Azure Portal, add your
DATABASE_URL,SECRET_KEY, etc., to the App Service's configuration.
- Import your repository on Vercel.
- Configure:
- Framework Preset: Vite
- Root Directory:
frontend
- Add environment variables:
VITE_API_BASE: Your backend URL from Azure App Service.VITE_GOOGLE_CLIENT_ID: Your Google Client ID.
- Deploy.
(Instructions for local setup remain the same, allowing developers to work on any component without needing a full cloud environment.)
- Python 3.11+
- Node.js 18+
- A PostgreSQL database instance
- Clone & Navigate:
git clone https://github.com/dhruvmohan867/stock-predictor.git && cd stock-predi - Activate Python Env:
python -m venv venv && source venv/bin/activate(or.\venv\Scripts\activateon Windows) - Install Dependencies:
pip install -r backend/requirements.txt -r data_pipeline/requirements.txt - Setup Database: Run the script from
data_pipeline/db_setup.sqlon your database. - Run Data Pipeline:
python data_pipeline/fetch_data.py - Train Model:
python ml_model/train.py - Run Backend:
uvicorn backend.main:app --reload - Run Frontend:
cd frontend && npm install && npm run dev
This project is licensed under the MIT License. See the LICENSE file for details.
