How sharan1392/django_alpha_vantage_api_pull works
Purpose and Entry Points
This is a Django service that periodically fetches BTC/USD pricing from Alpha Vantage and persists it in PostgreSQL. The main Django entry points are manage.py, AlphaVantage/urls.py, and AlphaVantage/wsgi.py; HTTP endpoints are owned by the price app via price/urls.py and price/views.py.
Django Application Boundary
AlphaVantage/settings.py defines the project runtime configuration, including database, Celery, Redis, and installed applications. price/apps.py registers the domain app, while price/models.py defines the persisted price data model and price/admin.py exposes it to Django administration.
Scheduled Ingestion Pipeline
Celery is initialized/configured in price/celery.py. Scheduled execution is expected to be managed through Celery Beat and the django_celery_beat dependency. The ingestion job lives in price/tasks.py: it is the asynchronous boundary between periodic scheduling and external price retrieval/storage.
External Market Data Integration
price/client.py is the Alpha Vantage integration boundary. It isolates outbound API requests from task orchestration and persistence concerns. Alpha Vantage credentials/configuration are likely sourced through AlphaVantage/.env and settings in AlphaVantage/settings.py.
Persistence Flow
The primary flow is: Celery Beat triggers a task in price/tasks.py; the task calls price/client.py; returned BTC/USD data is converted into a record in price/models.py; Django uses psycopg2 to write that record to PostgreSQL. PostgreSQL is therefore the durable system of record for collected prices.
API and Read Access
price/views.py provides the read-facing Django/DRF layer over stored price data, routed through price/urls.py and included by AlphaVantage/urls.py. This separates query/API delivery from the background collection path.
Runtime and Infrastructure
The service runs in Docker, defined by Dockerfile and coordinated with PostgreSQL, Redis, Django, and likely Celery worker/beat processes through docker-compose.yml. Redis is the Celery broker/result infrastructure; PostgreSQL stores application data; Alpha Vantage is the external upstream service. Python dependencies and version constraints are captured in Pipfile and Pipfile.lock.
Main entry points: settings.py Project settings · docker-compose.yml Docker Compose · models.py Price model · celery.py Celery setup
Components 18
Django service
- Django CLI
manage.py - Project settings · Configures apps, database, Celery, and Redis.
AlphaVantage/settings.py - Project routes
AlphaVantage/urls.py - WSGI entry
AlphaVantage/wsgi.py - Price app
price/apps.py - Price routes
price/urls.py - Price read API · Serves stored price data.
price/views.py - Price model · Defines persisted BTC/USD price records.
price/models.py - Django admin
price/admin.py
Price ingestion
- Celery setup
price/celery.py - Celery Beat · Periodically dispatches ingestion work.
- Price ingestion task · Orchestrates retrieval and storage.
price/tasks.py - Alpha Vantage client
price/client.py
Runtime infrastructure
- PostgreSQL · Durably stores collected prices.
- Redis
- Docker Compose · Coordinates Django, workers, scheduler, Redis, and PostgreSQL.
docker-compose.yml - Docker image
Dockerfile
Other components
- Alpha Vantage · External BTC/USD price source.
Connections 20
- Django CLI → Project settings: loads
- WSGI entry → Project settings: loads
- Project settings → Price app: installs
- Project settings → PostgreSQL: configures
- Project settings → Celery setup: configures
- Project routes → Price routes: includes
- Price routes → Price read API: routes to
- Price read API → Price model: queries
- Django admin → Price model: manages
- Celery setup → Celery Beat: enables schedule
- Celery setup → Redis: uses
- Celery Beat → Price ingestion task: triggers
- Price ingestion task → Alpha Vantage client: fetches through
- Alpha Vantage client → Alpha Vantage: requests BTC/USD
- Price ingestion task → Price model: creates record
- Price model → PostgreSQL: persists via ORM
- Docker Compose → Docker image: builds from
- Docker Compose → PostgreSQL: runs
- Docker Compose → Redis: runs
- Docker Compose → Celery Beat: runs