# tilakjain619/medtalk architecture

> Architecture diagram of the GitHub repository tilakjain619/medtalk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tilakjain619/medtalk
- Repository: https://github.com/tilakjain619/medtalk

## Overview

##### Project type and purpose
- MedTalk is a full-stack web application: an AI-powered healthcare assistant.
- Purpose: Users upload prescription images; the app extracts medication details via OCR, generates a patient-friendly summary, and provides a conversational chat powered by an LLM to answer follow-up questions.

##### File structure
- Top-level folders:
- client/ – React-based front end
– public, src, components, lib, config files (tsconfig, eslint, Vite).
- server/ – Node.js + Express back end
– app.js entry point, routes (ai.js), utils (OCR & OpenRouter integration), no persistent database.
- Key patterns:
- SPA (single page app) in client
- REST-style API endpoints in server/routes
- External service wrappers in server/utils
- Deployment/config files:
- client/vite.config.mjs, server/package.json, environment variable placeholders (.env for VITE_BACKEND_URL, OPENROUTER_API_KEY).

##### README for additional insights
- Frontend uses React + Tailwind CSS.
- Backend uses Express.
- OCR via Puter.ai.
- AI chat via Google Gemma accessed through the OpenRouter API.
- No database indicated—stateless, real-time processing pipeline.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "React Frontend (client/)"
        direction TB
        Browser["React SPA"]:::frontend
        AppShell["App.jsx"]:::frontend
        MainPanel["MainPanel.jsx"]:::frontend
        Sidebar["Sidebar.jsx"]:::frontend
        ChatUI["Chat.jsx"]:::frontend
        Utils["utils.ts"]:::frontend
        Styles["App.css"]:::frontend
    end

    %% Backend Layer
    subgraph "Express Backend (server/)"
        direction TB
        ExpressAPI["Express API (app.js)"]:::backend
        AIRoutes["ai.js (API Route)"]:::backend
        OpenRouterUtil["openrouter.js"]:::backend
        OCRData["eng.traineddata"]:::backend
        PackageDef["package.json"]:::backend
    end

    %% External Services
    subgraph "External Services"
        direction TB
        OCRService["Puter.ai OCR"]:::external
        AIService["Google Gemma (via OpenRouter)"]:::external
    end

    %% Data Flows
    Browser -->|"POST /upload image"| ExpressAPI
    Browser -->|"POST /chat prompt"| ExpressAPI
    ExpressAPI -->|"calls OCR"| OCRService
    ExpressAPI -->|"calls OpenRouter"| AIService
    OCRService -->|"returns text"| ExpressAPI
    AIService -->|"returns response"| ExpressAPI
    ExpressAPI -->|"JSON payload"| Browser

    %% Click Events - Frontend
    click Browser "https://github.com/tilakjain619/medtalk/tree/main/client/"
    click AppShell "https://github.com/tilakjain619/medtalk/blob/main/client/src/App.jsx"
    click MainPanel "https://github.com/tilakjain619/medtalk/blob/main/client/src/components/MainPanel.jsx"
    click Sidebar "https://github.com/tilakjain619/medtalk/blob/main/client/src/components/Sidebar.jsx"
    click ChatUI "https://github.com/tilakjain619/medtalk/blob/main/client/src/components/Chat.jsx"
    click Utils "https://github.com/tilakjain619/medtalk/blob/main/client/src/lib/utils.ts"
    click Styles "https://github.com/tilakjain619/medtalk/blob/main/client/src/App.css"
    click Browser "https://github.com/tilakjain619/medtalk/blob/main/client/src/main.jsx"
    click Browser "https://github.com/tilakjain619/medtalk/blob/main/client/vite.config.mjs"

    %% Click Events - Backend
    click ExpressAPI "https://github.com/tilakjain619/medtalk/blob/main/server/app.js"
    click AIRoutes "https://github.com/tilakjain619/medtalk/blob/main/server/routes/ai.js"
    click OpenRouterUtil "https://github.com/tilakjain619/medtalk/blob/main/server/utils/openrouter.js"
    click OCRData "https://github.com/tilakjain619/medtalk/blob/main/server/eng.traineddata"
    click PackageDef "https://github.com/tilakjain619/medtalk/blob/main/server/package.json"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef backend fill:#DFF7E0,stroke:#28a745,color:#28a745
    classDef external fill:#FFE8D0,stroke:#d46a08,color:#d46a08
```
