Skip to content

fix: API frontend readiness, documentation, and project cleanup - #9

Merged
rezadrian01 merged 15 commits into
mainfrom
fix/api-frontend-readiness
May 28, 2026
Merged

fix: API frontend readiness, documentation, and project cleanup#9
rezadrian01 merged 15 commits into
mainfrom
fix/api-frontend-readiness

Conversation

@rezadrian01

Copy link
Copy Markdown
Owner

Summary

  • Add GET /payments/order/:order_id endpoint that returns client_secret so the frontend can confirm Stripe payments via Stripe.js
  • Make GET /inventory/:product_id public (no auth required) so product pages can display stock without login
  • Standardise all user-service HTTP responses to { success, data } envelope
  • Fix Stripe webhook API version mismatch (IgnoreAPIVersionMismatch: true) and PaymentIntent return_url requirement (AllowRedirects: "never")
  • Fix GORM type:decimal(12,2) tag causing malformed ALTER SQL — changed to type:numeric(12,2) across all services; added HasTable guard to skip AutoMigrate on restart
  • Exclude search_vector from GORM model management (gorm:"-") to prevent tsvector tag conflicts
  • Correct JWT env vars in .env.example (JWT_PRIVATE_KEY/JWT_PUBLIC_KEYJWT_SECRET/JWT_REFRESH_SECRET)
  • Add comprehensive README.md, docs/API_DOCS.md, docs/API_CURL_TESTS.md, and docs/Auron.postman_collection.json
  • Remove unused files: orphaned db/*.sql migration files, stale IMPLEMENTATION_PLAN.md docs, unused shared/ Go module, and default Next.js SVG assets

Test plan

  • POST /api/orders → then GET /api/payments/order/:order_id returns client_secret in response
  • GET /api/inventory/:product_id returns stock without Authorization header
  • POST /api/auth/register and GET /api/users/me return { "success": true, "data": { ... } } envelope
  • Stripe webhook (POST /api/payments/webhook/stripe) processes payment_intent.succeeded and updates payment status to completed
  • docker compose up starts cleanly — product-service does not crash on AutoMigrate
  • cp .env.example .env produces a working template with correct JWT variable names

🤖 Generated with Claude Code

rezadrian01 and others added 15 commits May 28, 2026 16:29
…ecret

Adds PaymentCheckoutResponse DTO that includes client_secret so the frontend
can call stripe.confirmPayment() via Stripe.js after order placement.
Adds GetPaymentByOrderID to service interface and implementation; ownership
check (UserID match) is enforced before returning the secret.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…y route

- GET /inventory/:product_id no longer requires auth — product pages can now
  display stock availability without an admin token
- PUT /inventory/:product_id remains admin-only
- GET /payments/order/:order_id proxied to payment-service with auth required

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
All endpoints now return { success: true, data: {...} } on success and
{ success: false, error: "..." } on failure, matching the envelope
used by every other service in the platform.

Login and refresh token responses are unchanged ({ access_token, refresh_token })
as they are auth-protocol responses, not resource envelopes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sequential curl commands for auth, user, address, category, product,
inventory, cart, order, and payment flows including error cases.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
GORM's AutoMigrate generates malformed SQL (unbound $ parameter) when
using the type:GIN index tag. The GIN index is already created correctly
by applySearchIndex via raw SQL (CREATE INDEX IF NOT EXISTS ... USING GIN).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
GORM AutoMigrate fails with tsvector column type (insufficient arguments error
from the postgres driver). The search_vector column is created and indexed by
applySearchIndex via raw SQL — GORM does not need to own it. The WHERE clause
in the repository uses it as a raw SQL string so no struct field scanning needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ervices

PostgreSQL reports numeric columns as 'numeric', not 'decimal'. When GORM
AutoMigrate detects a type mismatch it attempts an ALTER COLUMN and generates
TYPE decimal($1,$2) with unbound parameters — causing an 'insufficient
arguments' error. Aligning the tag to 'numeric' prevents the spurious ALTER.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
GORM v1.31.1 generates malformed ALTER statements for columns with precision
type specifiers (numeric(12,2), tsvector) when comparing against existing
PostgreSQL column metadata. Guard with HasTable check so AutoMigrate only
runs on a fresh database. applySearchIndex always runs since its raw SQL
statements are fully idempotent (IF NOT EXISTS / CREATE OR REPLACE).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Use ConstructEventWithOptions with IgnoreAPIVersionMismatch:true so the
  payment-service accepts webhooks from Stripe CLI (API 2024-04-10) while
  stripe-go v76 uses API version 2023-10-16
- Add AllowRedirects:"never" to PaymentIntent creation so redirect-based
  payment methods (iDEAL, BACS etc.) are excluded and no return_url is
  required at confirmation; cards continue to work with stripe.confirmPayment()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…responses

All 30 endpoints confirmed working end-to-end including the full Stripe
payment flow: order → Kafka → PaymentIntent → CLI confirm → webhook →
status completed. Documents the stripe-go API version mismatch workaround
and allow_redirects:never PaymentIntent configuration.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- API_DOCS.md covers all 30 endpoints across 8 services with request/response
  shapes, query parameters, auth requirements, and error codes
- Auron.postman_collection.json provides a ready-to-import Postman collection
  with collection variables, Bearer auth pre-configured, and test scripts that
  auto-save IDs (tokens, order_id, product_id, etc.) after each response

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers architecture diagram, full tech stack, all 7 services and their
responsibilities, Kafka event flow, getting started steps (env setup,
Stripe webhook forwarding, admin promotion), Make command reference,
payment checkout flow, API quick reference, project directory layout,
and environment variable table.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaced JWT_PRIVATE_KEY / JWT_PUBLIC_KEY (leftover RSA design) with
JWT_SECRET and JWT_REFRESH_SECRET, which is what the services actually
read. Updated the comment to reflect the HS256 shared-secret approach.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Move API_DOCS.md, API_CURL_TESTS.md, Auron.postman_collection.json,
  and ecommerce-technical-plan.md into docs/ folder
- Delete orphaned db/*.sql migration files across order-service,
  payment-service, and product-service (GORM AutoMigrate handles schema)
- Delete stale IMPLEMENTATION_PLAN.md files from all services and
  FULLTEXT_SEARCH.md from product-service
- Remove unused shared/ Go module (packages were defined but never
  imported by any service)
- Update README Project Structure to reflect the new docs/ layout

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 28, 2026 11:13
@rezadrian01
rezadrian01 merged commit 93ce9a0 into main May 28, 2026
1 of 2 checks passed
@rezadrian01
rezadrian01 removed the request for review from Copilot May 28, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant