# nathanvogel/deepmaps architecture

> Architecture diagram of the GitHub repository nathanvogel/deepmaps, 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/nathanvogel/deepmaps
- Repository: https://github.com/nathanvogel/deepmaps

## Overview

##### Main Components Identification

a. Browser Extension (Firefox)
- Style Transfer Component (browser-based)
- Request Interceptor
- UI Components (options, controls)

b. Local Server
- Model Wrapper
- Image Processing Pipeline
- HTTP Server Interface

c. Machine Learning Models
- CycleGAN Model
- Style Transfer Model
- Model Resources (weights, variables)

**[Browser/Extension] <---> [Local Server] <---> [ML Models]**

##### Data Flow Indicators

- Original map tile requests (OpenStreetMap → Extension)
- Intercepted requests (Extension → Local Server)
- Model processing flow (Server → ML Models)
- Styled map tiles (Server → Extension → Browser)

##### Implementation Details

Technical notes for:
- Python-based server implementation
- PyTorch ML framework
- Firefox WebExtension APIs
- Image processing pipeline

##### External Dependencies

Connections to:
- OpenStreetMap tile server
- Model weight files
- Training datasets

This system design should emphasize:
##### The data flow between components

This will provide a clear understanding of how the system transforms standard map tiles into stylized versions while maintaining the interactive nature of web mapping.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Browser
        FE[Firefox Extension]
        UI[UI Components]
        ST[Style Transfer Engine]
        RS[Request Scraper]
        SI[Style Injection Module]
        
        FE --> UI
        FE --> ST
        FE --> RS
        FE --> SI
    end

    subgraph Server
        LS[Local Server]
        MW[Model Wrapper]
        IPP[Image Processing Pipeline]
        DH[Dataset Handlers]
        HTTP[HTTP Server :8080]
        
        LS --> HTTP
        LS --> MW
        MW --> IPP
        MW --> DH
    end

    subgraph ML["ML Models"]
        CG[CycleGAN Model]
        STM[Style Transfer Model]
        MR[Model Resources]
        
        CG --> MR
        STM --> MR
    end

    OSM[("OpenStreetMap")]
    
    OSM -->|Map Tiles| RS
    RS -->|Intercepted Requests| HTTP
    HTTP -->|Processing Request| MW
    MW -->|Model Input| CG
    CG -->|Processed Output| MW
    MW -->|Styled Tiles| HTTP
    HTTP -->|Return Styled Tiles| SI
    SI -->|Display| FE

    classDef browser fill:#a8d1f0,stroke:#333,stroke-width:2px
    classDef server fill:#90EE90,stroke:#333,stroke-width:2px
    classDef ml fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:2px
    classDef dataflow fill:#FFA500,stroke:#333,stroke-width:2px

    class FE,UI,ST,RS,SI browser
    class LS,MW,IPP,DH,HTTP server
    class CG,STM,MR ml
    class OSM external

    click FE "https://github.com/nathanvogel/DeepMaps/tree/master/extensions/DeepMaps/"
    click RS "https://github.com/nathanvogel/DeepMaps/blob/master/extensions/DeepMaps/background.js"
    click ST "https://github.com/nathanvogel/DeepMaps/blob/master/extensions/DeepMaps/styleTransfer.js"
    click UI "https://github.com/nathanvogel/DeepMaps/blob/master/extensions/DeepMaps/options.html"
    click LS "https://github.com/nathanvogel/DeepMaps/blob/master/server/servemaps.py"
    click MW "https://github.com/nathanvogel/DeepMaps/blob/master/server/modelwrapper.py"
    click IPP "https://github.com/nathanvogel/DeepMaps/blob/master/server/util/util.py"
    click CG "https://github.com/nathanvogel/DeepMaps/blob/master/server/models/cycle_gan_model.py"
    click STM "https://github.com/nathanvogel/DeepMaps/tree/master/extensions/DeepMaps/models/"
    click MR "https://github.com/nathanvogel/DeepMaps/tree/master/extensions/DeepMaps/models/oldmap01/"
    click DH "https://github.com/nathanvogel/DeepMaps/blob/master/server/data/aligned_dataset.py"

%% Legend
    subgraph Legend
        B[Browser Component]:::browser
        S[Server Component]:::server
        M[ML Component]:::ml
        E[External Service]:::external
        D[Data Flow]:::dataflow
    end
```
