Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 143 additions & 0 deletions .codeboarding/Listing_Streaming.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
{
"description": "The PRAW library's data retrieval architecture is primarily composed of two distinct but complementary patterns: listing generation and stream generation. The ListingGenerator forms the backbone for paginated data retrieval, efficiently fetching and iterating through large datasets from the Reddit API. This core functionality is extended and specialized by BaseListingMixin, SubredditListingMixin, and RedditorListingMixin, which provide context-specific listing capabilities for general, subreddit, and redditor content, respectively. For real-time data, the StreamGenerator (implemented as stream_generator utility) offers a robust mechanism for continuous data delivery, handling deduplication and rate limiting. This utility is leveraged by higher-level stream methods within Redditors, Inbox, and Subreddits classes, providing user-friendly entry points for accessing live streams of redditors, inbox messages, and subreddit content. This dual approach ensures comprehensive and efficient access to both historical and real-time Reddit data.",
"components": [
{
"name": "ListingGenerator",
"description": "Manages the iteration and pagination of items from Reddit API responses. It handles fetching data in batches, extracting relevant sub-lists, and providing an iterable interface to the user, abstracting away pagination details. This component is crucial for efficiently handling large datasets from the Reddit API.",
"referenced_source_code": [
{
"qualified_name": "ListingGenerator",
"reference_file": "/home/ubuntu/CodeBoarding/repo/praw/praw/models/listing/generator.py",
"reference_start_line": 17,
"reference_end_line": 103
}
]
},
{
"name": "BaseListingMixin",
"description": "Provides foundational listing methods such as `hot`, `new`, `top`, and `controversial`. It prepares generic API requests and validates time filters applicable across various Reddit resources, serving as a common interface for listing operations.",
"referenced_source_code": [
{
"qualified_name": "BaseListingMixin",
"reference_file": "/home/ubuntu/CodeBoarding/repo/praw/praw/models/listing/mixins/base.py",
"reference_start_line": 15,
"reference_end_line": 149
}
]
},
{
"name": "SubredditListingMixin",
"description": "Specializes listing functionality for subreddit-specific content, including comments and submissions within a subreddit. It determines appropriate API paths for subreddit-related data, extending the base listing capabilities.",
"referenced_source_code": [
{
"qualified_name": "SubredditListingMixin",
"reference_file": "/home/ubuntu/CodeBoarding/repo/praw/praw/models/listing/mixins/subreddit.py",
"reference_start_line": 49,
"reference_end_line": 73
}
]
},
{
"name": "RedditorListingMixin",
"description": "Specializes listing functionality for redditor-specific content, such as comments and submissions made by a particular user. It creates sub-listings tailored to user activity, providing a user-centric view of Reddit data.",
"referenced_source_code": [
{
"qualified_name": "RedditorListingMixin",
"reference_file": "/home/ubuntu/CodeBoarding/repo/praw/praw/models/listing/mixins/redditor.py",
"reference_start_line": 35,
"reference_end_line": 185
}
]
},
{
"name": "StreamGenerator",
"description": "This component, implemented as the `stream_generator` function, provides a generic, low-level mechanism for continuously yielding new items from a source. It manages the stream's state, handles deduplication using a `BoundedSet`, and incorporates exponential backoff for rate limiting, forming the core engine for all streaming operations. This is the fundamental utility for real-time data.",
"referenced_source_code": [
{
"qualified_name": "stream_generator",
"reference_file": "/home/ubuntu/CodeBoarding/repo/praw/praw/models/util.py",
"reference_start_line": 36,
"reference_end_line": 163
}
]
},
{
"name": "RedditorsStream",
"description": "Represents the `stream` method within the `Redditors` class, acting as an entry point for initiating and managing a continuous stream of new redditors as they are created or become active. It provides a high-level interface for accessing real-time user data by leveraging the `stream_generator` utility.",
"referenced_source_code": [
{
"qualified_name": "Redditors.stream",
"reference_file": "/home/ubuntu/CodeBoarding/repo/praw/praw/models/redditors.py",
"reference_start_line": 93,
"reference_end_line": 104
}
]
},
{
"name": "InboxStream",
"description": "Represents the `stream` method within the `Inbox` class, acting as an entry point for initiating and managing a continuous stream of unread inbox messages for the authenticated user. This component is vital for real-time notification and interaction features, leveraging the `stream_generator` utility.",
"referenced_source_code": [
{
"qualified_name": "Inbox.stream",
"reference_file": "/home/ubuntu/CodeBoarding/repo/praw/praw/models/inbox.py",
"reference_start_line": 229,
"reference_end_line": 247
}
]
},
{
"name": "SubredditContentStream",
"description": "Represents the `stream` method within the `Subreddits` class, providing access to streams of content related to a specific subreddit, including specialized moderation streams. This allows for real-time monitoring of activity within a subreddit by leveraging the `stream_generator` utility.",
"referenced_source_code": [
{
"qualified_name": "Subreddits.stream",
"reference_file": "/home/ubuntu/CodeBoarding/repo/praw/praw/models/subreddits.py",
"reference_start_line": 124,
"reference_end_line": 133
}
]
}
],
"components_relations": [
{
"relation": "specializes",
"src_name": "SubredditListingMixin",
"dst_name": "BaseListingMixin"
},
{
"relation": "specializes",
"src_name": "RedditorListingMixin",
"dst_name": "BaseListingMixin"
},
{
"relation": "utilizes",
"src_name": "BaseListingMixin",
"dst_name": "ListingGenerator"
},
{
"relation": "utilizes",
"src_name": "SubredditListingMixin",
"dst_name": "ListingGenerator"
},
{
"relation": "utilizes",
"src_name": "RedditorListingMixin",
"dst_name": "ListingGenerator"
},
{
"relation": "leverages",
"src_name": "RedditorsStream",
"dst_name": "StreamGenerator"
},
{
"relation": "leverages",
"src_name": "InboxStream",
"dst_name": "StreamGenerator"
},
{
"relation": "leverages",
"src_name": "SubredditContentStream",
"dst_name": "StreamGenerator"
}
]
}
108 changes: 108 additions & 0 deletions .codeboarding/Listing_Streaming.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
Listing Streaming
=================

