How ayushsalunkhe/medgemma-pillidentification works
Project type and purpose
• This is a single-page, front-end React+TypeScript application built with Vite.
• Purpose: let users upload images of medicine labels, fetch drug details from the FDA API, and translate or enrich content via the Gemini AI API.
File structure
Top level:
• index.html & index.tsx – entry point for the browser.
• App.tsx – root React component.
• vite.config.ts – build and dev-server config.
• package.json & tsconfig.json – dependencies and TS settings.
• .gitignore, metadata.json – misc.
Directories:
• hooks/ – custom hooks (useTranslations).
• services/ – API wrappers (fdaService.ts, geminiService.ts).
• types.ts – shared TypeScript types and interfaces.
README for additional insights
• The app runs locally with npm run dev.
• Requires setting GEMINI_API_KEY in .env.local.
• No server-side code—instead, the front end directly calls external REST and AI APIs.
a. Main components to include:
1) Browser / Client: your React SPA (App.tsx + all components & hooks)
2) Service Layer: fdaService and geminiService modules
3) External APIs:
• FDA Open API for drug information
• Gemini AI API for translation/enrichment
4) Dev/Build Tooling: Vite Dev Server & bundler (for local dev and production builds)
5) Environment Configuration: .env.local with GEMINI_API_KEY
b. Relationships and data flow
• User uploads an image → ImageUploader component captures file →
↓
• fdaService POST/GET to FDA API → returns raw medicine data →
↓
• MedicineInfoCard and SideEffectsChart render FDA data →
↓
• If translation is needed, the TranslationLoader hook calls geminiService → Gemini API → returns translated text → UI updates.
c. Architectural patterns and design principles
• Layered architecture: UI Components → Hooks → Services → External APIs
• Separation of concerns: components handle rendering, services handle external calls, hooks handle orchestration
• Environment-driven configuration: API key injection via Vite’s env mechanism
d. Key technologies and libraries
• React + TypeScript
• Vite (dev server & build)
• FDA Open API (REST)
• Gemini AI API (AI/ML)
• Custom hook pattern (useTranslations)