How lakshaycodes08/stripe-payment-gateway works
This is a Fastify/MySQL payment backend. Clients can manage products and carts, create payments whose amounts are calculated server-side, and retrieve payment history; Stripe webhooks verify payment outcomes and update payment/cart state. The graph separates routing, controllers, domain services, persistence, and Stripe integration. Service internals are partly unsampled, so some service-to-database relationships rely on the SOURCE INDEX or README rather than inspected implementations.
Main entry points: app.ts Fastify bootstrap · connection.ts MySQL database · payment.service.ts Payment service · product.routes.ts Product routes
Components 19
API runtime
- Fastify bootstrap
src/app.ts
Catalog and cart
- Product routes
src/modules/products/product.routes.ts - Product controller
src/modules/products/product.controller.ts - Product service
src/modules/products/product.service.ts - Cart routes
src/modules/cart/cart.routes.ts - Cart controller
src/modules/cart/cart.controller.ts - Cart service
src/modules/cart/cart.service.ts
Payment processing
- Payment routes
src/modules/payments/payment.routes.ts - Payment controller
src/modules/payments/payment.controller.ts - Payment service
src/modules/payments/payment.service.ts - Stripe REST client
src/modules/payments/stripe.client.ts
Webhook processing
- Webhook routes
src/modules/webhooks/webhook.routes.ts - Webhook controller
src/modules/webhooks/webhook.controller.ts - Webhook service
src/modules/webhooks/webhook.service.ts
Shared infrastructure
- MySQL database
src/db/connection.ts - Environment config
src/config/env.ts - Error handler
src/plugins/errorHandler.ts
Other components
- API client
- Stripe
Connections 26
- Fastify bootstrap → Environment config: reads config
src/app.ts - Fastify bootstrap → MySQL database: connects at startup
src/app.ts - Fastify bootstrap → Error handler: registers handler
src/app.ts - Fastify bootstrap → Product routes: registers routes
src/app.ts - Fastify bootstrap → Cart routes: registers routes
src/app.ts - Fastify bootstrap → Payment routes: registers routes
src/app.ts - Fastify bootstrap → Webhook routes: registers routes
src/app.ts - API client → Product routes: requests products
src/modules/products/product.routes.ts - Product routes → Product controller: dispatches requests
src/modules/products/product.routes.ts - Product controller → Product service: calls service
src/modules/products/product.controller.ts - Product service → MySQL database: queries products
src/modules/products/product.service.ts - API client → Cart routes: requests cart
- Cart routes → Cart controller: dispatches requests
src/modules/cart/cart.routes.ts - Cart controller → Cart service: calls service
src/modules/cart/cart.controller.ts - Cart service → MySQL database: queries cart
src/modules/cart/cart.service.ts - API client → Payment routes: creates or lists payments
README.md - Payment routes → Payment controller: dispatches requests
src/modules/payments/payment.routes.ts - Payment controller → Payment service: calls service
src/modules/payments/payment.controller.ts - Payment service → MySQL database: reads and writes
src/modules/payments/payment.service.ts - Payment service → Stripe REST client: creates intent
src/modules/payments/payment.service.ts - Stripe REST client → Stripe: calls REST API
README.md - Stripe → Webhook routes: sends events
README.md - Webhook routes → Webhook controller: dispatches event
src/modules/webhooks/webhook.routes.ts - Webhook controller → Webhook service: verifies and processes
src/modules/webhooks/webhook.controller.ts - Webhook service → MySQL database: updates payment and cart
src/modules/webhooks/webhook.service.ts - MySQL database → Environment config: uses connection settings
src/db/connection.ts