# bansal-yash08/stock-market-project- architecture

> Architecture diagram of the GitHub repository bansal-yash08/stock-market-project-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bansal-yash08/stock-market-project-
- Repository: https://github.com/bansal-yash08/stock-market-project-

## Overview

1. **What this repository is**
   - This is a **single-app Streamlit project** for Nifty 500 stock analysis and prediction.
   - Architecturally, it is a **monolithic Python dashboard**: the same `app.py` file handles UI rendering, business logic, authentication, watchlists, admin access, and stock visualization.

2. **Primary execution boundary**
   - The main runtime entrypoint is **`app.py`**.
   - There is no separate backend service, database server, or frontend app in the tree.
   - The browser talks directly to the Streamlit server process running this Python app.

3. **User-facing interaction model**
   - Users access the system through a **Streamlit web UI**.
   - The UI includes:
     - login/signup
     - user watchlists
     - an admin dashboard
     - stock analysis and prediction views
   - Streamlit’s reactive execution model means most interaction state is managed inside the app process rather than through a separate API layer.

4. **Data layer**
   - The core dataset is **`nifty500_stocks.csv`**, which serves as the stock market source data for analysis and prediction visuals.
   - The README also indicates a local **`users.json`** file is used for account data and salted password hashes, although it is not shown in the tree.
   - This suggests a **file-based persistence model**, not a relational database or external storage service.

5. **Authentication and authorization**
   - Authentication appears to be implemented inside `app.py`.
   - Admin access is controlled by a hardcoded email allowlist (`ADMIN_EMAILS` in `app.py`), with the README naming `yash08bansal@gmail.com` as the admin account.
   - Regular user identities and password hashes are stored locally, so the auth boundary is application-managed rather than outsourced to an identity provider.

6. **Watchlists and account state**
   - Watchlists are part of the user experience and likely stored alongside user records in the local user store.
   - Because the project is file-backed, this state is simple to run locally but is not inherently durable across cloud restarts unless moved to a persistent database.

7. **Deployment model**
   - The repository supports **two deployment modes**:
     - **Local execution** on `http://localhost:8503`
     - **Streamlit Community Cloud** for a permanent public dashboard URL
   - The README explicitly recommends Streamlit Cloud as the long-term public deployment, and treats Cloudflare tunnel links as temporary.

8. **Local launch and operational tooling**
   - There are multiple launcher scripts:
     - `START_DASHBOARD.bat`
     - `run_app.bat`
     - `run_app.ps1`
     - `start_dashboard.ps1`
     - related “final project” and tunnel launchers
   - These wrappers mainly manage **starting the Streamlit process, choosing the port, and opening or reusing the local dashboard**.
   - The existence of these scripts indicates the project is optimized for non-technical users and classroom demos.

9. **Cloud and networking options**
   - The repo includes Cloudflare tunnel setup files and notes, but these are positioned as **temporary public access mechanisms**.
   - The final recommended public boundary is Streamlit Community Cloud, which removes dependence on a laptop staying online.
   - So the repo’s external-access story has evolved from local-only, to tunneled preview, to permanent hosted dashboard.

10. **Environment and dependency boundary**
   - `requirements.txt` defines the Python stack required by the app.
   - `runtime.txt` pins the Python version for cloud deployment.
   - `.streamlit/config.toml` configures Streamlit behavior, likely including UI/runtime settings that affect how the app is presented.

11. **Documentation and packaging artifacts**
   - The repository contains multiple project deliverables:
     - `DEPLOYMENT.md`
     - `PERMANENT_CLOUDFLARE_SETUP.md`
     - project PDFs/DOCX files
     - link shortcut files like `OPEN_DASHBOARD.url`
   - These are not runtime components, but they document and support the deployment/usage path for the dashboard.

12. **Architecture summary for diagramming**
   - The most accurate diagram is:
     - **Browser user**
     - → **Streamlit app process (`app.py`)**
     - → **local file-based inputs/outputs (`nifty500_stocks.csv`, likely `users.json`)**
   - Admin and user flows are both inside the same app process.
   - There are no separate services, queues, or databases in this repository; the architecture is intentionally compact and file-backed.

