Designing application- QuantAI_123 [financial analyst ChatGPT]

I am building MVP, a web application ~domain specific ChatGPT [imagine LLM based financial analyst named QuantAI_123].

I need some guidance around following pain points:

  1. Cookie Management: the user should be able to get 3 responses from QuantAI_123 for free. Then hit a paywall for buying a 30 min chat (~20 messages). Which library should I use for this in Streamlit? Please explain the pseudocode I can use.

    I want the user to not be able to pass the trial version by refreshing the browser or switching from chrome to safari

  2. Paywall: I want to use the Stripe Payment links for this. Essentially, created a product to be bought over Stripe.

    Authentication of successful payment : Once, 3 reponses/free trial is over, user is prompted with a button/link of Stripe product [30 min chat~ 20 messages] to be bought and then if successful, redirected to chatbot. I am having trouble understanding/listening to incoming webhook from Stripe.

    2.1) Is a webhook required for this use case? If not, please suggest an alternative.
    2.2) If yes, I plan to use a unique cookie session id as client reference id in checkout session to be able to retrieve the status of success/failure.
    2.3) Do I need to register the webhook in Stripe or checkout session is default.
    2.4) How do I listen to this asynchronously?

  3. As I am planning to scale this web app if it attracts any traffic, I want to avoid switching from Streamlit cloud platform due to [resource limit] (Is there Streamlit App Limitations such as usage time, users etc.? - #2 by mathcatsand) later on. Would it be better to use a paid app hosting service like Heroku for this?

    Please Note: I want to be able to keep the codebase and data powering QuantAI_123 private and secure.

Hey @x31,

Thanks for sharing these questions!

For #1, I’m not aware of a way to persist a variable if a user switches to a different browser. Session state values will persist across app reruns, but not browser refreshes or switching to another browser. Even if you used cookies, those would be browser-specific, so I think you’d still run into the same issue.

For #2, check out the st-paywall package created by @Tyler, which allows you to integrate a Stripe paywall into your app.

For #3, Streamlit apps on Community Cloud are limited to 1GB, so I’d recommend using a different hosting platform if you anticipate that won’t be enough – check out our community deployment wiki.