How nubplayz/metrofinder-lost-items works
Project type and purpose
• This is a full-stack React/Next.js web application created with create-next-app.
• The “app” directory holds both the frontend UI (pages, layouts, styles) and serverless API routes (app/api/items/route.ts).
• There is also a side “script” folder containing Node.js data-processing scripts and a JSON file (allItems.json), plus a small “liberary” module for filtering logic.
File structure
• Top-level directories:
• app/ – Next.js App Router: UI pages (page.tsx), layout (layout.tsx), global styles, and API routes.
• liberary/ – Shared filtering utilities (filter.ts, linefilter.ts).
• script/ – Separate Node.js scripts for data preparation and JSON output.
• Config files:
• next.config.ts, tsconfig.json, postcss.config.mjs, eslint.config.mjs
• package.json/package-lock.json for dependencies
• No external database directory: data is read from local JSON (script/allItems.json) or computed via library functions.
README
• Confirms use of Next.js with App Router, server-side rendering and API routes.
• Mentions no built-in backend database—likely static or file-based data.
• Deployment target is Vercel (serverless).
Main components and their interactions
a. Browser (Client)
• Sends HTTP requests to Next.js for both page loads (SSR/CSR) and API calls (/api/items).
• Renders React components defined in app/page.tsx and sub-components.
b. Next.js Server (Serverless Functions on Vercel)
• SSR Entry points (the React pages)
• API route handler at app/api/items/route.ts
• Reads / transforms data via the “liberary” module.
c. liberary Module (Business Logic)
• Pure TS functions (filter.ts, linefilter.ts) that apply domain-specific filters to raw data.
• Called by both the API route and potentially by page code (if some filtering is done client-side).
d. Data Source
• Static JSON (script/allItems.json), generated by Node scripts for initial data.
• Node scripts (script/index1.js, uniqueStation.js) run offline or at build time to produce or clean data.
e. Build & Deployment
• Next.js build process (via next.config.ts, PostCSS, TypeScript)
• Hosted on Vercel or comparable platform.
Architectural patterns and design principles
• File-system routing (App Router) for pages & API routes.
• Separation of concerns:
• Presentation layer in app/
• Business logic in liberary/
• Data ingestion in script/
• Serverless, zero-server infrastructure: each API file becomes an AWS Lambda (or Vercel Function).
• Static assets decoupled under public/.
1. Client (Browser)
2. Next.js Frontend (Page components, SSR)
3. Next.js Backend (API Route)
4. Business Logic Module (liberary)
5. Data Source (JSON files, script outputs)
• From Client → Frontend (HTTP GET/POST)
• From Client → API route (fetch to /api/items)
• From API route → liberary functions (function calls/imports)
• From liberary → Data Source (read file or memory)
• Blue rectangles for user-facing components (Browser, React pages)
• Green rectangles for server-side components (API route, business logic)
• Clear labels for all components and directories.
• UI layer
• API layer
• Business-logic layer
• Data layer
• Build/configuration artifacts