How inbest-inc/inbest-frontend works
Project type and purpose
• This is a Next.js 13 “app”-directory front-end application (“inbest-frontend”) that delivers a stock-portfolio tracking UI, user authentication flows, social features (followers, opinions, posts), and serverless endpoints for generating assets (e.g. logos).
• It is deployed via Cloudflare Pages/Workers (wrangler.toml), uses Tailwind CSS, and stages Vue-style React components for charts, tables, modals, etc.
File structure
• Top-level files:
• next.config.mjs, tsconfig.json, tailwind.config.js → Next.js and build configuration
• wrangler.toml → Cloudflare Workers deployment
• src/app/ → Next.js route handlers and UI pages (app-directory routing)
• /api/getLogo/route.ts → serverless API route
• nested dynamic routes ([username], [portfolio], [postId]) for rendering and management pages
• auth flows: login, register, forgot/reset/verify password and verification pages
• src/components/ → reusable UI building blocks (charts, tables, modals, headers, footers, tooltips)
• src/services/ → modules that wrap REST calls to external backend APIs (userService, portfolioService, followService, socialService, fileUploadService)
• src/lib/ and src/utils/ → utility and helper functions (chart utilities, window resize hook, password/quantity/stock helpers)
• src/config/env.ts → environment variable loader
README for additional insights
• Basic build and dev instructions (pnpm build, pnpm run dev)
• Key public routes for pages and dynamic user/portfolio URLs
• No direct mention of the external backend, implying the frontend’s services point to a separate API domain
a. Main Components
• Client (Browser)
• Next.js App Server (Serverless runtime on Cloudflare Workers)
– Routing & SSR/SSG using the /src/app directory
– API Routes (getLogo)
• CDN / Static Assets (public folder served via Cloudflare)
• External Backend API Services
– Authentication Service
– Portfolio Management Service
– Social / Follow Service
– File Upload / Media Storage Service
• Database(s) (managed by the backend—user store, portfolio store, posts store)
b. Relationships & Interactions
• Client ↔ Next.js Server via HTTPS for page requests, SSR data fetching, CSR hydration
• Next.js Server ↔ External Backend API via REST calls from src/services
• Next.js Serverless API Route (getLogo) ↔ File Upload / Image-Generation Service or CDN
• Client ↔ CDN for static assets (CSS, JS bundles, images)
c. Architectural Patterns & Principles
• Serverless micro-endpoints for on-demand SSR and asset generation
• “App” directory nested routing pattern for domain-centric URL design
• Separation of concerns:
– UI layer (components)
– Data-access layer (services)
– Configuration & utilities (lib, utils, config)
d. Technologies & Frameworks
• Next.js 13 (app router, React, SSR/SSG)
• Cloudflare Workers (wrangler.toml)
• Tailwind CSS for utility-first styling
• pnpm package manager, TypeScript
• External REST APIs for core business logic & persistence
Elements
– Browser → Next.js (page render)
– Next.js → External API (data fetches via services)
– Browser → CDN (static asset fetch)
– Next.js API route → File Upload/Image Service
– Client-side components (Browser, Components library)
– Serverless runtime (Next.js + API routes)
– External services & databases
– Infrastructure (CDN, Cloudflare Workers)