How teresebo/orpha_table works
Project Type and Purpose
• This is a full-stack, single-page Next.js (React) application for building and exporting custom lists of rare diseases (ORPHAcode, ICD-10, names, synonyms) by querying the Orphanet API.
• The app uses Next.js App Router (app/ directory), server-side API routes for proxying external API requests, a React-based frontend for search and table interactions, and in-browser state management (Zustand).
File Structure Analysis
• Top-level assets and settings:
• next.config.mjs, postcss.config.mjs, tailwind.config.js — build & styling configuration
• .eslintrc.json, jest.config.js, jsconfig.json — lint, test, and editor settings
• .github/workflows — CI configuration
• app/ directory (Next.js App Router):
• app/layout.js, app/page.jsx — overall layout and home page
• app/globals.css — global styles
• app/api/* — serverless route handlers (icd10, name, orphacode) and shared utils
• components/ directory:
• searchbox.jsx — search input UI
• result/* — results table UI, action buttons
• selection/* — selected items table, export schema
• ui/* — generic UI primitives (Button, Input, Table, DataTable)
• zustandstore/: state management hooks (e.g., orphastore.js)
• lib/ and utils/: shared utility functions (date formatting, API helpers)
• __tests__ and __testutils__: testing infrastructure for components and pages
README Insights
• Confirms Next.js usage, reliance on ORPHA_API_KEY (via .env)
• Describes user flow: search → display results → select/remove → export JSON/Excel
a. Main Components
• Client Browser (React UI in Next.js)
• Next.js Server (App Router + API Routes)
• External Orphanet REST API
• In-Browser State Store (Zustand)
• Export Module (JSON/Excel generator)
• Configuration (.env for ORPHA_API_KEY)
b. Relationships & Data Flow
1. User enters search in Browser → React SearchBox → triggers fetch() to Next.js API route
2. Next.js API Route (e.g., /api/icd10/[term])
→ reads ORPHA_API_KEY
→ proxies request to Orphanet API
→ receives JSON response → returns to client
3. React UI receives response → renders ResultsTable (components/result)
4. User selects items → dispatch to Zustand store → updates SelectionTable
5. User triggers export → ExportModule reads state → generates file (JSON or Excel) → browser download
c. Architectural Patterns
• Serverless Functions: API routes as thin proxies to external API
• Component-based UI (atomic components in components/ui)
• State management via Zustand (global store decoupled from component tree)
• Separation of concerns: UI → state → API → external services
d. Key Technologies
• Next.js 13 (App Router)
• React + JSX
• Tailwind CSS (styling)
• Zustand (state management)
• Node.js serverless functions (API handlers)
• Excel generation library (via schema in components/selection/excelschema)