# jayeeed/fb-gapi architecture

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

- Interactive diagram: https://gitdiagram.com/jayeeed/fb-gapi
- Repository: https://github.com/jayeeed/fb-gapi

## Overview

##### Project type and purpose
- This is a Python Async SDK (library) for interacting with Meta’s Facebook Graph and Messenger Send APIs.
- It provides an asynchronous client to send text and image messages, fetch conversation history, and handle API errors.

##### File structure
- .github/workflows/pypi-publish.yml → CI pipeline that builds, tests, and publishes the package to PyPI.
- README.md → high-level overview, usage examples, feature list.
- pyproject.toml → metadata, dependencies, and build configuration.
- fb_gapi/
- __init__.py → package export (e.g., MessengerClient)
- client.py → core asynchronous HTTP client and public methods (asend_text, asend_remote_attachment, etc.)
- exceptions.py → custom exception class (MessengerAPIError)
- utils.py → helper functions (e.g., payload builders, file readers)

##### README for additional insights
- The README explicitly describes the main use-cases (send text, remote/local attachments, get chat history).
- It shows async usage patterns, error handling, and prerequisites (Python 3.9+).

##### Final checklist for detail
- Async boundaries (e.g., annotate “async call”).
- Error-handling flow separately.
- Packaging/publishing path.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer Application
    DevApp["Developer Application"]:::external

    %% SDK Package
    subgraph "fb_gapi SDK" 
        direction TB
        Init["__init__.py"]:::internal
        Client["MessengerClient"]:::internal
        Utils["utils module"]:::internal
        Excp["exceptions module"]:::internal
    end

    %% External Service
    FBAPI["Facebook Graph & Messenger Send API"]:::external

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline" 
        direction TB
        CI[".github/workflows/pypi-publish.yml"]:::pipeline
        Build["pyproject.toml"]:::pipeline
        Doc["README.md"]:::doc
    end

    %% Data Flows
    DevApp -->|"import & init"| Client
    Client -->|"async call\n(payload via utils)"| FBAPI
    FBAPI -->|"JSON response"| Client
    FBAPI -.->|"error response"| Client
    Client -->|"return or raise\nMessengerAPIError"| DevApp
    Client -->|"build payload"| Utils
    Client -->|"raise on error"| Excp

    %% CI/CD flows
    CI -->|"reads config"| Build
    CI -->|"runs tests & build"| Build
    CI -->|"publishes package"| PyPI[(PyPI)]:::external

    %% Click Events
    click Client "https://github.com/jayeeed/fb-gapi/blob/main/fb_gapi/client.py"
    click Utils "https://github.com/jayeeed/fb-gapi/blob/main/fb_gapi/utils.py"
    click Excp "https://github.com/jayeeed/fb-gapi/blob/main/fb_gapi/exceptions.py"
    click Init "https://github.com/jayeeed/fb-gapi/blob/main/fb_gapi/__init__.py"
    click CI "https://github.com/jayeeed/fb-gapi/blob/main/.github/workflows/pypi-publish.yml"
    click Build "https://github.com/jayeeed/fb-gapi/blob/main/pyproject.toml"
    click Doc "https://github.com/jayeeed/fb-gapi/blob/main/README.md"

    %% Styles
    classDef internal fill:#D6EAF8,stroke:#3498DB,color:#154360
    classDef external fill:#D5F5E3,stroke:#27AE60,color:#145A32
    classDef pipeline fill:#F2F3F4,stroke:#95A5A6,color:#2C3E50
    classDef doc fill:#FCF3CF,stroke:#F1C40F,color:#7D6608
```
