How nikhil-2x/summerhacks works
1. Overall shape
- This is a Next.js 14 App Router application with a clear split between UI pages/components and server-side route handlers.
- The runtime is TypeScript/React on the frontend, with Next.js API routes handling OCR, AI analysis, chat, auth, and lookup services.
2. Primary user-facing surfaces
- app/page.tsx and components/homeclient.tsx form the main landing/workflow surface for uploading reports and viewing results.
- Separate route pages exist for login, signup, and clinics, so the app is not just a single dashboard; it has distinct entry points for auth and clinic discovery.
3. Core report-processing flow
- The main data path is: user uploads a blood report through components/upload-zone.tsx → server OCR/analysis endpoints process the file → structured results are rendered in components/results-display.tsx, results-panel.tsx, and insights-panel.tsx.
- app/api/verify-ocr/route.ts suggests a correction/validation step after OCR, before or alongside downstream analysis.
4. Server API boundary
- All backend capabilities are exposed via app/api/* route handlers, including:
- /api/analyze for blood report analysis
- /api/analyze-menu for dietary/menu interpretation
- /api/chat for conversational health guidance
- /api/clinics and /api/clinic-details for clinic/specialist lookup
- /api/patient/insight for patient-specific insights
- /api/auth/[...all] for authentication/session endpoints
- This keeps the UI thin and pushes sensitive logic, AI calls, and data access behind server boundaries.
5. AI and OCR subsystem
- lib/glm-ocr.ts and the README indicate OCR plus Google Generative AI-backed interpretation.
- The architecture likely uses OCR to extract text/values from uploaded blood reports, then sends normalized data to AI analysis endpoints that produce structured insights and explanations for the UI.
6. Chat and voice consultation
- components/chat-interface.tsx, chat-drawer.tsx, and /api/chat form the text-chat subsystem.
- components/VoiceDoctor.tsx plus lib/vapi.json indicate a separate real-time voice agent path, integrated with Vapi/Daily-style calling infrastructure for live consultations.
7. Clinic and patient guidance
- The clinic subsystem is separate from the report analysis flow: /api/clinics and /api/clinic-details provide location/specialist information, while /api/patient/insight appears to tailor outputs based on patient context.
- The README’s “nearest specialist healthcare location” feature suggests this is a post-analysis recommendation layer, not part of OCR itself.
8. Authentication and session management
- Auth is implemented with lib/auth.ts, lib/auth-client.ts, and the catch-all auth route.
- The app uses database-backed sessions/accounts via Prisma, so authenticated access is a first-class boundary around analysis history, insights, and possibly exports/chat.
9. Persistence layer
- prisma/schema.prisma and lib/db.ts define the database boundary, with PostgreSQL as the backing store.
- The visible schema emphasis is on auth entities such as User, Session, and Account, which means persistence is likely focused on identity/session state and whatever application records are stored around analysis workflows.
10. Shared UI system
- components/ui/* is a large reusable design system built on Radix UI primitives and styled with Tailwind CSS.
- Higher-level composites like drawers, sheets, dialogs, modals, tables, and charts are used to present results, mobile-friendly insights, and interactive workflows.
11. Export and utility layer
- lib/export-utils.ts plus components/export-modal.tsx suggest a dedicated export path for report outputs and analysis summaries.
- lib/utils.ts and the hook utilities provide common formatting, responsive behavior, and state helpers used across the app.
12. Responsive/mobile behavior
- The presence of mobile-insights-sheet.tsx, drawers, sheets, and hooks/use-mobile.ts shows that the app intentionally splits certain experiences into desktop panels versus mobile overlays.
- This is important for the architecture diagram because insights, chat, and analysis are presented as adaptive UI layers rather than a single fixed layout.
13. Static and supporting assets
- public/ holds static assets, while sample reports/ likely provides demo/test inputs for OCR and analysis flows.
- https/first.http is a manual request file for exercising endpoints during development.
14. Key architectural takeaway
- The repo is organized around a single pipeline: authenticated upload/analysis on the server, AI/OCR enrichment in the middle, and rich client-side presentation on the front end.
- The main boundaries to show in a diagram are: UI shell, API/service layer, persistence/auth, and external AI/voice providers.
Main entry points: homeclient.tsx Home client · ui UI primitives · route.ts Analyze API · db.ts Database
Components 29
Frontend
App Router pages and client components
- Home · Main entry page for upload and report workflow
app/page.tsx - Home client · Orchestrates upload, analysis state, and results display
components/homeclient.tsx - Upload zone · Blood report upload and file intake surface
components/upload-zone.tsx - Results display · Primary structured output for analyzed reports
components/results-display.tsx - Results panel · Tabbed or panel-based presentation of analysis output
components/results-panel.tsx - Insights panel · Clinical insights and interpretation view
components/insights-panel.tsx - Chat interface · Text-based health guidance conversation surface
components/chat-interface.tsx - Chat drawer · Drawer wrapper for chat on smaller screens
components/chat-drawer.tsx - Voice doctor · Real-time voice consultation client
components/VoiceDoctor.tsx - Auth form · Login and signup form component
components/auth/auth-form.tsx - Clinics · Clinic discovery and specialist lookup page
app/clinics/page.tsx - Login · Authentication entry page
app/login/page.tsx - Signup · Account creation entry page
app/signup/page.tsx
Server APIs
Route handlers for OCR, AI, chat, auth, and lookups
- Analyze API · Main report analysis endpoint
app/api/analyze/route.ts - Verify OCR · OCR correction and validation step
app/api/verify-ocr/route.ts - Chat API · Conversational health guidance endpoint
app/api/chat/route.ts - Clinics API · Clinic and specialist lookup endpoint
app/api/clinics/route.ts - Patient insight API · Patient-specific insight generation endpoint
app/api/patient/insight/route.ts - Auth API · Catch-all authentication and session endpoint
app/api/auth/[...all]/route.ts - Menu API · Dietary or menu interpretation endpoint
app/api/analyze-menu/route.ts - Clinic details API · Detailed clinic and specialist lookup endpoint
app/api/clinic-details/route.ts
Platform
Shared libraries, database, and external integration config
- GLM OCR · OCR and text extraction helper
lib/glm-ocr.ts - Auth core · Server auth configuration and session logic
lib/auth.ts - Auth client · Client-side auth helpers
lib/auth-client.ts - Database · Database access boundary
lib/db.ts - Export utils · Report export and formatting helpers
lib/export-utils.ts - Vapi config · Voice-agent integration configuration
lib/vapi.json - Prisma schema · Database schema for auth and app records
prisma/schema.prisma
UI Kit
Reusable design-system primitives
- UI primitives · Reusable Radix/Tailwind component set
components/ui
Connections 27
- Home → Home client: renders · The home page mounts the interactive workflow client
- Home client → Upload zone: uses · Upload area starts the report intake flow
- Home client → Results display: shows · Structured analysis results are rendered in the main view
- Home client → Results panel: routes to · Results can be presented in panel form
- Home client → Insights panel: routes to · Clinical insights are shown as a separate view
- Upload zone → Analyze API: submits to · Uploaded report data is sent for analysis
- Analyze API → GLM OCR: extracts with · OCR is used to read report text and values
- Analyze API → Verify OCR: validates via · OCR output can be corrected or checked before final interpretation
- Analyze API → Database: persists · Analysis-related records and sessions can be stored
- Results display → Export utils: exports · Displayed results can be packaged for export
- Chat interface → Chat API: sends messages to · Text chat is backed by the server chat endpoint
- Chat drawer → Chat interface: wraps · Mobile drawer hosts the chat experience
- Voice doctor → Vapi config: configured by · Voice consultation uses the external voice-agent config
- Clinics → Clinics API: loads · Clinic discovery page fetches lookup data
- Clinics API → Clinic details API: expands to · Detailed clinic information is fetched separately
- Login → Auth form: renders · Login page uses the shared auth form
- Signup → Auth form: renders · Signup page uses the shared auth form
- Auth API → Auth core: uses · Server auth routes are implemented with shared auth logic
- Auth form → Auth client: uses · Forms rely on client-side auth helpers
- Auth core → Database: reads/writes · Auth state is backed by the database
- Database → Prisma schema: defined by · Prisma schema defines the persistence model
- Patient insight API → Database: reads · Patient-specific insights can use stored context
- Menu API → GLM OCR: interprets with · Menu analysis reuses AI/OCR style interpretation helpers
- UI primitives → Home client: supports · The client workflow is built from shared UI primitives
- UI primitives → Chat interface: supports · Chat uses the shared component system
- UI primitives → Results panel: supports · Results views are composed from primitives
- UI primitives → Insights panel: supports · Insights presentation is built on the shared design system