How manuelhettich/medicat works
• A Python-based backend that performs the analysis pipeline, including PDF processing, text extraction, refinement via Large Language Model (LLM) calls, categorization, and CSV generation.
• An iOS client project (MediCat) written in Swift, which likely serves as one of the frontends for interacting with or displaying processed clinical guideline information.
Main components
• Frontend Components:
• iOS Client: Shown by the “iOS” directory containing Swift files (ContentView.swift, FeedView.swift, etc.). This application provides the user interface on mobile and probably consumes backend services.
• (Optional) Web Frontend: Indicated by presence of “templates” and “static” directories and the upload HTML page. This shows that a web-based UI could be available.
• Backend Components:
• Core Application Server: Represented by files like app.py, which likely initializes and runs the web server. Use of gunicorn_config.py hints at deployment with Gunicorn.
• Processing Modules: This includes plaintext2.py for PDF-to-text extraction, chatgpt_calls.py for interacting with the LLM endpoints, generateCSV.py, and stats.py for post-processing reports.
• File Storage: The “uploads” directory holds intermediate and final outputs (e.g., plain_text, paragraphs.txt, evaluated paragraphs) which the system uses as data storage for processing results.
• External Services:
• Custom LLM Endpoints: The README details multiple LLM endpoints used for refining text and categorizing content; these should be shown as external service components.
• OpenAI API: Since an API key is mandatory (OPENAI_API_KEY), indicate the dependency on OpenAI’s API.
• DigitalOcean Deployment: The “.do/deploy.template.yaml” and DigitalOcean deployment button from the README suggest cloud hosting, which can be shown as the deployment environment.
Relationships and Interactions
• The frontend sends a request to the backend server (app.py) through well-defined endpoints (like /process_pdf).
• The backend receives a PDF file upload, and plaintext2.py is used to extract raw text, storing results in the “uploads” directory.
• The extracted text is passed to a refinement module (likely via chatgpt_calls.py) which in turn calls an external LLM endpoint to format and clean the text.
• The refined output is then further processed by categorization and ranking via additional LLM calls, producing outputs like “paragraphs.txt” and “paragraphs_evaluated.txt”, culminating in a CSV file.
• The final results are then returned to the frontend for visualization.
Architectural Patterns and Technologies
• Mention that the system uses a pipeline design, breaking the processing into distinct stages with clear responsibility:
• Extraction → Refinement → Categorization.
• Separation of concerns between the Python backend handling data processing and the iOS/web frontend for user interaction.
• Integration of external services (custom LLM endpoints, OpenAI API) as an essential part of the data processing pipeline.
• Mention the use of a WSGI server (Gunicorn) for deploying the backend.