# juleski/feather_simple_api architecture

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

- Interactive diagram: https://gitdiagram.com/juleski/feather_simple_api
- Repository: https://github.com/juleski/feather_simple_api

## Overview

##### Main System Components

a) API Layer
- Entry point through Flask application
- JWT Authentication system
- Route handlers and endpoints

b) Service Layer
- User management
- Authentication services
- Provider services
- Insurance recommendation logic

c) Data Layer
- PostgreSQL database (evident from docker-compose setup)
- Data Access Objects (DAOs)
- SQLAlchemy ORM integration

##### Architectural Patterns to Highlight

The project follows a clear layered architecture:
- Resource-based organization (users, providers, auth)
- DTO pattern for data transfer
- DAO pattern for database access
- Service layer for business logic

**Client Requests**
- ↓
**[API Layer]**
- Flask App (core/app.py)
- Route Handlers (core/routes.py)
- Error Handlers (core/error_handler.py)
- JWT Authentication (extensions/jwt_extended)
- ↓
**[Service Layer]**
- Auth Service (resources/auth)
- Users Service (resources/users)
- Providers Service (resources/providers)
- ↓
**[Data Access Layer]**
- Users DAO
- Providers DAO
- SQLAlchemy ORM
- ↓
**[Database]**
- PostgreSQL

##### Important Details

a) Extensions and Middleware:
- Flask-SQLAlchemy integration
- JWT Extended authentication
- Custom GUID type handling

b) Resource Components:
- Users management
- Provider management
- Authentication flow

c) Database Migrations:
- Alembic migration system
- Initial schema setup

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        CR[Client Requests]
    end

    subgraph "API Layer"
        FA[Flask Application]:::api
        RH[Route Handlers]:::api
        EH[Error Handlers]:::api
        
        subgraph "Authentication"
            JWT[JWT Authentication]:::auth
            AE[Auth Endpoints]:::api
            UE[User Endpoints]:::api
            SEC[Security Utils]:::auth
        end
    end

    subgraph "Service Layer"
        AS[Auth Service]:::service
        US[Users Service]:::service
        PS[Providers Service]:::service
    end

    subgraph "Data Transfer"
        UDTO[User DTOs]:::dto
        PDTO[Provider DTOs]:::dto
    end

    subgraph "Data Access Layer"
        UDAO[Users DAO]:::dao
        PDAO[Providers DAO]:::dao
        ORM[SQLAlchemy ORM]:::dao
    end

    subgraph "Database Layer"
        DB[(PostgreSQL)]:::db
        DBINIT[DB Initialization]:::db
        DBM[Database Migrations]:::db
    end

    %% Relationships
    CR --> FA
    FA --> RH
    FA --> EH
    FA --> JWT
    
    RH --> AE
    RH --> UE
    
    JWT --> SEC
    AE --> AS
    UE --> US
    
    AS --> UDTO
    US --> UDTO
    PS --> PDTO
    
    AS --> UDAO
    US --> UDAO
    PS --> PDAO
    
    UDAO --> ORM
    PDAO --> ORM
    
    ORM --> DB
    DBINIT --> DB
    DBM --> DB

    %% Click Events
    click FA "https://github.com/juleski/feather_simple_api/blob/main/feather_simple_api/core/app.py"
    click RH "https://github.com/juleski/feather_simple_api/blob/main/feather_simple_api/core/routes.py"
    click EH "https://github.com/juleski/feather_simple_api/blob/main/feather_simple_api/core/error_handler.py"
    click JWT "https://github.com/juleski/feather_simple_api/tree/main/feather_simple_api/extensions/jwt_extended/"
    click AS "https://github.com/juleski/feather_simple_api/blob/main/feather_simple_api/resources/auth/auth_service.py"
    click US "https://github.com/juleski/feather_simple_api/blob/main/feather_simple_api/resources/users/users_service.py"
    click UDAO "https://github.com/juleski/feather_simple_api/blob/main/feather_simple_api/resources/users/users_dao.py"
    click PDAO "https://github.com/juleski/feather_simple_api/blob/main/feather_simple_api/resources/providers/providers_dao.py"
    click ORM "https://github.com/juleski/feather_simple_api/tree/main/feather_simple_api/extensions/flask_sqlalchemy/"
    click DBM "https://github.com/juleski/feather_simple_api/tree/main/migrations/"
    click UE "https://github.com/juleski/feather_simple_api/blob/main/feather_simple_api/resources/users/users_endpoint.py"
    click AE "https://github.com/juleski/feather_simple_api/blob/main/feather_simple_api/resources/auth/auth_endpoint.py"
    click DBINIT "https://github.com/juleski/feather_simple_api/blob/main/db/init/feather_app.sql"
    click SEC "https://github.com/juleski/feather_simple_api/blob/main/feather_simple_api/resources/auth/security.py"
    click UDTO "https://github.com/juleski/feather_simple_api/blob/main/feather_simple_api/resources/users/user_dto.py"
    click PDTO "https://github.com/juleski/feather_simple_api/blob/main/feather_simple_api/resources/providers/provider_dto.py"

    %% Styling
    classDef api fill:#2374ab
    classDef auth fill:#ff7f50
    classDef service fill:#4caf50
    classDef dao fill:#ffd700
    classDef db fill:#808080
    classDef dto fill:#ba68c8
```