.. mermaid::

graph LR
ListingGenerator["ListingGenerator"]
BaseListingMixin["BaseListingMixin"]
SubredditListingMixin["SubredditListingMixin"]
RedditorListingMixin["RedditorListingMixin"]
StreamGenerator["StreamGenerator"]
RedditorsStream["RedditorsStream"]
InboxStream["InboxStream"]
SubredditContentStream["SubredditContentStream"]
SubredditListingMixin -- "specializes" --> BaseListingMixin
RedditorListingMixin -- "specializes" --> BaseListingMixin
BaseListingMixin -- "utilizes" --> ListingGenerator
SubredditListingMixin -- "utilizes" --> ListingGenerator
RedditorListingMixin -- "utilizes" --> ListingGenerator
RedditorsStream -- "leverages" --> StreamGenerator
InboxStream -- "leverages" --> StreamGenerator
SubredditContentStream -- "leverages" --> StreamGenerator

| |codeboarding-badge| |demo-badge| |contact-badge|

.. |codeboarding-badge| image:: https://img.shields.io/badge/Generated%20by-CodeBoarding-9cf?style=flat-square
:target: https://github.com/CodeBoarding/CodeBoarding
.. |demo-badge| image:: https://img.shields.io/badge/Try%20our-Demo-blue?style=flat-square
:target: https://www.codeboarding.org/demo
.. |contact-badge| image:: https://img.shields.io/badge/Contact%20us%20-%[email protected]?style=flat-square
:target: mailto:[email protected]

Details
-------

The PRAW library's data retrieval architecture is primarily composed of two distinct but complementary patterns: listing generation and stream generation. The ListingGenerator forms the backbone for paginated data retrieval, efficiently fetching and iterating through large datasets from the Reddit API. This core functionality is extended and specialized by BaseListingMixin, SubredditListingMixin, and RedditorListingMixin, which provide context-specific listing capabilities for general, subreddit, and redditor content, respectively. For real-time data, the StreamGenerator (implemented as stream_generator utility) offers a robust mechanism for continuous data delivery, handling deduplication and rate limiting. This utility is leveraged by higher-level stream methods within Redditors, Inbox, and Subreddits classes, providing user-friendly entry points for accessing live streams of redditors, inbox messages, and subreddit content. This dual approach ensures comprehensive and efficient access to both historical and real-time Reddit data.

