# bubblehouse/django-moo architecture

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

- Interactive diagram: https://gitdiagram.com/bubblehouse/django-moo
- Repository: https://github.com/bubblehouse/django-moo

## Overview

##### Main Components

a) Client Layer:
- SSH Client Interface (Port 8022)
- Web Admin Interface (Django Admin)

b) Application Services:
- Web Server (Nginx)
- Application Server (uWSGI)
- Shell Server (SSH Service)
- Task Queue (Celery, indicated by celery.py)

c) Core Components:
- Authentication System
- Object System
- Verb System
- Parser
- Permission System
- Property System
- Task System

d) Data Layer:
- Database (Django ORM)

##### Key Architectural Elements

**[Client Layer]**

**[Web/Network Layer]**

**[Application Layer]**

**[Core Systems Layer]**

**[Data Layer]**

##### Important Relationships

- How the SSH and Web clients connect through their respective servers
- Relationship between core components:
- Objects → Properties
- Objects → Verbs
- Verbs → Parser
- All components → Permissions
- Task queue workflow for async operations

##### Implementation Details

- Django's MVT (Model-View-Template) architecture
- Celery task queue integration
- Authentication flow
- Command parsing pipeline
- Object inheritance system

##### Deployment Components

Docker containers (as shown in docker-compose.yml):
- Webapp container
- Shell container
- Nginx container
- Database container
- Celery worker container

For this specific project, focus on showing how traditional Django components integrate with MOO-specific features like the verb system and object hierarchy, as these are what make this project unique from a standard Django application.

Remember to include the async capabilities of the system, as indicated by the presence of Celery and async verb handlers in the codebase.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Clients
        SSH["SSH Client\n(Port 8022)"]:::client
        WebAdmin["Web Admin\nInterface"]:::client
    end

    subgraph "Web/Network Layer"
        NGINX["NGINX Server"]:::server
        UWSGI["uWSGI Server"]:::server
        SSHD["SSH Server"]:::server
    end

    subgraph "Application Layer"
        AuthSystem["Authentication\nSystem"]:::auth
        TaskQueue["Task Queue\n(Celery)"]:::queue
        ShellInterface["Shell Command\nInterface"]:::shell
    end

    subgraph "Core Systems"
        Parser["Command\nParser"]:::core
        Bootstrap["Bootstrap\nSystem"]:::core
        
        subgraph "Game Objects"
            ObjSystem["Object\nSystem"]:::game
            VerbSystem["Verb\nSystem"]:::game
            PropSystem["Property\nSystem"]:::game
            DefaultVerbs["Default Verb\nImplementations"]:::game
        end
        
        PermSystem["Permission\nSystem"]:::security
        TaskSystem["Task\nSystem"]:::core
    end

    subgraph "Data Layer"
        DB[(Database)]:::storage
    end

    %% Client Layer Connections
    SSH --> SSHD
    WebAdmin --> NGINX
    NGINX --> UWSGI

    %% Application Layer Connections
    SSHD --> ShellInterface
    SSHD --> AuthSystem
    UWSGI --> AuthSystem
    ShellInterface --> Parser
    
    %% Core System Connections
    Parser --> VerbSystem
    Parser --> ObjSystem
    ObjSystem --> PropSystem
    ObjSystem --> VerbSystem
    VerbSystem --> DefaultVerbs
    Bootstrap --> ObjSystem
    
    %% Security and Tasks
    PermSystem -.-> ObjSystem
    PermSystem -.-> VerbSystem
    PermSystem -.-> PropSystem
    TaskSystem --> TaskQueue
    
    %% Data Layer Connections
    ObjSystem --> DB
    VerbSystem --> DB
    PropSystem --> DB
    AuthSystem --> DB
    TaskSystem --> DB

    %% Click Events
    click SSH "https://github.com/bubblehouse/django-moo/blob/main/moo/shell/server.py"
    click WebAdmin "https://github.com/bubblehouse/django-moo/blob/main/moo/core/admin.py"
    click NGINX "https://github.com/bubblehouse/django-moo/blob/main/extras/nginx/nginx.conf"
    click UWSGI "https://github.com/bubblehouse/django-moo/blob/main/extras/uwsgi/uwsgi.ini"
    click TaskQueue "https://github.com/bubblehouse/django-moo/blob/main/moo/celery.py"
    click ObjSystem "https://github.com/bubblehouse/django-moo/blob/main/moo/core/models/object.py"
    click VerbSystem "https://github.com/bubblehouse/django-moo/blob/main/moo/core/models/verb.py"
    click Parser "https://github.com/bubblehouse/django-moo/blob/main/moo/core/parse.py"
    click PermSystem "https://github.com/bubblehouse/django-moo/blob/main/moo/core/models/acl.py"
    click PropSystem "https://github.com/bubblehouse/django-moo/blob/main/moo/core/models/property.py"
    click TaskSystem "https://github.com/bubblehouse/django-moo/blob/main/moo/core/models/task.py"
    click AuthSystem "https://github.com/bubblehouse/django-moo/blob/main/moo/core/models/auth.py"
    click Bootstrap "https://github.com/bubblehouse/django-moo/blob/main/moo/core/bootstrap/default.py"
    click ShellInterface "https://github.com/bubblehouse/django-moo/blob/main/moo/shell/prompt.py"
    click DefaultVerbs "https://github.com/bubblehouse/django-moo/tree/main/moo/core/bootstrap/default_verbs/"

    %% Styling
    classDef client fill:#6495ED,stroke:#333,stroke-width:2px
    classDef server fill:#90EE90,stroke:#333,stroke-width:2px
    classDef auth fill:#FFB6C1,stroke:#333,stroke-width:2px
    classDef queue fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef shell fill:#98FB98,stroke:#333,stroke-width:2px
    classDef core fill:#F0E68C,stroke:#333,stroke-width:2px
    classDef game fill:#FFA07A,stroke:#333,stroke-width:2px
    classDef security fill:#FF6B6B,stroke:#333,stroke-width:2px
    classDef storage fill:#A9A9A9,stroke:#333,stroke-width:2px
```
