# kykim88/sqlalchemy-filters architecture

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

- Interactive diagram: https://gitdiagram.com/kykim88/sqlalchemy-filters
- Repository: https://github.com/kykim88/sqlalchemy-filters

## Overview

##### Main Components

a. Core Components:
- Filters Module
- Sorting Module
- Pagination Module
- Loads Module
- Models Integration Layer
- Exceptions Handler

b. External Dependencies:
- SQLAlchemy ORM
- Supported Databases (SQLite, MySQL, PostgreSQL)

**┌─────────────────────────────────────────────────────────┐**
- Client Application                      │
- ┬─────────────────────────────────────┘
- ↓
**┌─────────────────────────────────────────────────────────┐**
- SQLAlchemy Filters                         │
- ┌───────────┐ ┌──────────┐ ┌───────────┐ ┌─────────┐  │
- Filters  │ │  Sorting │ │Pagination │ │  Loads  │  │
- ┘ └──────────┘ └───────────┘ └─────────┘  │
- ┌─────────────────────────┐                    │
- Models Integration   │                    │
- ┘                    │
- ┬─────────────────────────────────────┘
- ↓
**┌─────────────────────────────────────────────────────────┐**
- SQLAlchemy ORM                       │
- ┬─────────────────────────────────────┘
- ↓
**┌─────────────────────────────────────────────────────────┐**
- Database Engines                           │
- ┌─────────┐   ┌─────────┐   ┌──────────────┐       │
- SQLite  │   │  MySQL  │   │  PostgreSQL  │       │
- ┘   └─────────┘   └──────────────┘       │
- ┘

##### Component Interactions

- Client applications making requests to SQLAlchemy Filters
- Filters/Sorting/Pagination/Loads components interacting with Models Integration
- Models Integration interfacing with SQLAlchemy ORM
- SQLAlchemy ORM connecting to database engines

##### Additional Elements

- Operation types (filtering, sorting, pagination, loads)
- Supported operators (is_null, is_not_null, ==, !=, etc.)
- Database support indicators
- SQLAlchemy version compatibility (1.0 - 1.4)

##### Implementation Details

Filters:
- Boolean operations (and, or, not)
- Field filtering
- Hybrid attribute support

Sorting:
- Multi-field sorting
- Direction control
- Nulls handling

Pagination:
- Page size
- Page number
- Total results
- Number of pages

Loads:
- Field selection
- Deferred loading
- Join handling

##### Notes
- Use consistent styling
- Version compatibility information
- Clear data flow directions
- Automatic join capability
- Where error handling occurs

Remember to include a note about the project's primary purpose: "Designed to expose SQLAlchemy query filtering, sorting, and pagination operations over REST APIs."

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Application"]
        CA[Client Application]
    end

    subgraph SQLFilters["SQLAlchemy Filters"]
        subgraph CoreModules["Core Components"]
            FM["Filters Module"]:::core
            SM["Sorting Module"]:::core
            PM["Pagination Module"]:::core
            LM["Loads Module"]:::core
        end
        
        subgraph Integration["Integration Layer"]
            MI["Models Integration"]:::core
            EH["Exceptions Handler"]:::core
        end
    end

    subgraph ORM["SQLAlchemy ORM"]
        SQLA["SQLAlchemy ORM Layer"]:::orm
    end

    subgraph DB["Database Engines"]
        SQLITE["SQLite"]:::db
        MYSQL["MySQL"]:::db
        PGSQL["PostgreSQL"]:::db
    end

    subgraph Features["Component Features"]
        subgraph FiltersFeatures["Filters"]
            FF1["Boolean Operations"]
            FF2["Field Filtering"]
            FF3["Hybrid Attributes"]
        end
        
        subgraph SortingFeatures["Sorting"]
            SF1["Multi-field Sorting"]
            SF2["Direction Control"]
            SF3["Nulls Handling"]
        end
        
        subgraph PaginationFeatures["Pagination"]
            PF1["Page Size"]
            PF2["Page Number"]
            PF3["Total Results"]
        end
        
        subgraph LoadsFeatures["Loads"]
            LF1["Field Selection"]
            LF2["Deferred Loading"]
            LF3["Join Handling"]
        end
    end

    CA --> FM & SM & PM & LM
    FM & SM & PM & LM --> MI
    MI --> SQLA
    SQLA --> SQLITE & MYSQL & PGSQL
    EH -.-> FM & SM & PM & LM

    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef orm fill:#2ecc71,stroke:#27ae60,color:white
    classDef db fill:#f1c40f,stroke:#f39c12,color:black
    classDef default fill:#ecf0f1,stroke:#bdc3c7,color:black

    click FM "https://github.com/kykim88/sqlalchemy-filters/blob/master/sqlalchemy_filters/filters.py"
    click SM "https://github.com/kykim88/sqlalchemy-filters/blob/master/sqlalchemy_filters/sorting.py"
    click PM "https://github.com/kykim88/sqlalchemy-filters/blob/master/sqlalchemy_filters/pagination.py"
    click LM "https://github.com/kykim88/sqlalchemy-filters/blob/master/sqlalchemy_filters/loads.py"
    click MI "https://github.com/kykim88/sqlalchemy-filters/blob/master/sqlalchemy_filters/models.py"
    click EH "https://github.com/kykim88/sqlalchemy-filters/blob/master/sqlalchemy_filters/exceptions.py"

    subgraph Legend["Legend"]
        L1["Core Components"]:::core
        L2["ORM Layer"]:::orm
        L3["Database Engines"]:::db
        L4["Features"]:::default
    end
```
