# sharan1392/django_alpha_vantage_api_pull architecture

> Architecture diagram of the GitHub repository sharan1392/django_alpha_vantage_api_pull, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sharan1392/django_alpha_vantage_api_pull
- Repository: https://github.com/sharan1392/django_alpha_vantage_api_pull

## Overview

#### 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: [`AlphaVantage/settings.py`](https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/AlphaVantage/settings.py) (Project settings), [`docker-compose.yml`](https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/docker-compose.yml) (Docker Compose), [`price/models.py`](https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/price/models.py) (Price model), [`price/celery.py`](https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/price/celery.py) (Celery setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_django["Django service"]
  node_manage["Django CLI<br/>entry point<br/>[manage.py]"]
  node_project_settings["Project settings<br/>Django configuration<br/>[settings.py]"]
  node_project_urls["Project routes<br/>URL router<br/>[urls.py]"]
  node_wsgi["WSGI entry<br/>deployment entry point<br/>[wsgi.py]"]
  node_price_app["Price app<br/>Django app registration<br/>[apps.py]"]
  node_price_urls["Price routes<br/>URL router<br/>[urls.py]"]
  node_price_views["Price read API<br/>Django/DRF views<br/>[views.py]"]
  node_price_model["Price model<br/>Django ORM model<br/>[models.py]"]
  node_admin["Django admin<br/>admin integration<br/>[admin.py]"]
end

subgraph group_ingestion["Price ingestion"]
  node_celery_config["Celery setup<br/>Celery configuration<br/>[celery.py]"]
  node_beat(("Celery Beat<br/>scheduler"))
  node_task["Price ingestion task<br/>Celery task<br/>[tasks.py]"]
  node_client["Alpha Vantage client<br/>external API adapter<br/>[client.py]"]
end

subgraph group_infra["Runtime infrastructure"]
  node_postgres[("PostgreSQL<br/>system of record")]
  node_redis["Redis<br/>Celery broker/result backend"]
  node_docker_compose["Docker Compose<br/>runtime orchestration<br/>[docker-compose.yml]"]
  node_dockerfile["Docker image<br/>container build"]
end

node_alpha_vantage{{"Alpha Vantage<br/>market data API"}}

node_manage -->|"loads"| node_project_settings
node_wsgi -->|"loads"| node_project_settings
node_project_settings -->|"installs"| node_price_app
node_project_settings -->|"configures"| node_postgres
node_project_settings -->|"configures"| node_celery_config
node_project_urls -->|"includes"| node_price_urls
node_price_urls -->|"routes to"| node_price_views
node_price_views -->|"queries"| node_price_model
node_admin -->|"manages"| node_price_model
node_celery_config -->|"enables schedule"| node_beat
node_celery_config -->|"uses"| node_redis
node_beat -->|"triggers"| node_task
node_task -->|"fetches through"| node_client
node_client -->|"requests BTC/USD"| node_alpha_vantage
node_task -->|"creates record"| node_price_model
node_price_model -->|"persists via ORM"| node_postgres
node_docker_compose -->|"builds from"| node_dockerfile
node_docker_compose -->|"runs"| node_postgres
node_docker_compose -->|"runs"| node_redis
node_docker_compose -->|"runs"| node_beat

click node_manage "https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/manage.py"
click node_project_settings "https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/AlphaVantage/settings.py"
click node_project_urls "https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/AlphaVantage/urls.py"
click node_wsgi "https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/AlphaVantage/wsgi.py"
click node_price_app "https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/price/apps.py"
click node_price_urls "https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/price/urls.py"
click node_price_views "https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/price/views.py"
click node_price_model "https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/price/models.py"
click node_admin "https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/price/admin.py"
click node_celery_config "https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/price/celery.py"
click node_task "https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/price/tasks.py"
click node_client "https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/price/client.py"
click node_docker_compose "https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/docker-compose.yml"
click node_dockerfile "https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/Dockerfile"

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_manage,node_project_settings,node_project_urls,node_wsgi,node_price_app,node_price_urls,node_price_views,node_price_model,node_admin toneBlue
class node_celery_config,node_beat,node_task,node_client toneAmber
class node_postgres,node_redis,node_docker_compose,node_dockerfile toneMint
class node_alpha_vantage toneNeutral
```

## Components

### Django service

- [Django CLI](https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/manage.py): entry point · `manage.py`
- [Project settings](https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/AlphaVantage/settings.py): Django configuration · Configures apps, database, Celery, and Redis. · `AlphaVantage/settings.py`
- [Project routes](https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/AlphaVantage/urls.py): URL router · `AlphaVantage/urls.py`
- [WSGI entry](https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/AlphaVantage/wsgi.py): deployment entry point · `AlphaVantage/wsgi.py`
- [Price app](https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/price/apps.py): Django app registration · `price/apps.py`
- [Price routes](https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/price/urls.py): URL router · `price/urls.py`
- [Price read API](https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/price/views.py): Django/DRF views · Serves stored price data. · `price/views.py`
- [Price model](https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/price/models.py): Django ORM model · Defines persisted BTC/USD price records. · `price/models.py`
- [Django admin](https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/price/admin.py): admin integration · `price/admin.py`

### Price ingestion

- [Celery setup](https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/price/celery.py): Celery configuration · `price/celery.py`
- **Celery Beat**: scheduler · Periodically dispatches ingestion work.
- [Price ingestion task](https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/price/tasks.py): Celery task · Orchestrates retrieval and storage. · `price/tasks.py`
- [Alpha Vantage client](https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/price/client.py): external API adapter · `price/client.py`

### Runtime infrastructure

- **PostgreSQL**: system of record · Durably stores collected prices.
- **Redis**: Celery broker/result backend
- [Docker Compose](https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/docker-compose.yml): runtime orchestration · Coordinates Django, workers, scheduler, Redis, and PostgreSQL. · `docker-compose.yml`
- [Docker image](https://github.com/sharan1392/django_alpha_vantage_api_pull/blob/main/Dockerfile): container build · `Dockerfile`

### Other components

- **Alpha Vantage**: market data API · External BTC/USD price source.

## Connections

- 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
