# nc3-lu/testingplatform architecture

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

- Interactive diagram: https://gitdiagram.com/nc3-lu/testingplatform
- Repository: https://github.com/nc3-lu/testingplatform

## Overview

##### Project type and purpose
– It’s a full-stack web application built on Django (see testing_platform/ settings.py, wsgi.py, asgi.py).
– Purpose: provide a suite of security and compliance testing tools (apps under testing/, automation/, iot_inspector/, onekey/, etc.), plus an API (api/ serializers.py, views.py), user authentication (authentication/), and documentation (docs/).

##### File structure
– Top-level “testing_platform” Django project containing settings, URL routing, ASGI/WSGI.
– Multiple Django “apps” each encapsulating a feature (authentication, testing, automation, c3_protocols, contact, iot_inspector, knowledge_base, landing_page, legal_section, onekey, specialized_testing, plus api/).
– Static assets under static_global/, project-wide base templates under templates/.
– A separate small “dmarc-collector” CLI/service under dmarc-collector/.
– Dockerfile, entrypoint.sh, Makefile for containerization and orchestration.
– CI/CD pipelines under .github/workflows/ and .gitlab-ci.yml.
– Celery tasks in automation/tasks.py (implying a message broker).

##### README for additional insights
– README confirms a “Testing Platform” with full documentation in docs/.

a. Main components
- Client/User Interface: Web browser (HTML/CSS/JS served by Django templates & static files)
- Web Server / Reverse Proxy: Nginx (or similar)
- Application Server: Gunicorn/Uvicorn hosting the Django project
- Django Monolith:
– Core project (testing_platform/) for settings, URL routing, middleware
– Feature apps (authentication/, testing/, automation/, iot_inspector/, onekey/, etc.)
– API layer (api/) implementing REST endpoints
- Background Worker: Celery (automation/tasks.py) + Message Broker (Redis/RabbitMQ)
- Datastore: PostgreSQL (or other RDBMS—implied by migrations/)
- External Services & Tools:
– ZAP scanner, WHOIS lookup, DMARC reports, other security scanners invoked via helpers.py in testing/ and automation/
– dmarc-collector service (stand-alone process under dmarc-collector/)
- Static & Media Storage: Local filesystem or S3 for static_global/ and uploaded files
- Documentation & CI/CD: ReadTheDocs (docs/), GitHub Actions / GitLab CI pipelines
b. Relationships & data flows
1. User → Browser → Nginx → Gunicorn → Django routing (testing_platform/urls.py)
2. Django handles HTTP requests: invokes views in feature apps
3. Views → Models → Database for reads/writes
4. Long-running tasks (e.g., automated WHOIS, ZAP) → Celery task queue → Worker → update DB → send notifications
5. API clients → Django Rest Framework endpoints (api/) → DB or background tasks
6. Documentation pipeline triggered via CI/CD to build & publish docs
c. Architectural patterns & design principles
– Monolithic modular architecture: each Django app encapsulates a distinct domain
– MVC/MVT pattern (Models, Views, Templates)
– Separation of concerns: web layer vs. background tasks (Celery)
– Configuration as code: Dockerfile, Makefile, CI workflows
– Extensibility: clear apps structure allows adding new features
d. Key technologies & libraries
– Python 3.x, Django, Django REST Framework (api/), Celery, Redis/RabbitMQ, PostgreSQL
– Docker & Docker Compose, Make, GitHub Actions/GitLab CI
– Frontend: Bootstrap (static_global/css), vanilla JS (chart.js, nav.js, etc.)
– Third-party scanners (OWASP ZAP), WHOIS libraries, DMARC utilities

