# k-aniket-01/chartliz architecture

> Architecture diagram of the GitHub repository k-aniket-01/chartliz, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/k-aniket-01/chartliz
- Repository: https://github.com/k-aniket-01/chartliz

## Overview

##### Project type and purpose
- ChartLiz is a full-stack web application (Django MVC) that acts as a real-time stock trading assistant.
- It provides paper-trade simulation, candlestick pattern recognition, educational pages, and WebSocket-driven live updates.

##### File structure
- Top-level:
- manage.py, db.sqlite3 (local DB placeholder), requirements.txt
- ChartLiz/ (Django project folder with settings.py, asgi.py, wsgi.py, urls.py, models.py, views.py, admin.py, signals.py)
- migrations/ (database schema history)
- static/ (styles.css, PDF resources for patterns and strategy)
- templates/ (Django HTML templates for all pages: index, dashboard, buy/sell forms, portfolio, learn, etc.)
- README.md describes tech stack and usage.

##### README for additional insights
- Tech: Python, Django, MySQL (production), WebSockets (real-time stock feed), HTML/CSS templates.
- Features: candlestick pattern recognition (PDF docs under static), paper trading simulation (models for Buy/Sell/Portfolio/Transaction), real-time updates via WebSocket channels (asgi.py indicates ASGI setup).

##### Main components
a. Frontend (Client browsers)
- HTTP requests → Django views & templates
- WebSocket client (JS) → ASGI/WebSocket endpoint
b. Django Application Server
- URL router → Views (MVC controller)
- Templates (views render HTML)
- Models (ORM)
- Signals (e.g., post-save hooks for transactions or notifications)
c. Database (MySQL in production; SQLite in dev)
- Tables: User/Profile, Buy, Sell, Portfolio, Transaction
d. Real-time Data Ingestion
- External Stock Market Data API → WebSocket publisher inside Django (via Channels or custom ASGI consumer)
e. External Services
- Email/SMS notification service (if implemented)
- Third-party authentication (optional)
f. Static & Media
- Styles, PDF docs served via Django’s static files mechanism

##### Relationships and interactions
- User’s browser
↔ (HTTP) Django URLs → Views → Templates → back to browser
↔ (WebSocket) ASGI consumer → pushes real-time updates
- Views/Controllers
↔ (ORM) Database for CRUD on trades, portfolios
- ASGI Consumer
↔ External Stock API for live quotes
→ broadcast to connected clients
- Signals
↔ triggered on model events → e.g., send notifications

##### Architectural patterns & design principles
- MVC (Model-View-Controller) inherent in Django
- Event-driven messaging (WebSockets) for real-time updates
- Layered design: Presentation (templates, CSS), Application (views, consumers), Data (models, DB), Integration (external APIs)

##### Essential details to capture
- Both HTTP and WebSocket pathways
- ORM models and their persistence to DB
- How real-time stock data flows from the external API through the ASGI consumer to the browser
- Where user-triggered trades (buy/sell) flow from frontend to views to DB and back

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend
    Browser["User Browser"]:::frontend

    %% Django Application Server
    subgraph "Django App Server"
        direction TB
        Settings["Settings & Configuration"]:::backend
        Apps["App Declaration"]:::backend
        URLRouter["URL Router"]:::backend
        HTTPViews["HTTP Views (Controllers)"]:::backend
        Templates["Frontend Templates"]:::frontend
        StaticAssets["Static Assets (CSS, PDFs)"]:::static
        ASGI["ASGI Entry Point"]:::backend
        WSGI["WSGI Entry Point"]:::backend
        WSConsumer["WebSocket Consumer"]:::backend
        ORM["ORM Models"]:::backend
        Migrations["Database Migrations"]:::backend
        Signals["Signal Handlers"]:::backend
        Admin["Admin Interface"]:::backend
        Manage["Project Entry Point / CLI"]:::backend
        Requirements["Dependency List"]:::backend
        Readme["Documentation & Tech Overview"]:::backend
    end

    %% Database and External
    DB["MySQL Database"]:::db
    StockAPI["Stock Market Data API"]:::external
    Notification["Notification Service"]:::external

    %% HTTP Flow
    Browser -->|"HTTP"| URLRouter
    URLRouter --> HTTPViews
    HTTPViews --> Templates
    HTTPViews --> StaticAssets
    HTTPViews --> ORM
    HTTPViews --> Signals
    HTTPViews --> DB

    %% WebSocket Flow
    Browser <-->|"WebSocket"| WSConsumer
    ASGI --> WSConsumer
    WSConsumer --> ORM
    WSConsumer --> DB
    StockAPI --> WSConsumer

    %% ASGI/WSGI Entry Points
    Manage --> ASGI
    Manage --> WSGI
    WSGI --> HTTPViews

    %% ORM & Migrations
    Migrations --> ORM
    Admin --> ORM

    %% Settings and Apps
    Settings --> URLRouter
    Settings --> ASGI
    Settings --> WSGI
    Settings --> ORM
    Apps --> URLRouter

    %% Signals to Notification
    Signals -.-> Notification

    %% Dependencies & Docs
    Requirements --- Readme

    %% Click Events
    click Templates "https://github.com/k-aniket-01/chartliz/tree/main/templates/"
    click StaticAssets "https://github.com/k-aniket-01/chartliz/tree/main/static/"
    click URLRouter "https://github.com/k-aniket-01/chartliz/blob/main/ChartLiz/urls.py"
    click HTTPViews "https://github.com/k-aniket-01/chartliz/blob/main/ChartLiz/views.py"
    click ORM "https://github.com/k-aniket-01/chartliz/blob/main/ChartLiz/models.py"
    click Migrations "https://github.com/k-aniket-01/chartliz/tree/main/ChartLiz/migrations/"
    click ASGI "https://github.com/k-aniket-01/chartliz/blob/main/ChartLiz/asgi.py"
    click Signals "https://github.com/k-aniket-01/chartliz/blob/main/ChartLiz/signals.py"
    click Admin "https://github.com/k-aniket-01/chartliz/blob/main/ChartLiz/admin.py"
    click Settings "https://github.com/k-aniket-01/chartliz/blob/main/ChartLiz/settings.py"
    click WSGI "https://github.com/k-aniket-01/chartliz/blob/main/ChartLiz/wsgi.py"
    click Apps "https://github.com/k-aniket-01/chartliz/blob/main/ChartLiz/apps.py"
    click Manage "https://github.com/k-aniket-01/chartliz/blob/main/manage.py"
    click Requirements "https://github.com/k-aniket-01/chartliz/blob/main/requirements.txt"
    click Readme "https://github.com/k-aniket-01/chartliz/blob/main/README.md"

    %% Styles
    classDef frontend fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef backend fill:#ccf,stroke:#333,stroke-width:1px
    classDef db fill:#ffcc99,stroke:#333,stroke-width:1px
    classDef external fill:#dddddd,stroke:#333,stroke-width:1px
    classDef static fill:#ffffcc,stroke:#333,stroke-width:1px
```
