How johnyeocx/autumn works
Main Components
• Frontend Dashboard(s):
• The “frontend” folder (built with Next.js) and the “vite” folder (a Vite/React implementation) both provide user interfaces. They include pages for customers, credits, features, products, onboarding, and integrations.
• They incorporate UI components, hooks, and styling (with Tailwind or similar) to interact with the API.
• Backend Server:
• The “server” directory contains the core Node.js backend services that manage the API endpoints. There are clearly separated directories for internal APIs (like customers, subscriptions, products, coupons, entitlements, dev endpoints, etc.) and external integrations (with Stripe, Supabase, Clerk, Redis, Logtail, and so on).
• Within “server/src/internal” and “server/src/external” you see modules that route incoming requests to business logic (for attaching products, checking entitlements, tracking events, processing webhooks, etc.).
• Reusable Packages and Shared Libraries:
• Under “packages/react”: there is a library of React components and providers (e.g., AutumnProvider, context hooks) that an application can embed with “a couple lines of code”. This package provides the integration points described in the README.
• The “shared” directory contains common error codes, model definitions, logging, and utility functions used by both server and other parts of the system.
• Background/Asynchronous Processing:
• The server includes “queue”, “trigger”, “cron” scripts, and “workers”—all of which indicate that some business logic (such as prorations, handling usage events, or adjusting allowances) is processed asynchronously in the background.
• External Integrations:
• Several subcomponents under the server deal with third-party integrations. For example, there are dedicated folders for handling Stripe payments, webhooks, Supabase, Clerk, and even using external tools like Svix and Resend.
Relationships and Data Flow
• The Frontend(s) interact with the Backend using clearly defined API endpoints:
• For example, using HTTP POST calls to endpoints like “/v1/entitled”, “/v1/events”, and “/v1/attach”.
• Views adapt to both customer management and product pricing configuration.
• The Backend routes incoming API requests via its “internal/api” routers that call business logic functions (e.g., attaching products, processing feature usage, invoicing, or entitlements).
• The Business Logic layer consults shared libraries for consistency (data models, error handling, constants).
• Background jobs (managed via the queue and cron files) process long-running tasks and webhook events received from external providers such as Stripe.
• External services like Stripe are integrated using dedicated utilities that handle things like checkout creation, price conversion, subscription handling, and webhooks.
Architectural Patterns / Design Principles
• Modular Separation: Notice how the server organizes endpoints by domain (customers, products, features, coupons, etc.). This encourages separation of concerns.
• Reusability: Shared directories and packages provide common functions and components that maintain consistency across the frontend and backend.
• API Gateway-like Routing: The “apiRouter.ts” modules indicate an internal routing layer that directs requests to domain-specific handlers.
• External Integration Abstraction: All third-party integrations (Stripe, Supabase, Clerk) have their own set of utilities or routers that encapsulate provider-specific logic.
• Background Processing: The decoupling of long-running processes via queues, cron jobs, and triggers improves scalability.