# tjcsl/tin architecture

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

- Interactive diagram: https://gitdiagram.com/tjcsl/tin
- Repository: https://github.com/tjcsl/tin

## Overview

##### Main System Components

a) Web Application Layer (Django)
- Core application with multiple Django apps (assignments, courses, submissions, users, venvs)
- Authentication system (OAuth support)
- Admin interface
- Template-based frontend

b) Task Processing Layer
- Celery worker system
- RabbitMQ message broker
- Task queues for grading submissions

c) Database Layer
- PostgreSQL (primary database)
- SQLite (secondary database)

d) Sandboxing System
- Container management for running student code
- Isolation mechanisms
- Network access controls

##### Component Relationships

**[Web Browsers] ←→ [Django Web Server]**
- ↑↓
- [Database]
- ↑↓
**[RabbitMQ] ←→ [Celery Workers] ←→ [Container Runtime]**

##### Detailed Component Breakdown

a) Django Apps (show as interconnected modules):
- Assignments (managing assignments and grading criteria)
- Submissions (handling student code submissions)
- Courses (course management and organization)
- Users (user management and permissions)
- VEnvs (virtual environment management)

b) Security Layer:
- Sandboxing mechanism
- Container isolation
- Network access controls
- Permission management

##### Data Flow Indicators

Key flows:
##### Student submission path
Browser → Django → Database → Message Queue → Celery → Container → Results
##### Teacher grading path
Browser → Django → Assignment Configuration → Database
##### Authentication flow
Browser → OAuth → Django → User Session

##### Technical Details

Annotations for:
- Python/Django backend
- Celery task queue
- PostgreSQL/SQLite databases
- Container runtime
- Static file handling
- Template rendering system

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Web Layer"
        Browser["Web Browser"]
        WebServer["Django Web Server"]:::web
        click WebServer "https://github.com/tjcsl/tin/blob/master/tin/wsgi.py"
        
        subgraph "Django Apps"
            Assignments["Assignments"]:::app
            click Assignments "https://github.com/tjcsl/tin/tree/master/tin/apps/assignments/"
            Courses["Courses"]:::app
            click Courses "https://github.com/tjcsl/tin/tree/master/tin/apps/courses/"
            Submissions["Submissions"]:::app
            click Submissions "https://github.com/tjcsl/tin/tree/master/tin/apps/submissions/"
            Users["Users"]:::app
            click Users "https://github.com/tjcsl/tin/tree/master/tin/apps/users/"
            VEnvs["Virtual Environments"]:::app
            click VEnvs "https://github.com/tjcsl/tin/tree/master/tin/apps/venvs/"
        end
        
        subgraph "Frontend"
            Templates["Templates"]:::frontend
            click Templates "https://github.com/tjcsl/tin/tree/master/tin/templates/"
            Static["Static Files"]:::frontend
            click Static "https://github.com/tjcsl/tin/tree/master/tin/static/"
        end
        
        Auth["Authentication"]:::security
        click Auth "https://github.com/tjcsl/tin/tree/master/tin/apps/auth/"
    end
    
    subgraph "Task Processing"
        RabbitMQ["RabbitMQ"]:::queue
        CeleryWorkers["Celery Workers"]:::worker
        click CeleryWorkers "https://github.com/tjcsl/tin/blob/master/tin/celery.py"
        AssignmentTasks["Assignment Tasks"]:::task
        click AssignmentTasks "https://github.com/tjcsl/tin/blob/master/tin/apps/assignments/tasks.py"
        SubmissionTasks["Submission Tasks"]:::task
        click SubmissionTasks "https://github.com/tjcsl/tin/blob/master/tin/apps/submissions/tasks.py"
        VEnvTasks["VEnv Tasks"]:::task
        click VEnvTasks "https://github.com/tjcsl/tin/blob/master/tin/apps/venvs/tasks.py"
    end
    
    subgraph "Database Layer"
        PostgreSQL["PostgreSQL"]:::db
        SQLite["SQLite"]:::db
    end
    
    subgraph "Security Layer"
        Sandbox["Sandbox System"]:::security
        click Sandbox "https://github.com/tjcsl/tin/blob/master/tin/sandboxing.py"
        Container["Container Runtime"]:::security
    end
    
    Browser --> WebServer
    WebServer --> Auth
    Auth --> Users
    
    WebServer --> Assignments
    WebServer --> Courses
    WebServer --> Submissions
    WebServer --> VEnvs
    WebServer --> Templates
    WebServer --> Static
    
    Assignments --> PostgreSQL
    Courses --> PostgreSQL
    Submissions --> PostgreSQL
    Users --> PostgreSQL
    VEnvs --> PostgreSQL
    
    Submissions --> RabbitMQ
    RabbitMQ --> CeleryWorkers
    
    CeleryWorkers --> AssignmentTasks
    CeleryWorkers --> SubmissionTasks
    CeleryWorkers --> VEnvTasks
    
    AssignmentTasks --> Container
    SubmissionTasks --> Container
    VEnvTasks --> Container
    
    Container --> Sandbox
    
    %% Styling
    classDef web fill:#3498db
    classDef app fill:#2ecc71
    classDef frontend fill:#9b59b6
    classDef security fill:#e74c3c
    classDef queue fill:#f39c12
    classDef worker fill:#d35400
    classDef task fill:#e67e22
    classDef db fill:#16a085
    
    %% Legend
    subgraph Legend
        L1["Web Components"]:::web
        L2["Django Apps"]:::app
        L3["Frontend"]:::frontend
        L4["Security"]:::security
        L5["Message Queue"]:::queue
        L6["Workers"]:::worker
        L7["Tasks"]:::task
        L8["Database"]:::db
    end
```
