# botirbakhtiyarov/autoinstaller_django architecture

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

- Interactive diagram: https://gitdiagram.com/botirbakhtiyarov/autoinstaller_django
- Repository: https://github.com/botirbakhtiyarov/autoinstaller_django

## Overview

##### Main Components
- Web Server & Django Application:
- AutoInstaller: Contains global configurations (settings.py, urls.py, WSGI/ASGI entry points).
- Installer App: Manages user-facing actions, including browsing apps, processing payments, and exposing API endpoints for installations.
- Management App: Provides the admin interface for app uploads, script management, and other administrative functions.
- Database:
- PostgreSQL (as mentioned in the README’s prerequisites) that stores app data, user purchases, and metadata.
- API Layer:
- REST endpoints (e.g., /api/install/<app_name>/) that facilitate installation commands both from the frontend and a Windows batch file.
- Client Components (Windows-specific):
- LocalApp.exe: A standalone executable responsible for processing installation commands.
- install_app.bat: A batch script wrapping the API call and triggering LocalApp.exe, which uses custom URLs (myapp://) to initiate installs.
- External Services & Deployment:
- WeChat Payment Gateway: Responsible for handling payments via QR codes.
- Docker & Docker Compose: Container orchestration components to deploy the server.
- Custom protocol registration (“myapp://”) that bridges the web API and local system installation.

##### Relationships and Data Flows
- User Workflow:
- A user visits the frontend (templates in the Installer directory) and browses available apps.
- Payment process via WeChat triggers a change in state, captured by the Installer’s views and corresponding database updates.
- When a user clicks “安装” (Install), the web client creates a custom protocol link (myapp://...) that triggers LocalApp.exe on the client machine.
- API & Batch Script Workflow:
- Running the command “install_app <app_name>” causes the batch file to call the API endpoint, which returns an install_url.
- The batch file then triggers LocalApp.exe with the received install URL, which in turn fetches and runs the installation script.
- Administration Workflow:
- Admins access the Management component using the admin interface (templates in Management) to upload and modify app details.
- Docker & Deployment:
- The Dockerfile and docker-compose.yml facilitate containerized deployment.
- Nginx (or another reverse proxy) and gunicorn are mentioned for production; these can be factored in as the deployment layer.

##### Architectural Patterns and Technologies
- MVC or MTV (Model-Template-View) pattern for separating concerns in Django.
- RESTful API design for the installation triggers.
- Integration of external payment services (WeChat) and custom protocol handling.
- Use of Docker to encapsulate environment configuration and dependencies.
- Technologies: Python 3.10, Django 4.2, Docker, PostgreSQL (external), and Windows utilities (batch scripting, custom protocol registration).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    UB["User Browser"]:::web

    %% Docker Container Subgraph (Django Web Application)
    subgraph "Docker Container (Django Web Application)"
        A1["AutoInstaller (Django Web Application)"]:::django
        A2["Installer App (User-Facing)"]:::django
        A3["Management App (Admin Interface)"]:::django
        A4["Installation API Endpoint (/api/install/<app_name>/)"]:::django
        A1 --> A2
        A1 --> A3
        A2 --> A4
    end

    %% External Services
    W["WeChat Payment Service"]:::external
    DB[(PostgreSQL Database)]:::db

    %% Windows Client Subgraph
    subgraph "Windows Client"
        B1["install_app.bat"]:::client
        B2["LocalApp.exe"]:::client
        B1 --> B2
    end

    %% Deployment & Containerization Subgraph
    subgraph "Deployment & Containerization"
        E1["Docker Compose"]:::deploy
        E2["Dockerfile"]:::deploy
    end

    %% User Flow Connections
    UB -->|"accesses"| A2
    A2 -->|"triggers"| W
    A4 -->|"updates/queries"| DB
    A4 -->|"API call"| B1

    %% Deployment Connection
    E1 -->|"builds"| A1
    E2 -->|"configures"| A1

    %% Admin Flow Connection (separate admin access via Management App)
    UB -->|"admin access"| A3

    %% Styles
    classDef web fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef django fill:#D5F5E3,stroke:#196F3D,stroke-width:2px;
    classDef db fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef external fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef client fill:#F5CBA7,stroke:#D35400,stroke-width:2px;
    classDef deploy fill:#E8DAEF,stroke:#6C3483,stroke-width:2px;

    %% Click Events
    click A1 "https://github.com/botirbakhtiyarov/autoinstaller_django/tree/master/AutoInstaller/"
    click A2 "https://github.com/botirbakhtiyarov/autoinstaller_django/tree/master/Installer/"
    click A3 "https://github.com/botirbakhtiyarov/autoinstaller_django/tree/master/Management/"
    click A4 "https://github.com/botirbakhtiyarov/autoinstaller_django/blob/master/Installer/views.py"
    click B1 "https://github.com/botirbakhtiyarov/autoinstaller_django/blob/master/install_app.bat"
    click E1 "https://github.com/botirbakhtiyarov/autoinstaller_django/blob/master/docker-compose.yml"
    click E2 "https://github.com/botirbakhtiyarov/autoinstaller_django/tree/master/dockerfile"
```
