# gdefias/api_automation_test architecture

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

- Interactive diagram: https://gitdiagram.com/gdefias/api_automation_test
- Repository: https://github.com/gdefias/api_automation_test

## Overview

##### Project Type and Purpose
- This is a full-stack web application designed as an API testing and automation platform.
- The backend is built with Python (Django 2.0.2 and the Django REST framework) and is responsible for managing API endpoints, automation test cases, user authentication (including DingTalk login), and administration.
- The frontend is built with Vue.js (with Element UI) and provides the user interface for logging in, managing projects, viewing reports, and interacting with the API testing functionalities.
- The overall design includes Docker-based deployment (with Dockerfile, docker-compose, and Nginx configurations) for containerization and streamlined deployment, as well as CI/CD using Jenkins.

##### Main Components Identified
a. Frontend Client:
– Located in the “frontend” directory with all Vue.js-related source code, build configurations (webpack, babel), and static assets.
– Produces a single-page application (SPA) that interacts with the backend’s RESTful APIs.
b. Backend Server:
– Contains two primary Django modules (api_automation_test and api_test) with models, views, serializers, URLs, and business logic.
– Manages API endpoints, authentication, and testing logic.
– Uses Django REST framework and integrates with Swagger UI (accessible via /docs/) for API documentation.
c. Database and Data Persistence:
– MySQL is used as the primary data storage (configuration provided in api_automation_test/settings.py and setup scripts under “mysql”).
d. API Testing and Automation Workflow:
– Multiple modules (inside api_test and common directories) handle test case management, dynamic API testing, generating test reports, and exporting test documentation.
e. Infrastructure & Deployment:
– Docker and docker-compose support containerization.
– Nginx (with its own Dockerfile and configuration) serves as a reverse proxy/load balancer.
– Uwsgi handles the Python/Django application interface (UwsgiScript folder).
– CI/CD integration is supported via Jenkins (Jenkinsfile).
f. External Integrations:
– DingTalk login integration (configured in DingConfig.py).
– SwaggerUI for API documentation.
– Email notifications and file export features.

##### Relationships and Interactions
- The Frontend (Vue.js SPA) makes HTTP requests to the Backend’s REST APIs.
- The Backend processes requests, interacts with the MySQL database for CRUD operations, test case management, and user data, and returns responses.
- The backend also exposes Swagger documentation and supports mock API responses.
- Docker orchestrates the various deployment containers (backend, frontend, MySQL, Nginx) and ensures that all components communicate properly.
- CI/CD pipelines (Jenkins) are set up to build, test, and deploy the containers.
- Additional services (like DingTalk for login and email services for sending reports) plug into the backend workflow.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clear division between frontend (presentation layer) and backend (business logic and data access).
- REST API Design: Backend endpoints based on Django REST framework.
- Microservices-ish separation: Although it is not strictly microservices, the backend structure “api_test” and “api_automation_test” indicate modular design.
- Containerization: Use of Docker for isolating and deploying distinct components (backend, frontend, database, proxy server).
- CI/CD and automation are built into the deployment lifecycle.

##### Technologies and Frameworks
- Backend: Python 3.6, Django 2.0.2, Django REST framework, Uwsgi.
- Frontend: Vue.js, Element UI, Webpack.
- Database: MySQL.
- Deployment: Docker, docker-compose, Nginx.
- CI/CD: Jenkins.
- Other: SwaggerUI for API documentation, possibly additional libraries for emailing and file generation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    U["User"]:::client

    %% Infrastructure & Deployment
    subgraph "Infrastructure & Deployment"
        D1["Dockerfile"]:::infra
        D2["Docker Compose"]:::infra
        Nginx["Reverse Proxy (Nginx)"]:::infra
        Uwsgi["Uwsgi Application Gateway"]:::infra
        Jenkins["CI/CD Pipeline (Jenkins)"]:::infra
    end

    %% External Integrations
    subgraph "External Integrations"
        Ext["DingTalk Login"]:::external
        Swagger["Swagger UI"]:::external
    end

    %% Frontend Client
    subgraph "Frontend Client"
        FE["Frontend (Vue.js SPA)"]:::frontend
    end

    %% Backend Server
    subgraph "Backend Server"
        B1["Core Django (Settings & URLs)"]:::backend
        B2["API Endpoints (Models,Views,Serializers)"]:::backend
        B3["Test Automation API"]:::backend
        B4["Common Modules"]:::backend
        B5["DingTalk Integration"]:::backend
        B6["Swagger UI Documentation"]:::backend
    end

    %% Database
    subgraph "Database"
        DB["MySQL Database"]:::database
    end

    %% Connections
    U -->|"HTTPRequest"| Nginx
    Nginx -->|"RoutesTo"| FE
    Nginx -->|"RoutesTo"| B1

    FE -->|"APICall"| B1
    
    B1 -->|"DelegatesTo"| B2
    B2 -->|"Executes"| B3
    B2 -->|"Executes"| B4
    B1 -->|"Queries"| DB
    B1 -->|"AuthenticatesVia"| B5
    B5 -->|"ConfiguredBy"| Ext
    B1 -->|"DocumentsVia"| B6
    B6 -->|"ExposedAs"| Swagger

    Jenkins -->|"TriggersBuild"| D1
    Jenkins -->|"TriggersBuild"| D2
    D1 --> FE
    D1 --> B1
    D2 --> FE
    D2 --> B1
    Uwsgi --> B1

    %% Styles
    classDef frontend fill:#C1E1C1,stroke:#333,stroke-width:2px;
    classDef backend fill:#FFB347,stroke:#333,stroke-width:2px;
    classDef database fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef infra fill:#FDD835,stroke:#333,stroke-width:2px;
    classDef external fill:#B39DDB,stroke:#333,stroke-width:2px;
    classDef client fill:#E0E0E0,stroke:#333,stroke-width:2px;

    %% Click Events
    click FE "https://github.com/gdefias/api_automation_test/tree/master/frontend/"
    click B1 "https://github.com/gdefias/api_automation_test/tree/master/api_automation_test/"
    click B2 "https://github.com/gdefias/api_automation_test/tree/master/api_test/"
    click B3 "https://github.com/gdefias/api_automation_test/tree/master/api_test/api/"
    click B4 "https://github.com/gdefias/api_automation_test/tree/master/api_test/common/"
    click DB "https://github.com/gdefias/api_automation_test/tree/master/mysql/"
    click Nginx "https://github.com/gdefias/api_automation_test/tree/master/nginx/"
    click Uwsgi "https://github.com/gdefias/api_automation_test/tree/master/UwsgiScript/"
    click Jenkins "https://github.com/gdefias/api_automation_test/tree/master/Jenkinsfile"
    click B5 "https://github.com/gdefias/api_automation_test/blob/master/api_test/config/DingConfig.py"
```
