Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Bug
about: Something broke — include the failing request and response.
labels: bug
---

## What happened

<!-- One sentence. -->

## Reproducer

```bash
# the exact curl (or Go snippet) that fails, copy-pasteable
```

## Expected vs. actual

- Expected: ...
- Actual: ...

## Environment

- Version / commit SHA:
- Go version (`go version`):
- Running via: docker compose / `make run` / binary / other:

## Logs

<!-- Paste the relevant log lines. Redact secrets. -->
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Feature / change proposal
about: Propose something new or a change to existing behaviour.
labels: enhancement
---

## What

<!-- One sentence describing the change. -->

## Why

<!-- The problem it solves. Bonus if you can link a real scenario where
the current behaviour bit you. -->

## Scope

<!-- What's in, what's out, what's follow-up. -->

## Alternatives considered

<!-- What else you thought about, and why it's worse. -->
15 changes: 15 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- A sentence on what this does and why. -->

## Changes

- ...

## Test plan

- [ ] `make test` passes locally
- [ ] `make vet` passes locally
- [ ] tried the end-to-end flow manually (if user-visible)

## Notes for reviewer

<!-- Anything surprising, deferred, or worth a second look. -->
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI

on:
push:
branches: [master]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.25"
cache: true

- name: go vet
run: go vet ./...

- name: gofmt
run: |
diff=$(gofmt -d .)
if [ -n "$diff" ]; then
echo "gofmt wants these changes:"
echo "$diff"
exit 1
fi

- name: go test
run: go test ./...

- name: build
run: go build ./...
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
.env
config.prod.yaml
config.local.yaml
config.yaml
spec.yaml

# Binary
# Binaries
bin/
instant-lite-api
lite

# IDE
.vscode/
.idea/
*.swp
88 changes: 88 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Contributing

Thanks for the interest. This project is early and small — the fastest way to
help is to file a bug with a reproducer, or open a PR that's scoped tightly.

## Development setup

Prereqs: Go 1.25+, a Postgres you can create databases on, Redis (optional —
the server degrades without it).

```bash
git clone https://github.com/InstaNode-dev/instant-lite-api
cd instant-lite-api
cp config.example.yaml config.yaml # edit the DB urls
make run
```

Or with Docker:

```bash
make docker-up
curl -s -X POST http://localhost:18080/db/new | jq
```

## Running the test suite

```bash
make test # unit tests, no external services needed
make vet # go vet + gofmt check
```

Unit tests stub out Razorpay via the `razorpayBaseURLOverride` pointer in
`internal/server/razorpay_client.go` — no test ever makes a real network call.

## Code layout

```
cmd/server/ entrypoint — thin main() that calls server.Run
internal/server/ everything else (handlers, auth, billing, config, db)
paths.go route-path constants (reuse these, don't hardcode)
payment.go billing-provider interface
razorpay_client.go razorpayPayment impl + SDK helpers
payment_noop.go no-op impl for self-hosts without Razorpay
billing.go shared billing helpers + deprecated migrate shim
billing_orders.go legacy one-time order flow
billing_webhook.go Razorpay webhook dispatcher + signature verify
billing_subscriptions.go subscription lifecycle handlers
billing_change_plan.go monthly↔annual plan switch
billing_reconciler.go background reconciler (polls Razorpay)
...
```

## PR conventions

- **Branch off master**, don't push to master directly (there's a pre-push
hook blocking this — enable with `git config core.hooksPath .githooks`).
- **One concern per PR**. Splitting a file, a bug fix, and a feature into
three PRs gets reviewed in three hours. Bundling them gets reviewed in
three weeks.
- **Commit messages**: `<scope>: <what changed>` (e.g. `billing: fix INR
rounding in receipt email`). Explain the *why* in the body when it's
non-obvious.
- **Tests**: add them when you add behaviour. Tests that hit a real
`httptest.Server` for external APIs, not mocks of our own types.
- **No `--no-verify` pushes**, no `gofmt` violations, no unused imports.

## Code style

- Follow `gofmt` — CI will fail otherwise.
- Prefer named constants over repeated string literals (paths, error codes,
header names). See `internal/server/paths.go` for the pattern.
- Errors bubble up; don't swallow. Log with `slog.ErrorContext` when the
request context is available so traces correlate.
- Return structured JSON errors via `writeError(w, status, code, message)` —
don't hand-write error bodies.

## What we're NOT looking for

- Abstractions-for-future-flexibility without a concrete second caller today.
- Rewrites of working code to match a different style.
- AI-generated PR descriptions or commit messages — write your own so we
can review intent, not output.

## Getting unstuck

Open an issue with the full command you ran and the full error output. We
don't need a stack trace dump of your entire server — just the failing
request + response.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /bin/instant-lite .
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /bin/instant-lite ./cmd/server

FROM alpine:3.20
RUN apk add --no-cache ca-certificates postgresql-client gettext
COPY --from=build /bin/instant-lite /usr/local/bin/instant-lite
COPY schema.sql /app/schema.sql
COPY internal/server/schema.sql /app/schema.sql
COPY config.prod.yaml.tpl /app/config.prod.yaml.tpl
ENV CONFIG_PATH=/app/config.yaml
EXPOSE 8080
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 InstaNode Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
47 changes: 47 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.PHONY: run build test vet lint fmt clean docker docker-up docker-down help

# Default target
help:
@echo "instant-lite-api — make targets:"
@echo " run start the server (reads config.yaml)"
@echo " build compile binary to bin/instant-lite"
@echo " test run the Go test suite"
@echo " vet go vet + gofmt check"
@echo " fmt format sources in place"
@echo " lint strict checks (vet + gofmt --diff)"
@echo " docker build the Docker image"
@echo " docker-up docker compose up -d --build"
@echo " docker-down docker compose down -v"
@echo " clean remove build artefacts"

run:
go run ./cmd/server

build:
@mkdir -p bin
CGO_ENABLED=0 go build -ldflags="-s -w" -o bin/instant-lite ./cmd/server

test:
go test ./...

vet:
go vet ./...
@gofmt -l . | (! grep .) || (echo "gofmt wants changes — run 'make fmt'" && exit 1)

fmt:
gofmt -w .

lint: vet
@gofmt -d . | (! grep .) || (echo "gofmt diff above — run 'make fmt'" && exit 1)

docker:
docker build -t instant-lite-api:local .

docker-up:
docker compose up -d --build

docker-down:
docker compose down -v

clean:
rm -rf bin/ lite instant-lite-api
Loading
Loading