##### Detail
– Don’t just lump everything as “Django.” Break out: web layer vs. API vs. background tasks vs. each major feature app (or at least group by category: “Testing Apps,” “Automation,” “Authentication,” etc.).
– Include CI/CD and docs as auxiliary components if desired, showing how code changes flow into builds, tests, and deployment.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    Browser["Web Browser"]:::external
    Nginx["Nginx Reverse Proxy"]:::web
    Gunicorn["Gunicorn/Uvicorn"]:::web

    %% Django Monolith
    subgraph "Django Monolith"
        direction TB
        Core["Django Core\n(settings, urls, asgi, wsgi)"]:::web
        subgraph "Feature Apps"
            direction TB
            Auth["Authentication App"]:::web
            TestingApp["Testing App"]:::web
            AutomationApp["Automation App"]:::web
            IoT["IoT Inspector App"]:::web
            OneKey["OneKey App"]:::web
            SpecTest["Specialized Testing App"]:::web
            C3["C3 Protocols App"]:::web
            Contact["Contact App"]:::web
            KB["Knowledge Base App"]:::web
            Landing["Landing Page App"]:::web
            Legal["Legal Section App"]:::web
        end
        API["API Layer\n(DRF serializers, views, urls)"]:::web
        StaticTemplates["Static & Templates\n(static_global/, templates/)"]:::web
    end

    %% Background & Async
    Broker["Message Broker\n(Redis/RabbitMQ)"]:::background
    Celery["Celery Worker\n(automation/tasks.py)"]:::background

    %% Data Stores
    Postgres["PostgreSQL Database"]:::data
    Storage["Static/Media Storage"]:::data

    %% External Services
    ExternalScanners["External Scanners\n(ZAP, WHOIS, DMARC)"]:::external
    DMARCCollector["DMARC Collector Service"]:::external
    CI_CD["CI/CD Pipelines"]:::external
    Docs["Documentation\n(docs/)"]:::external

    %% Connections
    Browser -->|"HTTPS Request"| Nginx
    Nginx -->|"Proxied Request"| Gunicorn
    Gunicorn -->|"Django Routing"| Core
    Core -->|"Route to App"| Auth
    Core -->|"Route to App"| TestingApp
    Core -->|"Route to App"| AutomationApp
    Core -->|"Route to App"| IoT
    Core -->|"Route to App"| OneKey
    Core -->|"Route to App"| SpecTest
    Core -->|"Route to App"| C3
    Core -->|"Route to App"| Contact
    Core -->|"Route to App"| KB
    Core -->|"Route to App"| Landing
    Core -->|"Route to App"| Legal
    Core -->|"Route to API"| API
    Core -->|"Serve Static/Templates"| StaticTemplates

    Auth -->|"DB Read/Write"| Postgres
    TestingApp -->|"DB Read/Write"| Postgres
    AutomationApp -->|"DB Read/Write"| Postgres
    IoT -->|"DB Read/Write"| Postgres
    OneKey -->|"DB Read/Write"| Postgres
    SpecTest -->|"DB Read/Write"| Postgres
    C3 -->|"DB Read/Write"| Postgres
    Contact -->|"DB Read/Write"| Postgres
    KB -->|"DB Read/Write"| Postgres
    Landing -->|"DB Read/Write"| Postgres
    Legal -->|"DB Read/Write"| Postgres
    API -->|"DB Read/Write"| Postgres

    TestingApp -->|"Invoke Scanner"| ExternalScanners
    AutomationApp -->|"Dispatch Task"| Broker
    Broker -->|"Task Message"| Celery
    Celery -->|"DB Update"| Postgres
    Celery -->|"Invoke Scanner"| ExternalScanners

    StaticTemplates -->|"Files Served"| Storage
    StaticTemplates -->|"CSS/JS/Images"| Browser

    DMARCCollector -->|"Collect Reports"| Postgres

    CI_CD -->|"Trigger Docs Build"| Docs
    CI_CD -->|"Deploy Image"| Nginx

    %% Click Events
    click Core "https://github.com/nc3-lu/testingplatform/blob/main/testing_platform/settings.py"
    click Core "https://github.com/nc3-lu/testingplatform/blob/main/testing_platform/urls.py"
    click Core "https://github.com/nc3-lu/testingplatform/blob/main/testing_platform/asgi.py"
    click Core "https://github.com/nc3-lu/testingplatform/blob/main/testing_platform/wsgi.py"
    click Auth "https://github.com/nc3-lu/testingplatform/tree/main/authentication/"
    click TestingApp "https://github.com/nc3-lu/testingplatform/tree/main/testing/"
    click AutomationApp "https://github.com/nc3-lu/testingplatform/tree/main/automation/"
    click IoT "https://github.com/nc3-lu/testingplatform/tree/main/iot_inspector/"
    click OneKey "https://github.com/nc3-lu/testingplatform/tree/main/onekey/"
    click SpecTest "https://github.com/nc3-lu/testingplatform/tree/main/specialized_testing/"
    click C3 "https://github.com/nc3-lu/testingplatform/tree/main/c3_protocols/"
    click Contact "https://github.com/nc3-lu/testingplatform/tree/main/contact/"
    click KB "https://github.com/nc3-lu/testingplatform/tree/main/knowledge_base/"
    click Landing "https://github.com/nc3-lu/testingplatform/tree/main/landing_page/"
    click Legal "https://github.com/nc3-lu/testingplatform/tree/main/legal_section/"
    click API "https://github.com/nc3-lu/testingplatform/tree/main/api/"
    click StaticTemplates "https://github.com/nc3-lu/testingplatform/tree/main/static_global/"
    click StaticTemplates "https://github.com/nc3-lu/testingplatform/tree/main/templates/"
    click DMARCCollector "https://github.com/nc3-lu/testingplatform/tree/main/dmarc-collector/dmarc-collector"
    click CI_CD "https://github.com/nc3-lu/testingplatform/tree/main/.github/workflows/"
    click CI_CD "https://github.com/nc3-lu/testingplatform/blob/main/.gitlab-ci.yml"
    click Docs "https://github.com/nc3-lu/testingplatform/tree/main/docs/"

    %% Styles
    classDef web fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef data fill:#90EE90,stroke:#333,stroke-width:1px
    classDef background fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
