# richbs/colourlens architecture

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

- Interactive diagram: https://gitdiagram.com/richbs/colourlens
- Repository: https://github.com/richbs/colourlens

## Overview

##### Main Components

A. Web Application Layer (Django)
- Primary Components:
- colourlens (Main Django App)
- coloursite (Project Configuration)

B. Data Processing Layer
- Management Commands
- Data Migration Tools

C. External Integrations
- Museum APIs (Harvard, etc.)
- Image Processing Services

D. Storage Layer
- SQLite Database (as seen in db.sqlite3)
- Static File Storage

**┌─────────────────────────────────────────────────┐**
- Client Browser                   │
- ┘
- ↕ HTTP
**┌─────────────────────────────────────────────────┐**
- Django Application               │
- ┌─────────────┐  ┌─────────────┐  ┌─────────┐ │
- Views     │  │    URLs     │  │ Models  │ │
- ┘  └─────────────┘  └─────────┘ │
- ┘
- ↕
**┌─────────────────────────────────────────────────┐**
- ┌─────────────┐  ┌─────────────────────────┐  │
- ┘  └─────────────────────────┘  │
- ┘
- ↕                    ↕
**┌─────────────┐    ┌─────────────────────────────┐**
- Database   │    │     External Museum APIs     │
- ┘    └─────────────────────────────┘

##### Important Elements to Highlight

a. Request Flow:
- How user requests flow from browser through Django's URL routing to views
- Data flow between components

b. Key Processing Points:
- API integration points
- Data storage and retrieval paths

##### Technical Details

- Django MVT (Model-View-Template) pattern
- Image processing dependencies (libjpeg-dev)
- Virtual environment setup
- Database connections
- API authentication points

##### Deployment Notes
Different deployment configurations:
- Development (local)
- Production (webfaction)
- Gondolin deployment

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]
    end

    subgraph "Django Application"
        Settings["Django Settings"]:::config
        URLs["URL Router"]:::core
        Views["Views Layer"]:::core
        Models["Data Models"]:::core
        Templates["Template System"]:::ui
        Static["Static Files"]:::ui
        Utils["Utility Functions"]:::core
    end

    subgraph "Processing Layer"
        ColorAnalysis["Color Analysis System"]:::processing
        DataMigration["Data Migration Tool"]:::processing
        Tests["Test Suite"]:::testing
    end

    subgraph "External Layer"
        MuseumAPI["Museum APIs"]:::external
    end

    subgraph "Storage Layer"
        DB[(Database)]:::storage
        StaticStorage["Static Storage"]:::storage
    end

    subgraph "Deployment Configurations"
        WSGI["WSGI Config"]:::deploy
        WebFaction["Webfaction Settings"]:::deploy
        Gondolin["Gondolin Settings"]:::deploy
    end

    Browser --> URLs
    URLs --> Views
    Views --> Models
    Views --> Templates
    Templates --> Static
    Models --> DB
    Views --> ColorAnalysis
    Views --> Utils
    ColorAnalysis --> StaticStorage
    Views --> MuseumAPI
    DataMigration --> DB
    Settings --> DB
    Settings --> WSGI
    Settings --> WebFaction
    Settings --> Gondolin

    %% Click Events
    click Settings "https://github.com/richbs/colourlens/blob/master/coloursite/settings.py"
    click Views "https://github.com/richbs/colourlens/blob/master/colourlens/views.py"
    click URLs "https://github.com/richbs/colourlens/blob/master/colourlens/urls.py"
    click Models "https://github.com/richbs/colourlens/blob/master/colourlens/models.py"
    click ColorAnalysis "https://github.com/richbs/colourlens/blob/master/colourlens/management/commands/imagecolour.py"
    click DataMigration "https://github.com/richbs/colourlens/blob/master/colourlens/management/commands/mongomigrate.py"
    click DB "https://github.com/richbs/colourlens/blob/master/coloursite/db.sqlite3"
    click Templates "https://github.com/richbs/colourlens/tree/master/colourlens/templates"
    click Static "https://github.com/richbs/colourlens/tree/master/colourlens/static"
    click Utils "https://github.com/richbs/colourlens/blob/master/colourlens/utils.py"
    click WSGI "https://github.com/richbs/colourlens/blob/master/coloursite/wsgi.py"
    click WebFaction "https://github.com/richbs/colourlens/blob/master/coloursite/settings_webfaction.py"
    click Gondolin "https://github.com/richbs/colourlens/blob/master/coloursite/settings_gondolin.py"
    click Tests "https://github.com/richbs/colourlens/blob/master/colourlens/tests.py"

    %% Styling
    classDef core fill:#2374ab
    classDef ui fill:#7785ac
    classDef config fill:#5603ad
    classDef processing fill:#8ac926
    classDef storage fill:#ffba08
    classDef external fill:#d62828
    classDef deploy fill:#073b4c
    classDef testing fill:#ff477e

    %% Legend
    subgraph Legend
        CoreComp["Core Components"]:::core
        UIComp["UI Components"]:::ui
        ConfigComp["Configuration"]:::config
        ProcessComp["Processing"]:::processing
        StorageComp["Storage"]:::storage
        ExtComp["External Services"]:::external
        DeployComp["Deployment"]:::deploy
        TestComp["Testing"]:::testing
    end
```
