Local Runtime And Auth Source Of Truth
This note is the current repo-local source of truth for the local dev runtime chain used by declaration flows and the standard public portal paths.
Runtime chain
Root npm run dev starts these services:
apps/web->http://localhost:3000services/api->http://localhost:4001services/svc-auth->http://localhost:4100services/svc-tenders->http://localhost:4020services/svc-risk->http://localhost:4200postgres->postgres://kvary:kvary@127.0.0.1:5432/kvary
For npm run dev:one, the bootstrap script now keeps the web origin fixed on http://localhost:3000 and aligns auth OIDC runtime env to that same frontend origin:
WEB_PORT=http://localhost:<chosen-port>forapps/webWEB_PORT=3000forapps/webFRONTEND_BASE_URL=http://localhost:3000forsvc-authGOOGLE_OIDC_REDIRECT_URI=http://localhost:3000/auth/google/callbackforsvc-auth
This is operationally important for Google login. Local OIDC callback origin must stay stable and match the OAuth app configuration.
The controlling script is:
Relevant root dev commands:
dev:auth->PORT=4100dev:api->PORT=4001dev:tenders->PORT=4020dev:web->apps/web
Public list/detail path
The standard public web portal uses:
NEXT_PUBLIC_API_BASE_URL=http://localhost:4001/api/v1
That means:
apps/web->services/api(4001)services/api->services/svc-tenders(4020) for tenders/auctions related reads
Current gateway defaults:
- tenders:
TENDERS_SERVICE_URL ?? http://localhost:4020
- auctions:
AUCTIONS_SERVICE_URL ?? TENDERS_SERVICE_URL ?? http://localhost:4020
Files:
Internal declaration proxy path
The internal Next proxy routes are same-origin browser routes under apps/web/src/app/api/....
Auction/internal allocation-related proxies
These prefer:
AUCTION_DECLARATION_SERVICE_URLTENDERS_SERVICE_URL- fallback
http://localhost:4020
Examples:
/api/auctions/declarations/.../api/auctions/internal/api/output-allocations/...
Tender declaration/internal proxies
These use:
TENDERS_SERVICE_URL- fallback
http://localhost:4020
Examples:
/api/tenders/declarations/.../api/tenders/internal
Files:
- apps/web/src/app/api/auctions/declarations/drafts/route.ts
- apps/web/src/app/api/auctions/internal/route.ts
- apps/web/src/app/api/output-allocations/route.ts
- apps/web/src/app/api/tenders/declarations/drafts/route.ts
- apps/web/src/app/api/tenders/internal/route.ts
For current root dev setup, the intended upstream is:
http://localhost:4020
Recommended local web env:
NEXT_PUBLIC_API_BASE_URL=http://localhost:4001/api/v1
NEXT_PUBLIC_AUTH_GATEWAY_BASE=http://localhost:4001/api/v1/auth
AUCTION_DECLARATION_SERVICE_URL=http://localhost:4020
For direct manual service startup outside dev:one, keep the local web/auth pair aligned:
# services/svc-auth/.env or shell env
FRONTEND_BASE_URL=http://localhost:3000
GOOGLE_OIDC_REDIRECT_URI=http://localhost:3000/auth/google/callback
Auth /me and refresh path
The web auth bootstrap uses:
NEXT_PUBLIC_AUTH_GATEWAY_BASE=http://localhost:4001/api/v1/auth
So:
/auth/me/auth/refresh/auth/login
go through services/api at 4001, not directly to svc-auth.
Files:
Declaration-related live auth role mappings
Live auth permissions are currently derived from:
auth_accounts.role- mapped in services/svc-auth/src/server.ts
Current declaration-related role truth:
-
AUCTION_DECLARERauction:create-draftauction:mark-readyauction:declare
-
TENDER_DECLARER- currently not mapped
- no live permission payload is emitted for this role at the moment
-
MARKET_DECLARERauction:create-draftauction:mark-readyauction:declaretender:create-drafttender:mark-readytender:declare
-
ADMINadmin:access
Important:
admin:accessis not the same as auction/tender declaration capability.- Declaration UI visibility should align to the declaration permission set, not assume
admin:access.
Public vs internal/operator routes
Public
Public routes remain public-only:
GET /auctionsGET /auctions/:idGET /tendersGET /tenders/:id
Public routes must not expose pre-announcement declaration states.
Internal/operator
Internal declaration and registry routes are capability-gated:
/api/auctions/internal/api/auctions/declarations/.../api/output-allocations/.../api/tenders/internal/api/tenders/declarations/...
Internal views may expose:
DRAFTREADY_FOR_ANNOUNCEMENTANNOUNCED
depending on mechanism-specific flow.
Restart rule when env changes
If any of these change:
apps/web/.env.localservices/api/.envservices/svc-tenders/.envservices/svc-auth/.env
restart the affected process at minimum.
Practical rule:
- if web env changes -> restart
apps/web - if gateway env changes -> restart
services/api - if tenders env changes -> restart
services/svc-tenders - if auth env or role mapping changes -> restart
services/svc-auth
If the auth role on a user row changes:
- restart
svc-authonly if code changed - sign out / sign in again to mint a new token with the updated permissions