# gonzalopontnau/crypto-price-pyhon architecture

> Architecture diagram of the GitHub repository gonzalopontnau/crypto-price-pyhon, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gonzalopontnau/crypto-price-pyhon
- Repository: https://github.com/gonzalopontnau/crypto-price-pyhon

## Overview

##### Main components

- Web Client – Representing the browser, which displays HTML pages (e.g., index.html, noticias.html, mercado.html) and static assets (CSS, images).

- Flask Application Server – The core of your system (app.py). This serves the HTML templates, handles routing, and coordinates interactions.

- External API – CoinMarketCap’s API that the application calls to fetch real-time price data. This component is external but essential.

- Static Assets – The “static” directory (CSS, images) used to style and support your UI.

- Deployment Components – Although not part of the runtime application logic, elements like the Procfile and vercel.json show that the app can be deployed on platforms such as Heroku and Vercel. You might also illustrate how environment variables (via the .env file) are used for configuration.

##### Relationships and interactions

- The Web Client (browser) makes HTTP requests to the Flask Application Server.

- The Flask server processes these requests and based on the route (e.g., home page, noticias, or mercado), it renders a template from the “templates” directory.

- When real-time cryptocurrency data is needed, app.py makes a request to the external CoinMarketCap API using the provided API key from the .env file.

- Data retrieved from the API is integrated into the web pages before being sent back to the Web Client.

- Static Assets are served by Flask to ensure the browser has the necessary styling and images.

- Deployment configurations (Procfile for Heroku, vercel.json for Vercel) guide how the application is hosted in production.

##### Important architectural patterns

- MVC (ish) Approach – Although Flask doesn’t enforce strict MVC, there is a separation between view (templates & static assets), controller (Flask routes in app.py), and the external model (data from the CoinMarketCap API).

- Environment Configuration – By using a .env file, configuration details (like your API key) are abstracted from the code, which is a good security and flexibility practice.

##### Relevant technologies and frameworks

- Python and Flask for server-side logic.

- HTML/CSS for client-side rendering (in the templates and static files).

- CoinMarketCap API for sourcing cryptocurrency price data.

- Optional deployment tools like Heroku and Vercel (as indicated by Procfile and vercel.json).

##### Instructing the Principal Software Engineer

- The user’s browser is at the top.
- This to a node labeled "Flask Application Server (app.py)".
- Inside or adjacent to this node, show internal routing logic, pointing out that HTML templates and static files form the view.
- Annotations for environment configuration (.env) that ensures API keys are securely used within the Flask app.
- Around the perimeter, include deployment symbols (e.g., Heroku/Vercel) indicating production setup.

- Data flow:
→ Browser sends requests to Flask routes.
→ Flask handles the request, consults the external API as needed.
→ Flask assembles the data into templates.
→ Rendered HTML along with static assets is sent back to the browser.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        Browser["Web Client (Browser)"]:::client
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        Flask["Flask Application Server (app.py)"]:::server
        Templates["HTML Templates"]:::template
        StaticAssets["Static Assets"]:::static
    end

    %% Data Layer
    subgraph "Data Layer"
        CoinAPI["CoinMarketCap API"]:::api
    end

    %% Deployment Configurations
    subgraph "Deployment Configurations"
        Procfile["Procfile"]:::deploy
        Vercel["vercel.json"]:::deploy
        Env[".env (Environment Config)"]:::env
    end

    %% Data Flow Connections
    Browser -->|"HTTPRequest"| Flask
    Flask -->|"Render"| Templates
    Flask -->|"Serve"| StaticAssets
    Flask <-->|"APIRequest_Response"| CoinAPI
    Templates -->|"HTML"| Browser
    StaticAssets -->|"CSS/Images"| Browser
    Flask ---|"Uses"| Env
    Flask --- Procfile
    Flask --- Vercel

    %% Click Events for Component Mapping
    click Templates "https://github.com/gonzalopontnau/crypto-price-pyhon/blob/main/templates/index.html"
    click Templates "https://github.com/gonzalopontnau/crypto-price-pyhon/blob/main/templates/noticias.html"
    click Templates "https://github.com/gonzalopontnau/crypto-price-pyhon/blob/main/templates/mercado.html"
    click StaticAssets "https://github.com/gonzalopontnau/crypto-price-pyhon/blob/main/static/css/style.css"
    click StaticAssets "https://github.com/gonzalopontnau/crypto-price-pyhon/tree/main/static/img"
    click Flask "https://github.com/gonzalopontnau/crypto-price-pyhon/blob/main/app.py"
    click Procfile "https://github.com/gonzalopontnau/crypto-price-pyhon/tree/main/Procfile"
    click Vercel "https://github.com/gonzalopontnau/crypto-price-pyhon/blob/main/vercel.json"

    %% Styles
    classDef client fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef server fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef template fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef static fill:#87CEFA,stroke:#333,stroke-width:2px;
    classDef api fill:#FFA07A,stroke:#333,stroke-width:2px;
    classDef deploy fill:#DDA0DD,stroke:#333,stroke-width:2px;
    classDef env fill:#D3D3D3,stroke:#333,stroke-width:2px;
```
