# meizuflux/private-destination architecture

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

## Overview

##### Main Components

a) Frontend Layer:
- Static Assets (CSS/JS)
- Jinja2 Templates
- Client-side TypeScript/JavaScript
- Organization into different sections (dashboard, admin, errors)

b) Backend Layer:
- Flask Application Structure
- Blueprints Architecture
- Models Layer
- Utils/Helpers
- Authentication System

c) Database Layer:
- PostgreSQL Database
- Migration System

##### Core Application Structure
**[Client Browser] → [Nginx (Production)] → [Flask Application]**
- ↓
- [Blueprint Router]
- ↓
- [Database] ← [Models] ← [Controllers (Blueprints)] → [Templates]

- Admin Blueprint (Purple)
- Users Management
- Application Management
- Dashboard Blueprint (Blue)
- Notes Management
- URL Shortener
- Settings
- Auth Blueprint (Red)
- Authentication
- Session Management

##### Utility Services (Green)
- Database Utilities
- Authentication Utilities
- Form Handling
- Time Utilities
- Shortener Logic

##### Data Flow Patterns
- HTTP request flow
- Template rendering process
- Database interactions
- Authentication flow

Key Visualization Guidelines:

##### Specific features
- URL shortening flow
- Notes management system
- User authentication process
- Admin management interface
- Static asset handling

##### Security Layer
- Authentication flow
- Admin access control
- API key management
- Password handling

##### Database Interactions
- Migration system
- Model relationships
- Data access patterns

##### Frontend Architecture
- Static asset compilation
- Template inheritance
- JavaScript/TypeScript integration

##### Development Tools
- Docker development environment
- Build scripts
- Migration tools

Remember to:
- Notes for future planned features
- Document the development environment setup

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Browser["Web Browser"]:::client
    end

    subgraph "Frontend Layer"
        StaticAssets["Static Assets"]:::frontend
        Templates["Templates"]:::frontend
        ClientJS["TypeScript/JavaScript"]:::frontend
        ErrorPages["Error Pages"]:::frontend
    end

    subgraph "Application Layer"
        Flask["Flask Application"]:::core
        Router["Blueprint Router"]:::core

        subgraph "Blueprints"
            AdminBP["Admin Blueprint"]:::admin
            DashboardBP["Dashboard Blueprint"]:::dashboard
            AuthBP["Auth Blueprint"]:::auth
        end

        subgraph "Features"
            Notes["Notes Management"]:::feature
            URLShortener["URL Shortener"]:::feature
            Settings["Settings"]:::feature
            UserMgmt["User Management"]:::feature
            AppMgmt["App Management"]:::feature
        end

        subgraph "Utils"
            DBUtils["Database Utils"]:::util
            AuthUtils["Auth Utils"]:::util
            FormUtils["Form Utils"]:::util
            TimeUtils["Time Utils"]:::util
            ShortenerUtils["Shortener Utils"]:::util
        end

        subgraph "Models"
            AuthModel["Auth Model"]:::model
            ShortenerModel["Shortener Model"]:::model
        end
    end

    subgraph "Database Layer"
        PostgreSQL[(PostgreSQL)]:::database
        Migrations["Migrations"]:::database
    end

    %% Connections
    Browser --> Flask
    Flask --> Router
    Router --> AdminBP & DashboardBP & AuthBP
    
    AdminBP --> UserMgmt & AppMgmt
    DashboardBP --> Notes & URLShortener & Settings
    AuthBP --> AuthUtils
    
    Notes & URLShortener & Settings --> Templates
    UserMgmt & AppMgmt --> Templates
    
    AuthModel & ShortenerModel --> PostgreSQL
    Migrations --> PostgreSQL
    
    DBUtils --> PostgreSQL
    AuthUtils --> AuthModel
    ShortenerUtils --> ShortenerModel
    
    %% Click Events
    click StaticAssets "https://github.com/meizuflux/private-destination/tree/master//static"
    click Templates "https://github.com/meizuflux/private-destination/tree/master//templates"
    click ClientJS "https://github.com/meizuflux/private-destination/tree/master//static/js"
    click ErrorPages "https://github.com/meizuflux/private-destination/tree/master//templates/errors"
    click AdminBP "https://github.com/meizuflux/private-destination/tree/master//app/blueprints/admin"
    click DashboardBP "https://github.com/meizuflux/private-destination/tree/master//app/blueprints/dashboard"
    click AuthBP "https://github.com/meizuflux/private-destination/blob/master//app/blueprints/auth.py"
    click AuthModel "https://github.com/meizuflux/private-destination/blob/master//app/models/auth.py"
    click ShortenerModel "https://github.com/meizuflux/private-destination/blob/master//app/models/shortener.py"
    click DBUtils "https://github.com/meizuflux/private-destination/blob/master//app/utils/db.py"
    click AuthUtils "https://github.com/meizuflux/private-destination/blob/master//app/utils/auth.py"
    click FormUtils "https://github.com/meizuflux/private-destination/blob/master//app/utils/forms.py"
    click TimeUtils "https://github.com/meizuflux/private-destination/blob/master//app/utils/time.py"
    click ShortenerUtils "https://github.com/meizuflux/private-destination/blob/master//app/utils/shortener.py"
    click Migrations "https://github.com/meizuflux/private-destination/tree/master//migrations"
    click URLShortener "https://github.com/meizuflux/private-destination/blob/master//app/blueprints/dashboard/shortener.py"
    click Notes "https://github.com/meizuflux/private-destination/blob/master//app/blueprints/dashboard/notes.py"
    click Settings "https://github.com/meizuflux/private-destination/blob/master//app/blueprints/dashboard/settings.py"
    click Flask "https://github.com/meizuflux/private-destination/blob/master//app/__init__.py"
    
    %% Styling
    classDef client fill:#f9f,stroke:#333
    classDef frontend fill:#aaf,stroke:#333
    classDef core fill:#ffa,stroke:#333
    classDef admin fill:#c9f,stroke:#333
    classDef dashboard fill:#9cf,stroke:#333
    classDef auth fill:#f99,stroke:#333
    classDef feature fill:#9f9,stroke:#333
    classDef util fill:#9f9,stroke:#333
    classDef model fill:#f90,stroke:#333
    classDef database fill:#ff9,stroke:#333
```
