How ayanooxd/razorpay-api works
1. Overall shape
- This is a single-binary Go service, with most of the logic in autorzp.go.
- It exposes an HTTP API, drives a remote Razorpay checkout flow, and reports the result as JSON.
- The rest of the repo is mostly configuration, packaging, and tests.
2. Runtime boundary
- The server listens on PORT (default 7070).
- It provides two public endpoints: /health for liveness checks and /razorpay/cc=... for the card-check workflow.
- The service is designed to run standalone in a container or on Railway.
3. Primary request flow
- A client sends a card payload in the URL path as cc|mm|yy|cvv.
- The handler validates the request, acquires capacity from a concurrency limiter, and then starts the Razorpay check process.
- The final response is normalized into a small JSON status object, such as approved, declined, charged, or error.
4. Razorpay interaction subsystem
- The core business logic is the browser-like HTTP interaction with a real Razorpay payment page.
- The service appears to emulate enough client behavior to get a bank/WAF response back from Razorpay rather than simply doing a local validation.
- Response handling includes parsing upstream responses and interpreting block/decline/approval outcomes.
5. Proxy and site inputs
- px.txt supplies proxy endpoints, optionally with credentials, and sites.txt supplies Razorpay payment-page URLs.
- These files are external data inputs, not code, and they influence how outbound requests are routed and which checkout pages are exercised.
- proxy_file and sites_file env vars let those paths be swapped without changing the binary.
6. State and logging
- live.txt is the runtime output file where approved/charged cards are logged.
- This is an append-style side effect rather than a database-backed system.
- Because it is file-based, persistence is simple but local to the filesystem or mounted volume.
7. Concurrency and backpressure
- The service uses a semaphore-like limiter controlled by MAX_CONCURRENT (default 120).
- If all slots are busy, new requests wait up to a bounded timeout and then receive 503 instead of hanging.
- This is the main load-shedding boundary in the architecture.
8. Networking and resilience concerns
- The README indicates the server has explicit protections for slow requests, retries, graceful shutdown, and panic recovery.
- Upstream content encoding is handled explicitly, which matters because the service consumes compressed responses from remote systems.
- The request lifecycle is therefore: accept HTTP request → constrain concurrency → call remote upstreams via proxy/site selection → parse response → return JSON.
9. Security and deployability boundaries
- The service is packaged for container deployment via a multi-stage Dockerfile.
- railway.json wires the container to Railway’s deployment model and healthcheck behavior.
- HEALTHCHECK in the container and /health in the app are the operational contract for orchestrators.
10. Build and test structure
- Makefile provides the main local workflows: build, run, test, lint, coverage, and Docker tasks.
- autorzp_test.go focuses on helper behavior and regression-prone logic, including the failure modes called out in the README.
- go.mod indicates Go 1.22+ as the runtime/toolchain baseline.
11. Architectural summary for a diagram
- Draw this as a thin HTTP front door, a central request processor, and three main dependency streams: proxy list, site list, and live-results file.
- The only external network dependency of interest is Razorpay, reached through rotating proxies.
- The key operational controls are health checks, concurrency limiting, and graceful shutdown.
Main entry points: autorzp.go autorzp.go · px.txt px.txt · sites.txt sites.txt · live.txt live.txt
Components 16
Runtime
Live request-processing and operational boundary
- autorzp.go · Single-binary HTTP server and request orchestrator
autorzp.go - HTTP API · Public endpoints for health checks and card-check requests
autorzp.go - Health check · Liveness endpoint used by orchestrators
autorzp.go - Card check · Parses the cc|mm|yy|cvv request and starts the check flow
autorzp.go - Limiter · Bounds in-flight requests and sheds load on timeout
autorzp.go - Razorpay flow · Drives the remote checkout interaction and interprets outcomes
autorzp.go - Result JSON · Normalizes outcomes such as approved, declined, charged, or error
autorzp.go - Resilience · Handles retries, graceful shutdown, and panic recovery
autorzp.go - Env vars · PORT, MAX_CONCURRENT, proxy_file, sites_file, and related settings
autorzp.go - Razorpay · Upstream payment flow reached through rotating proxies
Data
External input and output files used by the service
Delivery
Build and deployment surface
- Dockerfile · Multi-stage container packaging and healthcheck wiring
Dockerfile - railway.json · Railway deployment and healthcheck integration
railway.json - Makefile · Local build, run, test, lint, coverage, and Docker tasks
Makefile
Connections 16
- autorzp.go → HTTP API: serves · Main binary exposes the HTTP surface
- HTTP API → Health check: GET /health · Operational liveness endpoint
- HTTP API → Card check: GET /razorpay/cc=... · Primary card-check request path
- Card check → Limiter: acquires slot · Bounds concurrent request processing
- Card check → Razorpay flow: starts flow · Hands validated request into upstream checkout logic
- Razorpay flow → px.txt: uses proxies · Rotates outbound routing through configured proxies
- Razorpay flow → sites.txt: selects site · Chooses a payment-page URL to exercise
- Razorpay flow → Razorpay: calls upstream · Performs remote payment-page interaction
- Razorpay flow → Result JSON: interprets outcome · Converts upstream responses into service statuses
- Result JSON → live.txt: logs success · Appends approved or charged results to disk
- Card check → Resilience: protected by · Request lifecycle includes retries and recovery safeguards
- autorzp.go → Env vars: reads config · Uses environment variables for port, limits, and file paths
- autorzp.go → Dockerfile: packaged by · Built into a container image for deployment
- autorzp.go → railway.json: deploys on · Operationalized through Railway settings
- autorzp.go → Makefile: developed with · Local workflow entrypoint for build and test tasks
- autorzp.go → Razorpay: depends on · Core business logic centers on the external checkout flow