# aptrs/aptrs architecture

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

- Interactive diagram: https://gitdiagram.com/aptrs/aptrs
- Repository: https://github.com/aptrs/aptrs

## Overview

##### Project type and purpose
- This is a full-stack, Django-based web application (“Automated Penetration Testing Reporting System”) with a React/TypeScript frontend.
- Purpose: allow pen-test teams to manage projects, track vulnerabilities, generate custom reports (PDF, DOCX, Excel), and provide a customer dashboard.

##### File structure
- Top-level “APTRS” directory holds the Django project and apps: accounts, configapi, customers, project, vulnerability, plus shared utils and celery config.
- Frontend sits in “frontend/” with React+Vite, TypeScript, Tailwind CSS.
- Docker artifacts: docker-compose.yml orchestrates API, frontend (via Nginx), database, broker, etc.
- CI/CD configs in .github/workflows.
- env.example, env.docker, pyproject.toml/requirements.txt indicate Python dependencies.

##### README insights
- Confirms Django REST API, React frontend, Docker deployments.
- Mentions features like customer login, report templates, scheduling/retest.
- Suggests external dependencies: SMTP/email, AWS S3 (s3_utils), Celery for background tasks.

##### Main components & interactions
a. Frontend:
- Static hosting/ Nginx serving React app.
- Browser executes React app; calls Django REST API.
b. Backend API:
- Django process (Gunicorn/ASGI) serving REST endpoints from apps: accounts, customers, project, vulnerability, configapi.
- Business logic: serializers, views, tasks, signals.
- Celery worker for asynchronous jobs (report generation, email notifications, tasks.py in apps).
c. Persistence:
- PostgreSQL (or similar) as relational database for all Django models.
- Redis or RabbitMQ as Celery broker & result store.
- AWS S3 (via s3_utils) for media/files/reports storage.
d. External services:
- SMTP email service (email_notification).
- Optional OAuth providers if any (token_utils).
e. Users:
- Admin user (Django admin).
- Customer user (via customer dashboard).

##### Architectural patterns & design principles
- MVC (Model-Serializer-View) within Django REST Framework.
- Modular “app” structure: each domain (accounts, project, vulnerability) is self-contained.
- Asynchronous background processing with Celery.
- 12-factor app: environment config, separate build and run, logs to STDOUT.

- Rectangles with component names: Browser, Nginx, React App, Django REST API, Celery Worker, PostgreSQL, Redis, S3, SMTP.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Users
    Browser["Browser"]:::frontend

    %% Frontend Layer
    subgraph "Frontend Layer"
        Nginx["Nginx"]:::frontend
        React["React App"]:::frontend
    end

    %% Backend API Layer
    subgraph "Backend API"
        DjangoAPI["Django REST API"]:::backend
        subgraph "Django Apps"
            Accounts["Accounts Service"]:::backend
            Customers["Customers Service"]:::backend
            ConfigAPI["Configuration API"]:::backend
            ProjectSvc["Project Service"]:::backend
            VulnSvc["Vulnerability Service"]:::backend
        end
        subgraph "Shared Utilities"
            S3Utils["S3 Storage Utils"]:::backend
            EmailUtil["Email Notification Utils"]:::backend
            TokenUtil["Token/OAuth Utils"]:::backend
        end
    end

    %% Worker Layer
    subgraph "Celery Worker"
        Celery["Celery Worker"]:::backend
    end

    %% Data Stores
    subgraph "Data Stores"
        Postgres["PostgreSQL"]:::datastore
        Redis["Redis (Broker)"]:::datastore
        S3["AWS S3"]:::datastore
    end

    %% External Services
    subgraph "External Services"
        SMTP["SMTP Email Service"]:::external
    end

    %% Deployment
    subgraph "Deployment & CI/CD"
        DockerCompose["docker-compose.yml"]:::deployment
        FrontendDocker["Dockerfile_frontend"]:::deployment
        BackendDocker["Dockerfile_API"]:::deployment
        CICD["CI/CD Workflows"]:::deployment
    end

    %% Connections
    Browser -->|"HTTPS/JSON"| Nginx
    Nginx -->|"serves static"| React
    React -->|"HTTPS/JSON"| DjangoAPI
    DjangoAPI -->|"SQL/CRUD"| Postgres
    DjangoAPI -->|"AMQP tasks"| Redis
    DjangoAPI -->|"uses"| Accounts
    DjangoAPI -->|"uses"| Customers
    DjangoAPI -->|"uses"| ConfigAPI
    DjangoAPI -->|"uses"| ProjectSvc
    DjangoAPI -->|"uses"| VulnSvc
    DjangoAPI -->|"imports"| S3Utils
    DjangoAPI -->|"imports"| EmailUtil
    DjangoAPI -->|"imports"| TokenUtil
    Celery -->|"AMQP tasks"| Redis
    Celery -->|"SQL update"| Postgres
    Celery -->|"store reports"| S3
    Celery -->|"send emails"| SMTP
    DockerCompose --> React
    DockerCompose --> DjangoAPI
    DockerCompose --> Celery
    DockerCompose --> Postgres
    DockerCompose --> Redis

    %% Click Events
    click React "https://github.com/aptrs/aptrs/tree/main/frontend/"
    click Nginx "https://github.com/aptrs/aptrs/blob/main/frontend/nginx.conf"
    click FrontendDocker "https://github.com/aptrs/aptrs/tree/main/docker/Dockerfile_frontend"
    click CICD "https://github.com/aptrs/aptrs/tree/main/.github/workflows/"
    click DockerCompose "https://github.com/aptrs/aptrs/blob/main/docker-compose.yml"
    click DjangoAPI "https://github.com/aptrs/aptrs/blob/main/APTRS/APTRS/settings.py"
    click Celery "https://github.com/aptrs/aptrs/blob/main/APTRS/APTRS/celery.py"
    click Accounts "https://github.com/aptrs/aptrs/tree/main/APTRS/accounts/"
    click Customers "https://github.com/aptrs/aptrs/tree/main/APTRS/customers/"
    click ConfigAPI "https://github.com/aptrs/aptrs/tree/main/APTRS/configapi/"
    click ProjectSvc "https://github.com/aptrs/aptrs/tree/main/APTRS/project/"
    click VulnSvc "https://github.com/aptrs/aptrs/tree/main/APTRS/vulnerability/"
    click S3Utils "https://github.com/aptrs/aptrs/blob/main/APTRS/utils/s3_utils.py"
    click EmailUtil "https://github.com/aptrs/aptrs/blob/main/APTRS/utils/email_notification.py"
    click TokenUtil "https://github.com/aptrs/aptrs/blob/main/APTRS/utils/token.py"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#333,stroke-width:1px
    classDef backend fill:#D0FFD0,stroke:#333,stroke-width:1px
    classDef datastore fill:#FFF1A8,stroke:#333,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#333,stroke-width:1px
    classDef deployment fill:#ECECEC,stroke:#333,stroke-width:1px
```
