cryptoi is a Next.js App Router frontend for the public user-facing product. It handles localized pages, authenticated user state, live updates through Socket.IO, and feed-style review and complaint surfaces.
Install dependencies and start the dev server:
npm install
npm run devOpen http://localhost:3000.
The frontend expects environment variables for backend communication:
NEXT_PUBLIC_API_URL: base URL for REST API requestsNEXT_PUBLIC_SOCKET_URL: base URL for Socket.IO, if different from the current origin
NEXT_PUBLIC_API_URL is also used on the server for SSR fetches in lib/server-api.ts.
Mode is determined by NODE_ENV:
developmentwhen runningnpm run devproductionwhen runningnpm run buildandnpm run start
In production mode, the frontend now enforces secure public URLs:
NEXT_PUBLIC_API_URLmust usehttps://(except localhost)NEXT_PUBLIC_SOCKET_URLmust usehttps://orwss://(except localhost)
If an insecure URL is configured in production, startup/build fails with an explicit error.
npm run dev: start local developmentnpm run build: production buildnpm run start: run the production buildnpm run lint: run ESLint
app/: Next.js routes, layouts, and top-level providersfeatures/: domain-oriented UI, hooks, and API clientsshared/: reusable UI primitives and generic hookslib/: cross-cutting infrastructure such as env access, API wrappers, types, and contextsmessages/: locale message catalogs
- Keep domain behavior in
features/*; uselib/*for shared infrastructure, not feature-specific logic. - Prefer typed API clients over inline
fetchcalls in components. - Keep large interactive components thin by extracting formatting and stateful behavior into hooks, utilities, or focused child components.
- Treat server fetch failures explicitly when the page should distinguish between empty data and backend failure.
Before shipping changes, run:
npm run lint
npx tsc --noEmit- The root route redirects to the default locale.
- Auth state is hydrated through
next-authplus backend cookie checks. - Real-time updates are optional; the UI should remain usable when the socket is unavailable.
- Put
cryptoibehind a CDN that honors originCache-ControlandVary. - Anonymous HTML responses are intended to be cached at the CDN with
s-maxage=180andstale-while-revalidate=900. - Authenticated HTML responses are intentionally
private, no-storeso user state never bleeds across cache keys. - Public API endpoints in the backend now emit explicit edge-cache headers. Endpoints with optional auth vary on
Cookieand downgrade toprivate, no-storewhen auth is present. - Versioned Next assets under
/_next/static/*are served withpublic, max-age=31536000, immutable. - Image derivatives under
/_next/imageare expected to be cached at the CDN withs-maxage=86400andstale-while-revalidate=604800. - Keep CDN cache keys bounded to URL path + query string for public routes, and include cookie/auth context only where the origin already varies on it.
- Treat files in
public/as non-immutable unless they are filename-versioned. Hashed assets should live in the Next build output or use explicit versioned filenames.