Main entry points: [`app.py`](https://github.com/bansal-yash08/stock-market-project-/blob/main/app.py) (app.py), [`README.md`](https://github.com/bansal-yash08/stock-market-project-/blob/main/README.md) (Docs), [`START_PERMANENT_CLOUDFLARE_TUNNEL.bat`](https://github.com/bansal-yash08/stock-market-project-/blob/main/START_PERMANENT_CLOUDFLARE_TUNNEL.bat) (Tunnel setup), [`nifty500_stocks.csv`](https://github.com/bansal-yash08/stock-market-project-/blob/main/nifty500_stocks.csv) (Nifty CSV)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_browser_users(("Browser users<br/>client"))
  node_streamlit_app["app.py<br/>Streamlit app<br/>[app.py]"]
  node_ui_shell["UI shell<br/>streamlit UI<br/>[app.py]"]
  node_auth_flow["Auth flow<br/>login/signup<br/>[app.py]"]
  node_user_mgmt[("User data<br/>accounts/watchlists")]
  node_admin_panel["Admin panel<br/>admin access<br/>[app.py]"]
  node_stock_views["Stock views<br/>analysis/prediction<br/>[app.py]"]
  node_watchlists["Watchlists<br/>portfolio lists<br/>[app.py]"]
  node_stock_csv["Nifty CSV<br/>market dataset"]
end

subgraph group_support["Support"]
  node_streamlit_runtime["Streamlit server<br/>runtime boundary"]
  node_local_launchers["Launch scripts<br/>bat/powershell"]
  node_cloudflare_tunnel["Tunnel setup<br/>temporary access"]
  node_streamlit_config["Streamlit config<br/>ui/runtime config<br/>[config.toml]"]
  node_requirements["Dependencies<br/>python deps<br/>[requirements.txt]"]
  node_runtime_txt["Python pin<br/>runtime version<br/>[runtime.txt]"]
  node_deployment_docs["Docs<br/>deployment notes<br/>[README.md]"]
end

node_browser_users -->|"use"| node_streamlit_runtime
node_streamlit_runtime -->|"runs"| node_streamlit_app
node_streamlit_app -->|"renders"| node_ui_shell
node_streamlit_app -->|"handles"| node_auth_flow
node_streamlit_app -->|"serves"| node_stock_views
node_streamlit_app -->|"manages"| node_watchlists
node_streamlit_app -->|"gates"| node_admin_panel
node_auth_flow -->|"reads/writes"| node_user_mgmt
node_watchlists -->|"persists in"| node_user_mgmt
node_stock_views -->|"reads"| node_stock_csv
node_streamlit_app -->|"uses"| node_streamlit_config
node_streamlit_app -->|"depends on"| node_requirements
node_streamlit_app -->|"targets"| node_runtime_txt
node_local_launchers -->|"start"| node_streamlit_runtime
node_cloudflare_tunnel -->|"exposes"| node_streamlit_runtime
node_deployment_docs -.->|"documents"| node_local_launchers
node_deployment_docs -.->|"documents"| node_cloudflare_tunnel
node_deployment_docs -.->|"describes"| node_streamlit_app

click node_streamlit_app "https://github.com/bansal-yash08/stock-market-project-/blob/main/app.py"
click node_ui_shell "https://github.com/bansal-yash08/stock-market-project-/blob/main/app.py"
click node_auth_flow "https://github.com/bansal-yash08/stock-market-project-/blob/main/app.py"
click node_admin_panel "https://github.com/bansal-yash08/stock-market-project-/blob/main/app.py"
click node_stock_views "https://github.com/bansal-yash08/stock-market-project-/blob/main/app.py"
click node_watchlists "https://github.com/bansal-yash08/stock-market-project-/blob/main/app.py"
click node_stock_csv "https://github.com/bansal-yash08/stock-market-project-/blob/main/nifty500_stocks.csv"
click node_cloudflare_tunnel "https://github.com/bansal-yash08/stock-market-project-/blob/main/START_PERMANENT_CLOUDFLARE_TUNNEL.bat"
click node_streamlit_config "https://github.com/bansal-yash08/stock-market-project-/blob/main/.streamlit/config.toml"
click node_requirements "https://github.com/bansal-yash08/stock-market-project-/blob/main/requirements.txt"
click node_runtime_txt "https://github.com/bansal-yash08/stock-market-project-/blob/main/runtime.txt"
click node_deployment_docs "https://github.com/bansal-yash08/stock-market-project-/blob/main/README.md"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_browser_users,node_streamlit_app,node_ui_shell,node_auth_flow,node_user_mgmt,node_admin_panel,node_stock_views,node_watchlists,node_stock_csv toneBlue
class node_streamlit_runtime,node_local_launchers,node_cloudflare_tunnel,node_streamlit_config,node_requirements,node_runtime_txt,node_deployment_docs toneAmber
```

## Components

### Runtime

Interactive Streamlit app and the main user-facing flows.

- **Browser users**: client · End users and admins accessing the dashboard through a web browser.
- [app.py](https://github.com/bansal-yash08/stock-market-project-/blob/main/app.py): Streamlit app · Single monolithic Python application handling UI, business logic, authentication, and visualization. · `app.py`
- [UI shell](https://github.com/bansal-yash08/stock-market-project-/blob/main/app.py): streamlit UI · Reactive dashboard layout, navigation, and view rendering inside the app process. · `app.py`
- [Auth flow](https://github.com/bansal-yash08/stock-market-project-/blob/main/app.py): login/signup · User authentication, password handling, and session state managed in-app. · `app.py`
- **User data**: accounts/watchlists · Local account records and watchlist state maintained by the application.
- [Admin panel](https://github.com/bansal-yash08/stock-market-project-/blob/main/app.py): admin access · Restricted administration area gated by the app's admin email allowlist. · `app.py`
- [Stock views](https://github.com/bansal-yash08/stock-market-project-/blob/main/app.py): analysis/prediction · Stock analysis, prediction, and visualization workflows exposed to users. · `app.py`
- [Watchlists](https://github.com/bansal-yash08/stock-market-project-/blob/main/app.py): portfolio lists · Per-user tracked stock lists and saved selections. · `app.py`
- [Nifty CSV](https://github.com/bansal-yash08/stock-market-project-/blob/main/nifty500_stocks.csv): market dataset · Primary stock-market input data used for analysis and prediction visuals. · `nifty500_stocks.csv`

### Support

Deployment, configuration, and local launch artifacts.

- **Streamlit server**: runtime boundary · Local or hosted Streamlit process serving the app to browsers.
- **Launch scripts**: bat/powershell · Wrappers for starting the dashboard locally, opening ports, and handling demos or tunnels.
- [Tunnel setup](https://github.com/bansal-yash08/stock-market-project-/blob/main/START_PERMANENT_CLOUDFLARE_TUNNEL.bat): temporary access · Temporary public access path for exposing the local app through Cloudflare tunnels. · `START_PERMANENT_CLOUDFLARE_TUNNEL.bat`
- [Streamlit config](https://github.com/bansal-yash08/stock-market-project-/blob/main/.streamlit/config.toml): ui/runtime config · Streamlit settings that tune the app's runtime and presentation. · `.streamlit/config.toml`
- [Dependencies](https://github.com/bansal-yash08/stock-market-project-/blob/main/requirements.txt): python deps · Python packages required to run the dashboard. · `requirements.txt`
- [Python pin](https://github.com/bansal-yash08/stock-market-project-/blob/main/runtime.txt): runtime version · Pinned Python version for deployment compatibility. · `runtime.txt`
- [Docs](https://github.com/bansal-yash08/stock-market-project-/blob/main/README.md): deployment notes · Documentation and packaging artifacts for local launch, cloud deployment, and project delivery. · `README.md`

## Connections

- Browser users → Streamlit server: use · Users open the dashboard in a browser.
- Streamlit server → app.py: runs · The Streamlit server executes the single app process.
- app.py → UI shell: renders · The app builds the dashboard interface and views.
- app.py → Auth flow: handles · Authentication and session control are implemented in the app.
- app.py → Stock views: serves · Analysis and prediction views are produced inside the same app.
- app.py → Watchlists: manages · User watchlists are created and updated in-app.
- app.py → Admin panel: gates · Admin features are exposed through app-level authorization.
- Auth flow → User data: reads/writes · Account records and password hashes are stored locally.
- Watchlists → User data: persists in · Watchlist state is associated with local user records.
- Stock views → Nifty CSV: reads · Market data is loaded from the CSV dataset.
- app.py → Streamlit config: uses · Streamlit runtime and presentation settings are loaded from config.
- app.py → Dependencies: depends on · The app runs with the Python dependency set.
- app.py → Python pin: targets · Deployment uses a pinned Python version.
- Launch scripts → Streamlit server: start · Batch and PowerShell scripts launch the local dashboard process.
- Tunnel setup → Streamlit server: exposes · Temporary tunnel scripts publish the local app to the public internet.
- Docs → Launch scripts: documents · Project docs explain local startup and operational usage.
- Docs → Tunnel setup: documents · Project docs explain tunnel-based access and setup.
- Docs → app.py: describes · Documentation centers on the single Streamlit application architecture.
