$ show travis-ci/travis-api
Travis API is the backend REST API for the Travis CI continuous integration platform. It provides multiple API versions (v0/v1/v2/v3) that expose resources such as builds, jobs, repositories, users, organizations, cron schedules, caches, logs, environment variables, SSL keys, and billing/subscription data. The application is built on Ruby with Sinatra for HTTP routing and ActiveRecord for PostgreSQL persistence. It uses Redis for caching, feature flags, and background job queues (Sidekiq). External integrations include GitHub OAuth, a billing service, a remote VCS service (GitHub/GitLab/Bitbucket/Assembla), a logs API, artifact manager, scanner service, and cloud object storage (S3/GCS). The codebase follows a service-oriented architecture for the V3 API, with clear separation into services, queries, models, renderers, and permission classes. Legacy V1/V2 endpoints coexist, increasing maintenance surface. Authentication supports user tokens, application tokens, and log tokens, with fine-grained permissions checked against an external authorizer or local models. The system also handles enterprise deployments with custom licensing and user suspension. Notable engineering patterns include a generic renderer framework with representation modes (minimal/standard), a pagination system with Redis count caching, an encrypted column implementation, a config obfuscator for secure variables, and a feature flag system using Redis.
The LLM identified 5 files worth highlighting for reuse:
A standalone module that obfuscates sensitive configuration values (e.g., API keys, tokens) in build configs before exposing them. It handles nested hashes and arrays, replacing secure values with asterisks. This pattern is reusable in any application that needs to redact secrets from logs or API responses.
Provides transparent AES encryption for ActiveRecord columns. Defines a custom column type that automatically encrypts on write and decrypts on read. Includes key rotation support and is isolated enough to be extracted as a gem.
Implements cursor-based pagination with Redis-backed count caching to avoid expensive SQL COUNT queries. Generates first, last, next, prev links efficiently. The pagination logic is generic and could be reused in any API with list endpoints.
Base class for a hierarchy of access control objects that determine visibility and writability of API resources. Subclasses handle different authentication contexts (user token, log token, application token, anonymous). The pattern provides a clean, testable separation of authorization logic and is reusable in other API projects.
A permissions DSL that auto-generates `permission!` methods from boolean predicates on a model. Used to inject `@permissions` into API responses. The pattern is generic: given any object with predicate methods, it creates permission checks that can be attached to API output.