| # Paywall Integration Specification | |
| This document outlines the plan to integrate `st-paywall` into the Wrdler application to enable subscription-based access. | |
| ## 1. Dependencies | |
| Add `st-paywall` to the project dependencies. | |
| - **File**: `pyproject.toml` | |
| - **Action**: Add `st-paywall` to the `dependencies` list. | |
| ## 2. Configuration | |
| Configure the payment provider (Stripe or Buy Me A Coffee) in Streamlit secrets. | |
| - **File**: `.streamlit/secrets.toml` (User needs to create this if not exists) | |
| - **Content**: | |
| ```toml | |
| [stripe] | |
| api_key = "sk_live_..." | |
| link = "https://buy.stripe.com/..." | |
| # OR | |
| [bmac] | |
| api_key = "..." | |
| link = "https://www.buymeacoffee.com/..." | |
| ``` | |
| *Note: `st-paywall` expects specific keys. Refer to documentation for exact structure.* | |
| ## 3. Code Integration | |
| Integrate the authentication and subscription check into the main UI flow. | |
| - **File**: `wrdler/ui.py` | |
| - **Import**: `from st_paywall import add_auth` | |
| - **Placement**: | |
| - The `add_auth` function should be called early in the `run_app` function or before rendering sensitive content. | |
| - It handles the login UI and subscription check. | |
| ### Integration Strategy | |
| We will add a "Premium" toggle or check, or enforce it for the whole app depending on requirements. For now, we will document how to gate the entire app or specific premium features (like AI Wordlist generation). | |
| **Option A: Gate Entire App** | |
| Call `add_auth(required=True)` at the start of `run_app`. | |
| **Option B: Gate Premium Features** | |
| Call `add_auth(required=False)` to show the login/subscribe sidebar but allow free access. Then check `st.session_state.user_subscribed` (or similar provided by the library) before enabling features like: | |
| - AI Wordlist Generation | |
| - Challenge Mode creation | |
| ## 4. Implementation Plan | |
| 1. **Update `pyproject.toml`**: Add `st-paywall`. | |
| 2. **Update `wrdler/ui.py`**: | |
| - Import `add_auth`. | |
| - Insert `add_auth(...)` call in `run_app` or `_render_sidebar`. | |
| - (Optional) Wrap premium features with subscription checks. | |
| ## 5. Testing | |
| - Verify that the login button appears. | |
| - Verify that non-subscribed users are prompted to subscribe. | |
| - Verify that subscribed users can access the content. | |
| - Test with `testing_mode = true` in secrets. | |