$ show liberapay/liberapay.com
Liberapay is a production web application for recurrent monetary donations, operating as a non-profit platform. It allows donors to set up weekly, monthly, or yearly contributions to creators, teams, and organizations. The architecture is a monolithic Python web application built on the custom Aspen/Pando framework (a fork of Aspen), using PostgreSQL for persistence, Jinja2 for server-side rendering, and a mix of Stripe and PayPal for payment processing. Key entry points include the homepage (`www/index.html.spt`), user profile pages (`www/%username/index.html.spt`), donation management (`www/%username/giving/`), payment flows (`www/%username/giving/pay/stripe/%payin_id.spt`), and admin dashboards (`www/admin/`). Data flows involve user authentication via sessions and OAuth, tip creation and scheduling, payin execution through Stripe/PayPal, weekly payday settlement, and email notifications. External dependencies include Stripe, PayPal, Amazon SES (email), Sentry (error tracking), S3 (file storage), and multiple OAuth providers (GitHub, Twitter, Mastodon, etc.). The codebase is well-structured with reusable modules for payment prospect calculation, encryption, content security policy, currency handling, and OAuth abstraction, though it carries technical debt from a custom framework and aging dependencies.
The LLM identified 4 files worth highlighting for reuse:
Implements `PayinProspect`, a self-contained class that computes suggested donation amounts based on fee tiers (Stripe/PayPal), donor limits, and recipient preferences. It encapsulates fee logic, amount rounding, and minimum/maximum constraints, making it reusable for any payment flow that needs to present donation options to users.
Provides Fernet-based symmetric encryption with automatic key rotation and versioning. The `Cryptograph` class manages multiple encryption keys, supports encrypting/decrypting strings and bytes, and includes a key derivation function. It is isolated from the rest of the codebase and can be extracted for any project requiring secure, rotatable encryption.
Implements a custom CBOR encoder/decoder that handles Python `datetime`, `Decimal`, `Money`, and `MoneyBasket` objects. It extends the standard CBOR library with tag-based encoding for these types, enabling efficient and type-safe serialization for database storage or network transmission. The module is self-contained and demonstrates non-obvious skill in binary serialization.
Defines an abstract base class for OAuth1 and OAuth2 platform integrations, including token management, API request helpers, and user info extraction. It provides a reusable pattern for adding new social login providers with minimal code, as seen in the concrete implementations (GitHub, Twitter, Mastodon, etc.). The module is well-encapsulated and could be extracted as a generic OAuth client library.