# mozilla/addons-server architecture

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

- Interactive diagram: https://gitdiagram.com/mozilla/addons-server
- Repository: https://github.com/mozilla/addons-server

## Overview

##### Main Components

a. Frontend Layer:
- Static content (CSS, JavaScript, images)
- Templates (Jinja2-based templates in various app directories)
- Frontend assets management system

b. Backend Layer:
- Django web application
- Multiple Django apps (addons, users, versions, reviews, etc.)
- API endpoints (REST framework)
- Authentication system (FxA integration)

c. Database Layer:
- MySQL database (indicated by mysql.gpg.asc in docker/)
- Search functionality (Elasticsearch, indicated by lib/es/)

d. Services Layer:
- NGINX web server (docker/nginx/)
- uWSGI application server (docker/uwsgi.ini)
- Celery task queue (indicated by celery.py)

##### Key Architectural Patterns

a. Django MVT (Model-View-Template) architecture:
- Models (*/models.py files)
- Views (*/views.py files)
- Templates (*/templates directories)

b. Service-oriented components:
- -on validation service
- File handling service
- Signing service
- Review system

##### Integration Points

Connections for:
- External authentication (FxA)
- CDN for static files
- Remote Settings integration
- API endpoints for external consumers

##### Specific Implementation Details

Specialized components:
- Blocklist management
- Version control (Git integration)
- Internationalization system
- Security scanning system

**[Client Layer]**
- ↓ ↑
**[Load Balancer/NGINX]**
- ↓ ↑
**[Application Layer (uWSGI)]**
- ↓ ↑
**[Django Apps Layer]**
- ↓ ↑
**[Service Layer]**
- ↓ ↑
**[Data Layer]**

- Blue: Core application components
- Green: External services
- Yellow: Security components
- Gray: Infrastructure components
- Red: Critical paths/components

Specific elements:
##### Async task processing

Key considerations:
- Security components due to the sensitive nature of add-on distribution
- Scalability points
- Monitoring and logging components
- API versioning structure

- High-level architecture for overall understanding
- Sufficient detail for implementation guidance
- Security considerations for add-on validation
- Integration points with Mozilla services

This system design should reflect the complex nature of the add-ons ecosystem while maintaining clarity about the separation of concerns and security boundaries.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Browser["Web Browser"]
        APIClient["API Clients"]
    end

    subgraph LoadBalancer
        NGINX["NGINX Server"]:::infra
    end

    subgraph AppServer
        uWSGI["uWSGI Server"]:::infra
        Celery["Celery Tasks"]:::service
    end

    subgraph DjangoApps
        Core["Core Application"]:::core
        Addons["Add-ons Management"]:::core
        Users["User Management"]:::core
        API["API Framework"]:::core
        Auth["Authentication"]:::security
        DevHub["Developer Hub"]:::core
        Files["File Handling"]:::core
        Signing["Signing Service"]:::security
        Reviews["Review System"]:::core
        Blocklist["Blocklist Management"]:::security
        I18n["Internationalization"]:::core
        Versions["Version Management"]:::core
        Stats["Statistics"]:::core
    end

    subgraph Frontend
        Static["Static Assets"]:::frontend
        Templates["Templates"]:::frontend
        FrontendBuild["Frontend Build"]:::frontend
    end

    subgraph DataLayer
        MySQL[(MySQL Database)]:::data
        ES[(Elasticsearch)]:::data
        Cache[(Cache Layer)]:::data
    end

    subgraph ExternalServices
        FxA["Firefox Accounts"]:::external
        CDN["CDN"]:::external
        RemoteSettings["Remote Settings"]:::external
    end

    Browser --> NGINX
    APIClient --> NGINX
    NGINX --> uWSGI
    uWSGI --> Core
    Core --> Celery
    
    Core --> |Manages|Addons
    Core --> |Manages|Users
    Core --> |Manages|API
    Core --> |Manages|Auth
    
    Auth --> FxA
    Static --> CDN
    Core --> RemoteSettings
    
    DevHub --> Files
    Files --> Signing
    Addons --> Reviews
    Reviews --> Blocklist
    
    Core --> MySQL
    Core --> ES
    Core --> Cache
    
    Static --> Templates
    Static --> FrontendBuild

    %% Click events for component mapping
    click Static "https://github.com/mozilla/addons-server/tree/master//static/"
    click Templates "https://github.com/mozilla/addons-server/tree/master//src/olympia/templates/"
    click FrontendBuild "https://github.com/mozilla/addons-server/tree/master//static/css/node_lib/"
    click Core "https://github.com/mozilla/addons-server/tree/master//src/olympia/amo/"
    click Addons "https://github.com/mozilla/addons-server/tree/master//src/olympia/addons/"
    click Users "https://github.com/mozilla/addons-server/tree/master//src/olympia/users/"
    click API "https://github.com/mozilla/addons-server/tree/master//src/olympia/api/"
    click Auth "https://github.com/mozilla/addons-server/tree/master//src/olympia/accounts/"
    click NGINX "https://github.com/mozilla/addons-server/tree/master//docker/nginx/"
    click uWSGI "https://github.com/mozilla/addons-server/blob/master//docker/uwsgi.ini"
    click Celery "https://github.com/mozilla/addons-server/blob/master//src/olympia/amo/celery.py"
    click DevHub "https://github.com/mozilla/addons-server/tree/master//src/olympia/devhub/"
    click Files "https://github.com/mozilla/addons-server/tree/master//src/olympia/files/"
    click Signing "https://github.com/mozilla/addons-server/tree/master//src/olympia/signing/"
    click Reviews "https://github.com/mozilla/addons-server/tree/master//src/olympia/reviewers/"
    click Blocklist "https://github.com/mozilla/addons-server/tree/master//src/olympia/blocklist/"
    click I18n "https://github.com/mozilla/addons-server/tree/master//src/olympia/translations/"
    click Versions "https://github.com/mozilla/addons-server/tree/master//src/olympia/versions/"
    click Stats "https://github.com/mozilla/addons-server/tree/master//src/olympia/stats/"

    classDef core fill:#2b67a4,color:white
    classDef frontend fill:#42b983,color:white
    classDef security fill:#e6b800,color:black
    classDef service fill:#6b4fbb,color:white
    classDef data fill:#666666,color:white
    classDef external fill:#00cc66,color:white
    classDef infra fill:#435761,color:white
```
