# seanwessmith/medtrack architecture

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

- Interactive diagram: https://gitdiagram.com/seanwessmith/medtrack
- Repository: https://github.com/seanwessmith/medtrack

## Overview

##### Project Overview & Identification
- This project is a full-stack web application (client-side only in this repo) with strong frontend components built using React. It tracks patient medications, detects potential drug interactions from provided CSV datasets, and uses external APIs for medication data along with PostHog analytics.
- The README and file structure indicate that MedTrack emphasizes a responsive UI, live search capabilities, and integrations with external data sources (e.g., public JSON APIs served via R2).

##### File Structure Analysis
- Top-level files like index.html, package.json, and vite.config.ts reveal that the application uses Vite as the build tool.
- The src directory contains key React components including App.tsx, main.tsx, and supporting CSS and TypeScript files that manage the UI logic.
- Assets stored in src/assets (e.g., script.ts) might include custom JavaScript or helper utilities.
- Deployment scripts (deploy-to-cloudflare.sh) and configuration files (wrangler.toml) indicate deployment to Cloudflare Pages or Workers and emphasize integration with Cloudflare’s R2 service.
- CSV files (drugs.csv and interactions.csv) represent the core datasets for medications and potential interactions.

##### Key Components & Architectural Relationships
a. Frontend (Client Side):
- React Application: Main UI rendered via App.tsx and supported by other React components.
- Real-Time Search: Components that query and filter medication data dynamically.

b. Data & External Services:
- Public JSON APIs: Representing the remote endpoints (backed by Cloudflare R2) which provide searchable medication and interaction data.
- CSV Datasets: Local files (drugs.csv, interactions.csv) that might be pre-processed or used to seed the remote data.
- Analytics Service: PostHog is integrated for event tracking and user analytics.

c. Deployment & Build:
- Vite as the bundler and development server.
- Cloudflare deployment configurations (wrangler.toml) indicating the app’s delivery through Cloudflare infrastructure.
- Deployment automation via deploy-to-cloudflare.sh.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Deployment Infrastructure"
        Dep("Vite Bundler & Cloudflare Integration"):::deployment
    end

    subgraph "Frontend/UI Layer"
        RC("React Client (MedTrack UI)"):::frontend
        SU("Tailwind CSS & Helper Scripts"):::frontend
    end

    subgraph "Data & API Layer"
        API("Medication & Interaction API"):::api
        subgraph "CSV Datasets"
            CSV1("drugs.csv")
            CSV2("interactions.csv")
        end
    end

    subgraph "Analytics Layer"
        AN("Analytics Service (PostHog)"):::analytics
    end

    %% Connections
    Dep -->|"builds"| RC
    SU -->|"applies"| RC
    RC -->|"live-search"| API
    RC -->|"event-tracking"| AN
    CSV1 -->|"seeds"| API
    CSV2 -->|"seeds"| API

    %% Click Events for React Client (MedTrack UI)
    click RC "https://github.com/seanwessmith/medtrack/blob/main/src/App.tsx"
    click RC "https://github.com/seanwessmith/medtrack/blob/main/src/main.tsx"

    %% Click Events for CSV Datasets
    click CSV1 "https://github.com/seanwessmith/medtrack/blob/main/drugs.csv"
    click CSV2 "https://github.com/seanwessmith/medtrack/blob/main/interactions.csv"

    %% Click Events for Styling and UI Assets
    click SU "https://github.com/seanwessmith/medtrack/blob/main/src/index.css"
    click SU "https://github.com/seanwessmith/medtrack/blob/main/src/assets/script.ts"

    %% Click Events for Build and Deployment Infrastructure
    click Dep "https://github.com/seanwessmith/medtrack/blob/main/vite.config.ts"
    click Dep "https://github.com/seanwessmith/medtrack/blob/main/deploy-to-cloudflare.sh"
    click Dep "https://github.com/seanwessmith/medtrack/blob/main/wrangler.toml"

    %% Styles
    classDef frontend fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef api fill:#90ee90,stroke:#000,stroke-width:2px;
    classDef analytics fill:#ffcccb,stroke:#000,stroke-width:2px;
    classDef deployment fill:#ffa500,stroke:#000,stroke-width:2px;
```
