# sri0606/pyorcid architecture

> Architecture diagram of the GitHub repository sri0606/pyorcid, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sri0606/pyorcid
- Repository: https://github.com/sri0606/pyorcid

## Overview

##### Main Components

a) Client Layer:
- PyOrcid Library Interface
- Authentication Module
- Data Access Modules
- Search Module
- Scrapper Module

b) External Systems:
- ORCID Public API
- ORCID Member API
- ORCID Public Database (for scraping)

**┌─ Client Applications ─────────────────────────────────────┐**

- Uses PyOrcid Library                                    │

- ┤
- PyOrcid Library                       │
- ┬──────────────┬────────────┬───────────────┤

- OrcidAuth  │    Orcid    │  OrcidSearch│ OrcidScrapper │

- ┴──────────────┴────────────┴───────────────┤

- External Services                       │

- ORCID Public API    ORCID Member API    ORCID Web    │

- ┘

##### Component Details

For each major component, include:

a) OrcidAuthentication:
- Input: client_id, client_secret, redirect_uri
- Output: access_token
- Methods: get_public_access_token(), get_private_access_token()

b) Orcid:
- Input: orcid_id, orcid_access_token, state
- Methods: works(), generate_markdown_file()
- Handles API interactions

c) OrcidSearch:
- Input: orcid_access_token
- Methods: search()
- Handles search functionality

d) OrcidScrapper:
- Input: orcid_id
- Inherits from Orcid
- Web scraping alternative

##### Data Flow Indicators

Following flows:
- Authentication flow (client → OrcidAuth → ORCID API)
- Data retrieval flow (client → Orcid → ORCID API)
- Search flow (client → OrcidSearch → ORCID API)
- Scraping flow (client → OrcidScrapper → ORCID Web)

##### Important Notes

- Two access paths (API vs. Scrapper)
- Authentication requirements for different access levels
- Inheritance relationship between Orcid and OrcidScrapper
- Error handling paths
- Data transformation flows

## Diagram (Mermaid)

```mermaid
%%{init: {'theme':'neutral'}}%%
flowchart TB
    subgraph Client["Client Applications"]
        App["Python Applications"]
        Example["Example Implementation"]:::example
        MDGen["Markdown Generator"]:::example
    end

    subgraph PyOrcid["PyOrcid Library"]
        Interface["PyOrcid Interface"]:::core
        subgraph Core["Core Components"]
            Auth["OrcidAuth"]:::auth
            OrcidCore["Orcid"]:::core
            Search["OrcidSearch"]:::core
            Scrapper["OrcidScrapper"]:::core
        end
    end

    subgraph External["External Services"]
        PublicAPI["ORCID Public API"]:::external
        MemberAPI["ORCID Member API"]:::external
        Web["ORCID Web Interface"]:::external
    end

    %% Relationships
    App --> Interface
    Example --> Interface
    MDGen --> Interface
    Interface --> Core
    Auth --> PublicAPI & MemberAPI
    OrcidCore --> PublicAPI & MemberAPI
    Search --> PublicAPI
    Scrapper --> Web
    
    %% Click Events
    click Interface "https://github.com/sri0606/pyorcid/blob/main/src/pyorcid/__init__.py"
    click OrcidCore "https://github.com/sri0606/pyorcid/blob/main/src/pyorcid/orcid.py"
    click Auth "https://github.com/sri0606/pyorcid/blob/main/src/pyorcid/orcid_authentication.py"
    click Search "https://github.com/sri0606/pyorcid/blob/main/src/pyorcid/orcid_search.py"
    click Scrapper "https://github.com/sri0606/pyorcid/blob/main/src/pyorcid/orcid_scrapper.py"
    click Example "https://github.com/sri0606/pyorcid/blob/main/example.ipynb"
    click MDGen "https://github.com/sri0606/pyorcid/blob/main/md_generator_example.md"

    %% Styling
    classDef core fill:#a8d1ff,stroke:#333,stroke-width:2px
    classDef auth fill:#90EE90,stroke:#333,stroke-width:2px
    classDef external fill:#FFB366,stroke:#333,stroke-width:2px
    classDef example fill:#E6E6E6,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Authentication"]:::auth
        L3["External Services"]:::external
        L4["Examples"]:::example
    end
```