ListingGenerator
^^^^^^^^^^^^^^^^

Manages the iteration and pagination of items from Reddit API responses. It handles fetching data in batches, extracting relevant sub-lists, and providing an iterable interface to the user, abstracting away pagination details. This component is crucial for efficiently handling large datasets from the Reddit API.

**Related Classes/Methods**:

* `ListingGenerator:17-103 <https://github.com/CodeBoarding/praw/blob/main/praw/models/listing/generator.py#L17-L103>`_

BaseListingMixin
^^^^^^^^^^^^^^^^

Provides foundational listing methods such as `hot`, `new`, `top`, and `controversial`. It prepares generic API requests and validates time filters applicable across various Reddit resources, serving as a common interface for listing operations.

**Related Classes/Methods**:

* `BaseListingMixin:15-149 <https://github.com/CodeBoarding/praw/blob/main/praw/models/listing/mixins/base.py#L15-L149>`_

SubredditListingMixin
^^^^^^^^^^^^^^^^^^^^^

Specializes listing functionality for subreddit-specific content, including comments and submissions within a subreddit. It determines appropriate API paths for subreddit-related data, extending the base listing capabilities.

**Related Classes/Methods**:

* `SubredditListingMixin:49-73 <https://github.com/CodeBoarding/praw/blob/main/praw/models/listing/mixins/subreddit.py#L49-L73>`_

RedditorListingMixin
^^^^^^^^^^^^^^^^^^^^

Specializes listing functionality for redditor-specific content, such as comments and submissions made by a particular user. It creates sub-listings tailored to user activity, providing a user-centric view of Reddit data.

**Related Classes/Methods**:

* `RedditorListingMixin:35-185 <https://github.com/CodeBoarding/praw/blob/main/praw/models/listing/mixins/redditor.py#L35-L185>`_

StreamGenerator
^^^^^^^^^^^^^^^

This component, implemented as the `stream_generator` function, provides a generic, low-level mechanism for continuously yielding new items from a source. It manages the stream's state, handles deduplication using a `BoundedSet`, and incorporates exponential backoff for rate limiting, forming the core engine for all streaming operations. This is the fundamental utility for real-time data.

**Related Classes/Methods**:

* `stream_generator:36-163 <https://github.com/CodeBoarding/praw/blob/main/praw/models/util.py#L36-L163>`_

RedditorsStream
^^^^^^^^^^^^^^^

Represents the `stream` method within the `Redditors` class, acting as an entry point for initiating and managing a continuous stream of new redditors as they are created or become active. It provides a high-level interface for accessing real-time user data by leveraging the `stream_generator` utility.

**Related Classes/Methods**:

* `Redditors.stream:93-104 <https://github.com/CodeBoarding/praw/blob/main/praw/models/redditors.py#L93-L104>`_

InboxStream
^^^^^^^^^^^

Represents the `stream` method within the `Inbox` class, acting as an entry point for initiating and managing a continuous stream of unread inbox messages for the authenticated user. This component is vital for real-time notification and interaction features, leveraging the `stream_generator` utility.

**Related Classes/Methods**:

* `Inbox.stream:229-247 <https://github.com/CodeBoarding/praw/blob/main/praw/models/inbox.py#L229-L247>`_

SubredditContentStream
^^^^^^^^^^^^^^^^^^^^^^

Represents the `stream` method within the `Subreddits` class, providing access to streams of content related to a specific subreddit, including specialized moderation streams. This allows for real-time monitoring of activity within a subreddit by leveraging the `stream_generator` utility.

**Related Classes/Methods**:

