How bharathkumargoud179/stocker-cloud-based-platform works
Purpose and Entry Point
This is a Python stock-trading web application with separate trader and admin dashboards, market views, buy/sell flows, authentication, and transaction history. The primary application entry point is app.py. Browser-facing pages are server-rendered HTML rather than a standalone frontend application.
Application Layer
app.py is the central control boundary: it likely owns HTTP route handling, authentication/session behavior, stock transaction orchestration, dashboard data assembly, and database access. Its route outputs are rendered through the template layer and styled by static assets.
• app.py
• templates/base.html
• static/style.css
User and Trading Flows
The application exposes distinct flows for account access, viewing market data, executing purchases or sales, and reviewing completed transactions. Trader and administrator experiences are separated at the presentation layer, implying role-aware routing or authorization in the application layer.
• templates/login.html
• templates/signup.html
• templates/market.html
• templates/buy_stock.html
• templates/sell_stock.html
• templates/transactions.html
Dashboard Boundary
Dashboard templates define the main post-login operational views. The trader dashboard likely presents portfolio/trading information, while the admin dashboard supports elevated oversight or management operations. Shared page structure should flow through the common base template.
• templates/dashboard_trader.html
• templates/dashboard_admin.html
• templates/base.html
• templates/index.html
Persistence and External Services
DynamoDB is the material persistence dependency, as indicated by the dedicated provisioning script. Application configuration likely supplies AWS credentials, region, and table identifiers through environment variables; .env.example is the expected configuration contract. The database boundary should remain concentrated in app.py or its imported dependencies rather than in templates.
• setup_dynamodb.py
• .env.example
• app.py
Runtime and Deployment Topology
The intended production stack is Python served by Gunicorn, managed as a systemd service, and reverse-proxied by Nginx on EC2. Deployment scripts and policies establish host setup and AWS permissions. This creates a clear boundary between application code and infrastructure provisioning.
• gunicorn.conf.py
• deploy/stocker.service
• deploy/stocker.nginx
• deploy/ec2_setup.sh
• deploy/iam_policy.json
Key Control Flow
A request enters through Nginx, is forwarded to Gunicorn, and reaches the Python application in app.py. The application validates user/role context, reads or updates DynamoDB for account, market, portfolio, or transaction state, then renders the appropriate template. Buy/sell actions are the most important state-changing boundary and should enforce authorization, input validation, balance/holding constraints, and atomicity or consistency expectations around persistence.
Main entry points: app.py Application routes · base.html Shared page shell · stocker.nginx Nginx reverse proxy · gunicorn.conf.py Gunicorn
Components 20
Production Edge
- Nginx reverse proxy
deploy/stocker.nginx - Gunicorn
gunicorn.conf.py
Python Application
- Application routes · Central HTTP, session, dashboard, and database control boundary.
app.py - Authentication and roles · Gates trader and administrator experiences.
app.py - Buy/sell orchestration · Validates trades and updates balances, holdings, and transaction state.
app.py - Dashboard assembly
app.py
Server-rendered Views
- Shared page shell
templates/base.html - Login and signup
templates/login.html - Market and trade pages
templates/market.html - Transaction history
templates/transactions.html - Trader dashboard
templates/dashboard_trader.html - Admin dashboard
templates/dashboard_admin.html - Site styles
static/style.css
Persistence
- DynamoDB · Stores account, market, portfolio, and transaction state.
- DynamoDB provisioning
setup_dynamodb.py - AWS environment contract · Defines credentials, region, and table settings.
.env.example
Host Provisioning
- Systemd service
deploy/stocker.service - EC2 host setup
deploy/ec2_setup.sh - AWS IAM policy
deploy/iam_policy.json
Other components
- Browser
Connections 26
- Browser → Nginx reverse proxy: HTTPS requests
- Nginx reverse proxy → Gunicorn: proxies
- Gunicorn → Application routes: WSGI
- Systemd service → Gunicorn: manages process
- Application routes → Authentication and roles: validates identity and role
- Application routes → Buy/sell orchestration: handles buy/sell
- Application routes → Dashboard assembly: assembles post-login views
- Authentication and roles → DynamoDB: reads account context
- Buy/sell orchestration → DynamoDB: reads and writes trade state
- Dashboard assembly → DynamoDB: reads portfolio and history
- Application routes → Login and signup: renders
- Application routes → Market and trade pages: renders
- Application routes → Transaction history: renders
- Dashboard assembly → Trader dashboard: renders for trader
- Dashboard assembly → Admin dashboard: renders for admin
- Login and signup → Shared page shell: extends
- Market and trade pages → Shared page shell: extends
- Transaction history → Shared page shell: extends
- Trader dashboard → Shared page shell: extends
- Admin dashboard → Shared page shell: extends
- Shared page shell → Site styles: loads
- DynamoDB provisioning → DynamoDB: provisions
- AWS environment contract → Application routes: supplies AWS settings
- AWS IAM policy → DynamoDB: authorizes AWS access
- EC2 host setup → Systemd service: installs host service
- EC2 host setup → Nginx reverse proxy: installs proxy