# megh2005/med-o-next-hackathon architecture

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

- Interactive diagram: https://gitdiagram.com/megh2005/med-o-next-hackathon
- Repository: https://github.com/megh2005/med-o-next-hackathon

## Overview

##### Main Components Identification
The system consists of five major microservices:
- Med-o-Chat (Real-time consultation system)
- Med-o-Shop (E-commerce platform for medications)
- Med-o-Lens (OCR and document management)
- Med-o-AI (AI-powered medical assistant)
- Med-o-Coach (Health coaching system)

##### Architecture Overview
The system should be represented as a microservices architecture with the following layers:

a) Frontend Layer:
- Next.js applications for each service
- Shared UI components
- Redux state management (visible in med-o-shop)
- Authentication providers

b) Backend Layer:
- API routes for each service
- Database connections
- External service integrations
- Middleware components

##### Detailed Component Breakdown

For each microservice, include:

Med-o-Chat:
- Real-time messaging using Pusher
- MongoDB for message storage
- Redux for state management
- Authentication system
- Language translation service

Med-o-Shop:
- Frontend (Vite + React)
- Backend (Express.js)
- Product management system
- Cart and order processing
- Payment integration
- Admin dashboard

Med-o-AI & Med-o-Lens:
- OCR processing
- AI recommendation engine
- Prescription management
- Cloud storage (Cloudinary)

##### Cross-Cutting Concerns

Shared services:
- Authentication & Authorization
- Database connections
- File storage
- API gateways
- Monitoring and logging

##### Data Flow Representation

- User request flows
- Data synchronization between services
- Authentication flows
- Real-time communication paths

##### Integration Points

Connections with:
- MongoDB database
- Cloudinary
- Firebase
- External APIs
- Payment gateways

##### Deployment Architecture

Deployment structure using:
- Vercel for frontend
- Docker containers
- Kubernetes orchestration
- Load balancers
- CDN integration

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        UI1[UI Components]:::frontend
        UI2[Next.js Apps]:::frontend
        UI3[Redux State]:::frontend
        UI4[Auth Providers]:::frontend
    end

    subgraph "Med-o-Chat"
        MC1[Real-time Integration]:::chat
        MC2[Message Management]:::chat
        MC3[Chat State]:::chat
        MC4[Translation Service]:::chat
        MCD[(MongoDB)]:::database
    end

    subgraph "Med-o-Shop"
        MS1[Frontend Vite+React]:::shop
        MS2[Backend Express.js]:::shop
        MS3[Product Management]:::shop
        MS4[Cart System]:::shop
        MS5[Order Processing]:::shop
        MS6[Admin Dashboard]:::shop
        MSD[(MongoDB)]:::database
    end

    subgraph "Med-o-AI & Med-o-Lens"
        MA1[Prescription Management]:::ai
        MA2[OCR Processing]:::ai
        MA3[AI Recommendations]:::ai
        MA4[Cloudinary Integration]:::ai
    end

    subgraph "Cross-Cutting Services"
        CC1[Authentication]:::service
        CC2[Database Connections]:::service
        CC3[File Storage]:::service
        CC4[API Gateway]:::service
    end

    subgraph "External Services"
        ES1[Pusher]:::external
        ES2[Cloudinary]:::external
        ES3[Payment Gateway]:::external
        ES4[Firebase]:::external
    end

    %% Connections
    UI1 --> UI2
    UI2 --> UI3
    UI2 --> UI4

    UI2 --> MC1
    MC1 --> MC2
    MC2 --> MC3
    MC3 --> MC4
    MC2 --> MCD

    UI2 --> MS1
    MS1 --> MS2
    MS2 --> MS3
    MS2 --> MS4
    MS2 --> MS5
    MS1 --> MS6
    MS2 --> MSD

    UI2 --> MA1
    MA1 --> MA2
    MA2 --> MA3
    MA3 --> MA4

    CC1 -.-> MC1
    CC1 -.-> MS2
    CC1 -.-> MA1
    CC2 -.-> MCD
    CC2 -.-> MSD
    CC3 -.-> MA4

    MA4 --> ES2
    MC1 --> ES1
    MS5 --> ES3
    CC1 --> ES4

    %% Click Events
    click UI1 "https://github.com/Megh2005/Med-o-Next-Hackathon/tree/main/med-o-ai/src/components/ui/"
    click MC1 "https://github.com/Megh2005/Med-o-Next-Hackathon/blob/main/med-o-chat/src/lib/pusher.ts"
    click MC2 "https://github.com/Megh2005/Med-o-Next-Hackathon/blob/main/med-o-chat/src/models/message.model.ts"
    click MC3 "https://github.com/Megh2005/Med-o-Next-Hackathon/tree/main/med-o-chat/src/lib/features/conversations/"
    click MC4 "https://github.com/Megh2005/Med-o-Next-Hackathon/blob/main/med-o-chat/src/types/TranslationRequest.ts"
    click MS1 "https://github.com/Megh2005/Med-o-Next-Hackathon/tree/main/med-o-shop/frontend/"
    click MS2 "https://github.com/Megh2005/Med-o-Next-Hackathon/tree/main/med-o-shop/backend/"
    click MS3 "https://github.com/Megh2005/Med-o-Next-Hackathon/blob/main/med-o-shop/backend/src/controllers/product.controller.ts"
    click MS4 "https://github.com/Megh2005/Med-o-Next-Hackathon/blob/main/med-o-shop/backend/src/controllers/cart.controller.ts"
    click MS5 "https://github.com/Megh2005/Med-o-Next-Hackathon/blob/main/med-o-shop/backend/src/controllers/order.controller.ts"
    click MS6 "https://github.com/Megh2005/Med-o-Next-Hackathon/blob/main/med-o-shop/frontend/src/pages/Admin.tsx"
    click MA1 "https://github.com/Megh2005/Med-o-Next-Hackathon/tree/main/med-o-ai/src/app/api/prescription/"
    click MA2 "https://github.com/Megh2005/Med-o-Next-Hackathon/tree/main/med-o-ai/src/app/api/lens/"
    click MA4 "https://github.com/Megh2005/Med-o-Next-Hackathon/tree/main/med-o-ai/src/lib/cloudinary/"
    click MA3 "https://github.com/Megh2005/Med-o-Next-Hackathon/tree/main/med-o-ai/src/app/api/recommendation/"
    click CC1 "https://github.com/Megh2005/Med-o-Next-Hackathon/tree/main/med-o-ai/src/app/api/auth/"
    click CC2 "https://github.com/Megh2005/Med-o-Next-Hackathon/blob/main/med-o-ai/src/lib/db.ts"
    click CC3 "https://github.com/Megh2005/Med-o-Next-Hackathon/tree/main/med-o-ai/src/lib/cloudinary/"
    click UI3 "https://github.com/Megh2005/Med-o-Next-Hackathon/tree/main/med-o-shop/frontend/src/lib/redux/"

    %% Styles
    classDef frontend fill:#2196F3,color:white
    classDef chat fill:#4CAF50,color:white
    classDef shop fill:#FF9800,color:white
    classDef ai fill:#9C27B0,color:white
    classDef service fill:#607D8B,color:white
    classDef external fill:#F44336,color:white
    classDef database fill:#FFC107,color:black

    %% Legend
    subgraph Legend
        L1[Frontend]:::frontend
        L2[Chat Service]:::chat
        L3[Shop Service]:::shop
        L4[AI Service]:::ai
        L5[Cross-Cutting]:::service
        L6[External]:::external
        L7[(Database)]:::database
    end
```
