# an-ano-nymus/medkit architecture

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

- Interactive diagram: https://gitdiagram.com/an-ano-nymus/medkit
- Repository: https://github.com/an-ano-nymus/medkit

## Overview

##### Project Type & Purpose
- Full-stack medical assistant web application (“MedKit”) offering user authentication, appointment scheduling, medical-report summarization, translation, and related AI-powered pipelines.

##### High-Level Components
- Frontend (React SPA)
- AuthService (Node.js/Express REST API)
- MedicalService (Python microservice for AI/NLP pipelines)
- Database (MongoDB)
- File Storage (local “uploads” folder or S3)
- External APIs (Cerebras NLP, Google Translate/LibreTranslate)

##### Component Responsibilities & Interactions
a. React SPA
- Hosts UI pages (login/signup, dashboard, report upload, translation, appointment UI).
- Sends HTTP(S) requests to AuthService and MedicalService.
b. AuthService (backend/login-signup)
- Exposes routes (authRoutes, appointmentRoute, doctorRoute, medRoutes, translateRoute, otpRoute).
- Implements MVC: models (User, Doctor, Appointment, Report), controllers (authController), routes.
- Manages user sessions, JWT or sessions, sends OTP via SendOTP util.
- Stores user, appointment, report metadata in MongoDB.
- Persists uploaded PDFs in /uploads.
- Optionally orchestrates Python scripts in python_scripts (image_to_text, translator_by_llama).
c. MedicalService (backend/MEDICINE_API)
- Python scripts for:
- PDF/image→text (using Poppler CLI, Tesseract)
- Text summarization (Cerebras NLP, llama_using_api.py)
- Text-to-speech (Text_to_speech.py)
- Embeds a simple static medicine.html interface for manual testing.
- Exposes REST endpoints for report analysis.
d. Database (MongoDB)
- Single cluster storing users, appointments, doctor profiles, report summaries, translations.
e. File Storage
- Local “uploads” folder in AuthService for raw PDFs; accessible by MedicalService.
f. External Services
- Cerebras NLP API for summarization
- Google Translate / LibreTranslate for translations
- (Optional) LangChain orchestration