* `Subreddits.stream:124-133 <https://github.com/CodeBoarding/praw/blob/main/praw/models/subreddits.py#L124-L133>`_
118 changes: 118 additions & 0 deletions .codeboarding/Low_Level_API_Connector.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
"description": "The `praw` library provides a high-level, Pythonic interface for interacting with the Reddit API. At its core, the `Reddit Client` acts as the primary orchestrator, managing user requests and coordinating with other internal components. It leverages an `Authentication Module` to handle various OAuth2 flows and token management, ensuring secure access to Reddit resources. `Configuration Management` centralizes the loading and parsing of settings, making the client adaptable to different environments. All interactions with Reddit's data are facilitated through `Data Models/Objects`, which abstract API responses into intuitive Python objects. For the actual network communication and low-level OAuth2 intricacies, `praw` relies on the `Low-Level API Connector` (prawcore), an external dependency that handles the complexities of HTTP requests and responses, thereby decoupling `praw` from the underlying network layer.",
"components": [
{
"name": "Reddit Client",
"description": "The primary entry point for users to interact with the Reddit API. It orchestrates calls to other components to fulfill user requests, providing a high-level, Pythonic interface to Reddit resources.",
"referenced_source_code": [
{
"qualified_name": "praw.Reddit",
"reference_file": "/home/ubuntu/CodeBoarding/repo/praw/praw/reddit.py",
"reference_start_line": 1,
"reference_end_line": 1
}
]
},
{
"name": "Low-Level API Connector",
"description": "An external dependency, `prawcore`, which is solely responsible for handling the low-level HTTP communication with the Reddit API. It manages the actual network requests, responses, and the intricacies of OAuth2 authentication flows, abstracting these complexities from the higher-level `praw` library.",
"referenced_source_code": [
{
"qualified_name": "prawcore",
"reference_file": "/home/ubuntu/CodeBoarding/repo/praw/praw/reddit.py",
"reference_start_line": 527,
"reference_end_line": 546
}
]
},
{
"name": "Authentication Module",
"description": "Manages the various OAuth2 authentication flows (e.g., script, installed app, web app) and handles the storage and refreshing of access tokens.",
"referenced_source_code": [
{
"qualified_name": "praw.auth",
"reference_file": "/home/ubuntu/CodeBoarding/repo/praw/praw/models/auth.py",
"reference_start_line": 1,
"reference_end_line": 1
}
]
},
{
"name": "Data Models/Objects",
"description": "Represents Reddit API resources (e.g., `Submission`, `Comment`, `Subreddit`, `User`) as Python objects, providing attribute access and methods for interaction.",
"referenced_source_code": [
{
"qualified_name": "praw.models.submission.Submission",
"reference_file": "/home/ubuntu/CodeBoarding/repo/praw/praw/models/reddit/submission.py",
"reference_start_line": 1,
"reference_end_line": 1
},
{
"qualified_name": "praw.models.subreddit.Subreddit",
"reference_file": "/home/ubuntu/CodeBoarding/repo/praw/praw/models/reddit/subreddit.py",
"reference_start_line": 1,
"reference_end_line": 1
}
]
},
{
"name": "Configuration Management",
"description": "Handles the loading, parsing, and management of configuration settings (e.g., client ID, client secret, user agent) from various sources (e.g., `praw.ini`, environment variables).",
"referenced_source_code": [
{
"qualified_name": "praw.config",
"reference_file": "/home/ubuntu/CodeBoarding/repo/praw/praw/config.py",
"reference_start_line": 1,
"reference_end_line": 1
}
]
}
],
"components_relations": [
{
"relation": "utilizes",
"src_name": "Reddit Client",
"dst_name": "Low-Level API Connector"
},
{
"relation": "depends on",
"src_name": "Reddit Client",
"dst_name": "Low-Level API Connector"
},
{
"relation": "configures",
"src_name": "Authentication Module",
"dst_name": "Low-Level API Connector"
},
{
"relation": "provides authentication context to",
"src_name": "Authentication Module",
"dst_name": "Low-Level API Connector"
},
{
"relation": "interacts with",
"src_name": "Reddit Client",
"dst_name": "Authentication Module"
},
{
"relation": "uses",
"src_name": "Reddit Client",
"dst_name": "Data Models/Objects"
},
{
"relation": "loads settings via",
"src_name": "Reddit Client",
"dst_name": "Configuration Management"
},
{
"relation": "are populated by",
"src_name": "Data Models/Objects",
"dst_name": "Low-Level API Connector"
},
{
"relation": "reads settings from",
"src_name": "Authentication Module",
"dst_name": "Configuration Management"
}
]
}
Loading