# adityas1309/raktconnect architecture

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

- Interactive diagram: https://gitdiagram.com/adityas1309/raktconnect
- Repository: https://github.com/adityas1309/raktconnect

## Overview

##### Project type and purpose
- This is a full-stack MERN (MongoDB, Express, React, Node.js) application augmented by a standalone Python AI microservice.
- Purpose: connect hospitals, donors, and patients to manage blood inventory, track donations, forecast demand via AI, and handle blood requests.

##### File structure
- Top-level directories:
- ai-backend – Python service containing app.py, datasets (CSV), and requirements.txt for AI/ML data predictions
- client – React front-end (Vite) with component hierarchy for Auth, Landing, Donor, Hospital, Patient segments; Tailwind CSS, Recharts for visualizations
- server – Node.js/Express back-end with config (DB connection), models (Mongoose schemas), routes (APIs for auth, donor, hospital, patient), utilities (validation), and deployment config (vercel.json)
- Root contains package.json scripts to start client and server concurrently.
- Key patterns:
- Front-end ↔ Back-end via REST APIs
- Back-end ↔ Database via Mongoose (MVC pattern in server/models, server/controllers implicitly in routes)
- Back-end ↔ AI microservice via HTTP (treat ai-backend as separate microservice)

##### README for additional insights
- Architecture described indirectly via “MERN + AI-powered”
- Tech stack lists MongoDB, Express.js, React, Node.js, Recharts, Tailwind CSS, Python for AI
- Features map to three user segments with separate dashboards and analytics

##### Elements
– Clear, consistent labels on each component (e.g., “React Client”, “Express API”, “MongoDB”, “Python AI Service”)
- UI Components (e.g., blue rectangles)
- Microservices (e.g., orange hexagons)
– Notes/annotations for key endpoints (e.g., /api/hospital/inventory, /api/ai/forecast)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External User
    UserBrowser["User Browser"]:::external

    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        ReactClient["React Client"]:::frontend
        MainJS["main.jsx"]:::frontend
        AppJS["App.jsx"]:::frontend
        AuthComponents["Auth Components"]:::frontend
        LandingComponents["Landing Components"]:::frontend
        DonorComponents["Donor Components"]:::frontend
        HospitalComponents["Hospital Components"]:::frontend
        PatientComponents["Patient Components"]:::frontend
        Constants["constants.js"]:::frontend
        ViteConfig["vite.config.js"]:::frontend
    end

    %% API Layer
    subgraph "API Layer"
        direction TB
        ExpressAPI["Express API"]:::backend
        AppJS_Server["app.js"]:::backend
        ConnectDB["connectDB.js"]:::backend
        Models["Mongoose Models"]:::database
        Routes["API Routes"]:::backend
        Validation["validation.js"]:::backend
        VercelConfig["vercel.json"]:::backend
    end

    %% AI Microservice
    subgraph "AI Microservice"
        direction TB
        AIMicroservice["Python AI Service"]:::microservice
        AIApp["app.py"]:::microservice
        AIReqs["requirements.txt"]:::microservice
        AIDatasets["CSV Datasets"]:::microservice
    end

    %% Data Store
    MongoDB["MongoDB Database"]:::database

    %% Connections
    UserBrowser -->|"loads UI"| ReactClient
    ReactClient -->|"/src/main.jsx"| MainJS
    ReactClient -->|"/src/App.jsx"| AppJS
    ReactClient -->|"uses Auth"| AuthComponents
    ReactClient -->|"uses Landing"| LandingComponents
    ReactClient -->|"uses Donor"| DonorComponents
    ReactClient -->|"uses Hospital"| HospitalComponents
    ReactClient -->|"uses Patient"| PatientComponents
    ReactClient -->|"uses constants"| Constants
    ReactClient -->|"config via"| ViteConfig

    ReactClient -->|"HTTP requests"| ExpressAPI
    ExpressAPI -->|"/app.js"| AppJS_Server
    AppJS_Server -->|"connects"| ConnectDB
    AppJS_Server -->|"uses routes"| Routes
    AppJS_Server -->|"uses validation"| Validation
    AppJS_Server -->|"deployment config"| VercelConfig
    Routes -->|"CRUD ops"| Models
    AppJS_Server -->|"stores data"| MongoDB

    AppJS_Server -->|"forwards AI requests"| AIMicroservice
    AIMicroservice -->|"/app.py"| AIApp
    AIMicroservice -->|"dependencies"| AIReqs
    AIApp -->|"loads"| AIDatasets
    AIMicroservice -->|"returns predictions"| AppJS_Server

    %% Click Events
    click ReactClient "https://github.com/adityas1309/raktconnect/tree/main/client/src"
    click MainJS "https://github.com/adityas1309/raktconnect/blob/main/client/src/main.jsx"
    click AppJS "https://github.com/adityas1309/raktconnect/blob/main/client/src/App.jsx"
    click AuthComponents "https://github.com/adityas1309/raktconnect/tree/main/client/src/components/Auth"
    click LandingComponents "https://github.com/adityas1309/raktconnect/tree/main/client/src/components/Landing"
    click DonorComponents "https://github.com/adityas1309/raktconnect/tree/main/client/src/components/donor"
    click HospitalComponents "https://github.com/adityas1309/raktconnect/tree/main/client/src/components/hospital"
    click PatientComponents "https://github.com/adityas1309/raktconnect/tree/main/client/src/components/patient"
    click Constants "https://github.com/adityas1309/raktconnect/blob/main/client/src/utils/constants.js"
    click ViteConfig "https://github.com/adityas1309/raktconnect/blob/main/client/vite.config.js"
    click AppJS_Server "https://github.com/adityas1309/raktconnect/blob/main/server/app.js"
    click ConnectDB "https://github.com/adityas1309/raktconnect/blob/main/server/config/connectDB.js"
    click Models "https://github.com/adityas1309/raktconnect/tree/main/server/models"
    click Routes "https://github.com/adityas1309/raktconnect/tree/main/server/routes"
    click Validation "https://github.com/adityas1309/raktconnect/blob/main/server/utils/validation.js"
    click VercelConfig "https://github.com/adityas1309/raktconnect/blob/main/server/vercel.json"
    click AIApp "https://github.com/adityas1309/raktconnect/blob/main/ai-backend/app.py"
    click AIReqs "https://github.com/adityas1309/raktconnect/blob/main/ai-backend/requirements.txt"
    click AIDatasets "https://github.com/adityas1309/raktconnect/tree/main/ai-backend"

    %% Styles
    classDef frontend fill:#dae8fc,stroke:#6c8ebf,color:#000;
    classDef backend fill:#e2f0d9,stroke:#82b366,color:#000;
    classDef database fill:#f8cecc,stroke:#b85450,color:#000;
    classDef microservice fill:#ffe6cc,stroke:#d08b00,color:#000;
    classDef external fill:#d3d3d3,stroke:#999999,color:#000;
```
