How lavanshu5030/xogene-react-assessment works
Project type and purpose
• This is a single-page React application built with Create React App.
• Purpose: provide a user interface for searching drugs, displaying search results, offering spelling suggestions, and showing detailed drug information.
File structure
• Top-level files: package.json (npm scripts & dependencies), README.md, public/ (static HTML & meta), src/ (all React code + tests).
• src/index.js: application entry point.
• src/App.js: root component orchestrating routing between pages.
• src/pages/: page-level components (Home.js for search UI, DrugDetails.js for detail view).
• src/components/: reusable UI components (SearchBar, SearchResults, SpellingSuggestions).
README
• No server side; runs locally with npm start.
• No internal API—implies calls to an external drug API service.
• Typical tech stack: React (UI library), Node/npm (build & dev), Jest/React Testing Library (tests).
Main components
a. Browser / Client
– Static files (index.html, CSS/JS bundle) served by the dev server (or in production, a static file host/CDN).
– Renders the React SPA.
b. React SPA Core
– Root (App component + React Router)
– Pages (Home, DrugDetails)
– UI Components (SearchBar, SearchResults, SpellingSuggestions)
– State management (React state/hooks; unidirectional data flow)
c. External Drug Information API
– Third-party REST or GraphQL service providing search endpoints and drug details.
d. (Optional) Static Asset Host / CDN
– Serves index.html, JS bundle, CSS, manifest, robots.txt.
Relationships and interactions
• On page load, index.html loads bundle → index.js initializes App → React Router picks Home page.
• User types into SearchBar → component state updates → triggers fetch to external API.
• API returns results → fed into SearchResults and SpellingSuggestions.
• User clicks a result → Router navigates to DrugDetails → componentDidMount/useEffect fetches detailed data from API → renders details.
• reportWebVitals can send performance metrics to an analytics endpoint (if configured).
Architectural patterns and design principles
• Component-based architecture: small, reusable UI components.
• Unidirectional data flow via props and hooks.
• Separation of concerns: pages vs. shared components.
• CRA conventions for development, build, and test scripts.
Relevant technologies and frameworks
• React (Function components, hooks)
• Create React App (webpack, Babel, dev server)
• Node.js & npm (dev tooling)
• Jest & React Testing Library (unit/integration tests)
• static hosting (public folder: index.html, manifest.json, robots.txt)