# renuka010/vendorms architecture

> Architecture diagram of the GitHub repository renuka010/vendorms, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/renuka010/vendorms
- Repository: https://github.com/renuka010/vendorms

## Overview

##### Project’s Main Components
- REST API Layer: Highlight the endpoints for authentication and CRUD operations. This includes:
- Vendor endpoints (vendor_views.py)
- Purchase Order endpoints (purchase_order_views.py)
- Performance endpoints (performance_views.py)
- Webapp Module: This contains business logic centered around models, serializers, and signals.
- Models: Representing Vendor, PurchaseOrder, and Performance.
- Serializers: For JSON data handling and validation.
- Django Signals: Used to automatically trigger updates (especially for real-time metric updates).
- Scheduler Component: A dedicated component (scheduler.py) that runs background tasks (using APScheduler) to capture historical performance on a weekly basis.
- Database: Represented by an SQLite database (db.sqlite3). It shows that data storage is managed by Django ORM.

##### Component Interactions and Relationships
- The Client (Postman or any API consumer) interacts with the REST API layer over HTTP.
- The API views call the underlying business logic in the webapp module:
- They use serializers to validate and process incoming JSON data.
- They interact with the Django ORM via models.
- Django Signals are hooked into CRUD operations; these trigger events to update performance metrics in real-time.
- The Scheduler periodically triggers background processing to record historical vendor performance data.
- The database (SQLite) serves as the persistent data store for models.

##### Architectural Patterns and Principles
- Layered Architecture: Separate layers for request handling (views), business logic/data validation (serializers & signals), and persistence (models & database).
- Event-Driven Updates: Use of Django Signals for real-time metric updates.
- Background Tasks: Use of APScheduler (in scheduler.py) to manage periodic data recording.
- RESTful Design: Clear segregation of endpoints for vendors, purchase orders, and performance metrics.

##### Incorporate Technology Stack
- Django and Django Rest Framework are central in the backend component.
- SQLite is used for database interactions.
- APScheduler (inside scheduler.py) is used for periodic tasks.
- Token-based authentication is used for securing API endpoints.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External clients
    API_Client("API Client"):::external
    TokenAuth("Token Authentication"):::external

    %% Django Core component
    subgraph "Django Core"
        manage_py("manage.py"):::django
        settings_py("settings.py"):::django
        urls_py("urls.py"):::django
        asgi_py("asgi.py"):::django
        wsgi_py("wsgi.py"):::django
    end

    %% REST API Layer
    subgraph "REST API Layer"
        vendor_views("vendor_views.py"):::api
        purchase_order_views("purchase_order_views.py"):::api
        performance_views("performance_views.py"):::api
    end

    %% Webapp Module (Business Logic)
    subgraph "Webapp Module"
        models("models.py"):::webapp
        serializers("serializers.py"):::webapp
        signals("signals.py"):::webapp
        tests("tests.py"):::webapp
    end

    %% Background Tasks
    subgraph "Background Tasks"
        scheduler("scheduler.py"):::scheduler
    end

    %% Database
    database("SQLite Database"):::db

    %% Connections
    API_Client -->|"HTTP_Request"| TokenAuth
    TokenAuth -->|"SecuredRequest"| vendor_views

    %% REST API endpoints invoking business logic
    vendor_views -->|"uses"| serializers
    vendor_views -->|"calls"| models

    purchase_order_views -->|"uses"| serializers
    purchase_order_views -->|"calls"| models

    performance_views -->|"uses"| serializers
    performance_views -->|"calls"| models

    %% Model interactions
    models -->|"SignalTrigger"| signals
    models -->|"DB_Query"| database

    %% Scheduler performs background updates
    scheduler -->|"UpdateMetrics"| database

    %% Styles
    classDef django fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef api fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef webapp fill:#FFFFCC,stroke:#333,stroke-width:2px;
    classDef scheduler fill:#FFA07A,stroke:#333,stroke-width:2px;
    classDef db fill:#F5DEB3,stroke:#333,stroke-width:2px;
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:2px,stroke-dasharray: 5, 5;

    %% Click Events
    click manage_py "https://github.com/renuka010/vendorms/blob/main/vendorMS/manage.py"
    click settings_py "https://github.com/renuka010/vendorms/blob/main/vendorMS/vendorMS/settings.py"
    click urls_py "https://github.com/renuka010/vendorms/blob/main/vendorMS/vendorMS/urls.py"
    click asgi_py "https://github.com/renuka010/vendorms/blob/main/vendorMS/vendorMS/asgi.py"
    click wsgi_py "https://github.com/renuka010/vendorms/blob/main/vendorMS/vendorMS/wsgi.py"
    click vendor_views "https://github.com/renuka010/vendorms/blob/main/vendorMS/webapp/views/vendor_views.py"
    click purchase_order_views "https://github.com/renuka010/vendorms/blob/main/vendorMS/webapp/views/purchase_order_views.py"
    click performance_views "https://github.com/renuka010/vendorms/blob/main/vendorMS/webapp/views/performance_views.py"
    click models "https://github.com/renuka010/vendorms/blob/main/vendorMS/webapp/models.py"
    click serializers "https://github.com/renuka010/vendorms/blob/main/vendorMS/webapp/serializers.py"
    click signals "https://github.com/renuka010/vendorms/blob/main/vendorMS/webapp/signals.py"
    click tests "https://github.com/renuka010/vendorms/blob/main/vendorMS/webapp/tests.py"
    click scheduler "https://github.com/renuka010/vendorms/blob/main/vendorMS/vendorMS/scheduler.py"
    click database "https://github.com/renuka010/vendorms/blob/main/vendorMS/db.sqlite3"
```
