How anshsrihan/ticker2 works
Project Type and Purpose
• This is a full-stack, Django-based web application augmented with Celery for background processing.
• It provides real-time stock quotes, technical indicators, corporate filings, news integration, price alerts, and watchlists.
Break Down the Main Components
a. Client Layer
• Web Browser (User Interface)
• Static Assets: HTML templates under templates/, CSS/JS under staticfiles/
• Keyboard shortcuts & search overlay (JS code in staticfiles/js/main.js)
b. Web Tier
• Nginx (optional, for production static & reverse proxy)
• Gunicorn/uWSGI serving the Django app (manage.py, stock_ticker/wsgi.py)
• Django Application
– URL routing (stock_ticker/urls.py, stocks/urls.py)
– Views & REST Endpoints (stocks/views.py, DRF serializers in stocks/serializers.py)
– Business logic & services (stocks/services.py)
– Database models (stocks/models.py)
c. Data Persistence
• Primary Database (PostgreSQL recommended)
• Redis
– Caching stock data for quick access
– Celery broker & backend
d. Background Processing
• Celery Workers (stocks/tasks.py, celery_app.py)
• Celery Beat (scheduler for periodic tasks)
• Redis as broker/scheduler backend
• Periodic jobs: price updates, alert checks, news fetching, data cleanup
e. External Systems
• Yahoo Finance API & yfinance library (real-time & historical prices)
• NSE website scraping (corporate filings)
• News sources: RSS feeds, financial news APIs
• Email SMTP server (Gmail) for sending price-alert emails
Relationships & Data Flows
• Browser ↔ Nginx ↔ Gunicorn ↔ Django views
• Views ↔ Database (read/write)
• Views ↔ Redis (cache queries, session data)
• Views ↔ External APIs (data fetch via services.py)
• Celery Beat → Redis → Celery Workers →
• External APIs/scrapers → Database
• Database ← price alerts → Email server
• Reactivity: WebSocket or polling for real-time updates (if implemented; otherwise periodic AJAX)
• API endpoints (/api/search/, /api/stock/<symbol>/price/) consumed by frontend
Architectural Patterns & Principles
• MVC/MVT (Django’s Model-View-Template)
• Layered Architecture: Presentation, Application, Data
• Event-driven background processing with Celery
• Separation of concerns: services layer for external calls, tasks for scheduled jobs
• Cache-aside pattern (Redis caching)
• URL Router
• Views & DRF Endpoints
• Services Layer
• Models Layer
• Yahoo Finance API, NSE Scraper, RSS/News APIs, SMTP.