# thibmaek/instagramtomealie architecture

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

- Interactive diagram: https://gitdiagram.com/thibmaek/instagramtomealie
- Repository: https://github.com/thibmaek/instagramtomealie

## Overview

##### Main Components

a. Client Layer:
- Web Browser Interface (represented by templates/index.html)
- HTTP Endpoint for direct API calls

b. Application Layer:
- Flask Web Server (main.py)
- Instagram Integration Service (helpers/instadownloader.py)
- Mealie API Integration Service (helpers/mealie_api.py)
- Instagram Authentication Service (helpers/instaloader_login_helper.py)

c. External Services:
- Instagram Platform
- Mealie Server (with OpenAI/Ollama integration)
- Docker Container Environment

**┌─ Client Tier ─────────────────────┐**
- Web Browser                     │
- HTTP API Endpoint              │
- ┬──────────────────┘
- ↓
**┌─ Application Tier ────────────────┐**
- ┌─ Flask Web Server ────────────┐ │
- Route Handlers              │ │
- Request Processing          │ │
- ┘ │
- ┌─ Service Layer ──────────────┐ │
- Instagram Downloader       │ │
- Mealie API Client         │ │
- Authentication Handler     │ │
- ┘ │
- ┬────────────┬─────────┘
- ↓            ↓
**┌─ External Services ───────────────┐**
- Instagram Platform             │
- Mealie Server                  │
- OpenAI/Ollama Integration   │
- ┘

##### Key Flows to Highlight

a. Authentication Flow:
- Instagram session file or credentials → Authentication Handler
- Mealie API key validation

b. Main Application Flow:

##### Important Details

- Docker container boundary
- Environment variable configuration points
- Volume mount for Instagram session file
- Port mappings (9001)
- Dependencies between services

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef client fill:#a8d1f0,stroke:#000
    classDef app fill:#90EE90,stroke:#000
    classDef external fill:#FFB347,stroke:#000
    classDef container fill:#E6E6FA,stroke:#000,stroke-dasharray: 5 5
    
    %% Client Layer
    subgraph ClientLayer
        Browser["Web Browser Interface"]:::client
        API["HTTP API Endpoint"]:::client
    end
    
    %% Application Layer
    subgraph AppContainer["Docker Container"]
        subgraph AppServer["Flask Web Server"]
            Routes["Route Handlers"]:::app
            RequestProc["Request Processing"]:::app
        end
        
        subgraph Services["Service Layer"]
            InstaDown["Instagram Downloader"]:::app
            MealieClient["Mealie API Client"]:::app
            AuthHandler["Authentication Handler"]:::app
        end
        
        Config["Environment Config"]:::app
    end
    
    %% External Services
    subgraph ExternalServices["External Services"]
        Instagram["Instagram Platform"]:::external
        MealieServer["Mealie Server"]:::external
        AI["OpenAI/Ollama Integration"]:::external
    end
    
    %% Relationships
    Browser --> Routes
    API --> Routes
    Routes --> RequestProc
    RequestProc --> InstaDown
    RequestProc --> MealieClient
    RequestProc --> AuthHandler
    InstaDown --> Instagram
    MealieClient --> MealieServer
    MealieServer --> AI
    AuthHandler --> Instagram
    Config --> Services
    
    %% Click events for component mapping
    click Browser "https://github.com/thibmaek/InstagramToMealie/blob/main/templates/index.html"
    click Routes "https://github.com/thibmaek/InstagramToMealie/blob/main/main.py"
    click InstaDown "https://github.com/thibmaek/InstagramToMealie/blob/main/helpers/instadownloader.py"
    click MealieClient "https://github.com/thibmaek/InstagramToMealie/blob/main/helpers/mealie_api.py"
    click AuthHandler "https://github.com/thibmaek/InstagramToMealie/blob/main/helpers/instaloader_login_helper.py"
    click AppContainer "https://github.com/thibmaek/InstagramToMealie/tree/main/Dockerfile"
    click Config "https://github.com/thibmaek/InstagramToMealie/blob/main/compose.example.yaml"
    
    %% Legend
    subgraph Legend
        Client["Client Component"]:::client
        AppComp["Application Component"]:::app
        ExtService["External Service"]:::external
    end
```