##### Architectural Patterns & Design Principles
- Micro-services style separation:
- AuthService handles security, scheduling, data persistence
- MedicalService focuses on heavy AI/ML pipelines
- RESTful API layer between frontend and backends
- MVC within Node service; pipeline pattern within Python service
- Single-page-app front end consuming JSON APIs
- Shared file-storage or message exchange (filesystem or message queue) to pass PDF/text between services

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Browser
    Browser["React SPA"]:::frontend
    click Browser "https://github.com/an-ano-nymus/medkit/tree/main/frontend4/"

    %% AuthService
    subgraph "AuthService (Node.js/Express)" 
        direction TB
        Server["server.js"]:::backend
        Env[".env"]:::backend
        DBConfig["config/db.js"]:::backend
        subgraph "Models"
            direction TB
            UserModel["User.js"]:::backend
            AppointmentModel["Appointment.js"]:::backend
            DoctorModel["Doctor.js"]:::backend
            ReportModel["Report.js"]:::backend
        end
        Controllers["authController.js"]:::backend
        subgraph "Routes"
            direction TB
            AuthRoutes["authRoutes.js"]:::backend
            AppointmentRoutes["appointmentRoute.js"]:::backend
            DoctorRoutes["doctorRoute.js"]:::backend
            MedRoutes["medRoutes.js"]:::backend
            TranslateRoutes["translateRoute.js"]:::backend
            OTProutes["otpRoute.js"]:::backend
        end
        Utils["sendOTP.js"]:::backend
        subgraph "Python Scripts"
            direction TB
            IMG2TXT["image_to_text.py"]:::backend
            LlamaAPI["llama_using_api.py"]:::backend
            TranslatorLLM["translator_by_llama.py"]:::backend
            AnalyzePDF["analyze_medical_pdf.py"]:::backend
        end
        Uploads["uploads/"]:::storage
    end

    %% MedicalService
    subgraph "MedicalService (Python AI/NLP)" 
        direction TB
        ImgTxtMS["image_to_text.py"]:::backend
        Summarizer["llama_using_api.py"]:::backend
        TTS["Text_to_speech.py"]:::backend
        HTMLUI["medicine.html"]:::backend
        FilesTest["files_for_test/"]:::storage
    end

    %% Shared Storage and DB
    MongoDB["MongoDB Cluster"]:::db
    FileStorage["uploads/ (Shared)"]:::storage

    %% External APIs
    Cerebras["Cerebras NLP API"]:::external
    TranslateAPI["Google/LibreTranslate"]:::external

    %% Data Flows
    Browser -->|POST /api/auth/*| AuthRoutes
    Browser -->|POST /api/med/analyze| ImgTxtMS
    Browser -->|POST /api/med/translate| TranslatorLLM
    Browser -->|POST /api/med/tts| TTS

    AuthRoutes --> Controllers
    Controllers --> Models
    Controllers --> DBConfig
    Controllers -->|CRUD| MongoDB
    Controllers --> Utils
    Controllers --> Uploads

    IMG2TXT --> Uploads
    ImgTxtMS --> FileStorage
    FilesTest --> ImgTxtMS

    ImgTxtMS --> Summarizer
    Summarizer --> Cerebras
    TranslatorLLM --> TranslateAPI
    TTS -->|optional| Summarizer

    AuthService --> MongoDB
    AuthService --> FileStorage
    MedicalService --> FileStorage

    %% Click Events for AuthService
    click Server "https://github.com/an-ano-nymus/medkit/blob/main/backend/login-signup/server.js"
    click Env "https://github.com/an-ano-nymus/medkit/blob/main/backend/login-signup/.env"
    click DBConfig "https://github.com/an-ano-nymus/medkit/blob/main/backend/login-signup/config/db.js"
    click UserModel "https://github.com/an-ano-nymus/medkit/blob/main/backend/login-signup/models/User.js"
    click AppointmentModel "https://github.com/an-ano-nymus/medkit/blob/main/backend/login-signup/models/Appointment.js"
    click DoctorModel "https://github.com/an-ano-nymus/medkit/blob/main/backend/login-signup/models/Doctor.js"
    click ReportModel "https://github.com/an-ano-nymus/medkit/blob/main/backend/login-signup/models/Report.js"
    click Controllers "https://github.com/an-ano-nymus/medkit/blob/main/backend/login-signup/controllers/authController.js"
    click AuthRoutes "https://github.com/an-ano-nymus/medkit/blob/main/backend/login-signup/routes/authRoutes.js"
    click AppointmentRoutes "https://github.com/an-ano-nymus/medkit/blob/main/backend/login-signup/routes/appointmentRoute.js"
    click DoctorRoutes "https://github.com/an-ano-nymus/medkit/blob/main/backend/login-signup/routes/doctorRoute.js"
    click MedRoutes "https://github.com/an-ano-nymus/medkit/blob/main/backend/login-signup/routes/medRoutes.js"
    click TranslateRoutes "https://github.com/an-ano-nymus/medkit/blob/main/backend/login-signup/routes/translateRoute.js"
    click OTProutes "https://github.com/an-ano-nymus/medkit/blob/main/backend/login-signup/routes/otpRoute.js"
    click Utils "https://github.com/an-ano-nymus/medkit/blob/main/backend/login-signup/utils/sendOTP.js"
    click IMG2TXT "https://github.com/an-ano-nymus/medkit/blob/main/backend/login-signup/python_scripts/image_to_text.py"
    click LlamaAPI "https://github.com/an-ano-nymus/medkit/blob/main/backend/login-signup/python_scripts/llama_using_api.py"
    click TranslatorLLM "https://github.com/an-ano-nymus/medkit/blob/main/backend/login-signup/python_scripts/translator_by_llama.py"
    click AnalyzePDF "https://github.com/an-ano-nymus/medkit/blob/main/backend/login-signup/scripts/analyze_medical_pdf.py"
    click Uploads "https://github.com/an-ano-nymus/medkit/tree/main/backend/login-signup/uploads/"

    %% Click Events for MedicalService
    click ImgTxtMS "https://github.com/an-ano-nymus/medkit/blob/main/backend/MEDICINE_API/image_to_text.py"
    click Summarizer "https://github.com/an-ano-nymus/medkit/blob/main/backend/MEDICINE_API/llama_using_api.py"
    click TTS "https://github.com/an-ano-nymus/medkit/blob/main/backend/MEDICINE_API/Text_to_speech.py"
    click HTMLUI "https://github.com/an-ano-nymus/medkit/blob/main/backend/MEDICINE_API/medicine.html"
    click FilesTest "https://github.com/an-ano-nymus/medkit/tree/main/backend/MEDICINE_API/files_for_test/"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,color:#004085
    classDef backend fill:#d4edda,stroke:#155724,color:#155724
    classDef db fill:#fff3cd,stroke:#856404,color:#856404
    classDef storage fill:#e2e3e5,stroke:#6c757d,color:#6c757d
    classDef external fill:#f8d7da,stroke:#721c24,color:#721c24
```
