# brighteyekid/bloodsync architecture

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

- Interactive diagram: https://gitdiagram.com/brighteyekid/bloodsync
- Repository: https://github.com/brighteyekid/bloodsync

## Overview

##### Project Type & Purpose
- The project is a full-stack blood donation management system. Its purpose is to streamline blood donation operations—from donor interactions, appointment scheduling, to blood request management and real-time inventory updates.

##### File Structure
- Main directories:
- Frontend (located in the root “src” folder and additional configuration files such as tailwind.config.js, tsconfig.json, etc.).
- Backend (located in the “backend” folder) that includes:
▪ API endpoints under “backend/src/api”, with submodules for models and services (e.g., authentication, blood donation, blood request handling, digilocker integration, maps).
▪ Application entry point (“backend/src/app.py”).
▪ Database configuration and migration components under “backend/src/databases” and “backend/src/migrations”.
- Supporting files include build configurations for the frontend (package.json, pnpm-lock.yaml, etc.) and migration-related files for the backend. This clearly shows a separation into presentation (frontend), business logic & API (backend), and persistence (database).

##### Key Components and Their Relationships
a. Frontend Component:
- Developed with React, TypeScript, Tailwind CSS.
- Manages user interactions for donors, administrators, and general site navigation.
- Uses Axios (in “src/api/axios.ts”) for communicating with the backend.
b. Backend/API Component:
- Provides RESTful endpoints to serve data and business logic.
- Contains distinct modules under “api/services” for functionalities such as authentication, blood donation events, blood request processing, external integrations (e.g., digilocker, maps).
- Implements a service layer (possibly influenced by a microservice or layered architecture) to separate models from services.
c. Database and Migrations:
- Database access and configuration are managed in “backend/src/databases/db.py”.
- Migration scripts (found under “backend/src/migrations”) indicate that schema evolution is managed in a controlled manner.
d. External API/Service Integrations:
- Components like “digilocker_integration.py” and “maps.py” suggest connectivity with third-party services (for identity or location-based functionalities).

##### Architectural Patterns & Design Principles
- Separation of Concerns: The project divides responsibilities among the frontend (UI), backend (API business logic), and the database layer.
- Modular Design: Distinct folders for API models, services, and integrations indicate a modular and maintainable architecture.
- RESTful Communication: Clearly defined API endpoints between the frontend and backend.
- Scalability: Use of migrations and dedicated service modules implies that the architecture is built to evolve as the system grows.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        FE["Frontend - React UI"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BE_APP["Backend API - Application Entry Point"]:::backend
        subgraph "Service Modules"
            AUTH["Authentication Service"]:::services
            BDON["Blood Donation Service"]:::services
            BREQ["Blood Request Service"]:::services
            DIGI["Digilocker Integration"]:::services
            MAPS["Maps Integration"]:::services
        end
        MODELS["Data Models"]:::models
        BE_APP -->|"calls_auth_service"| AUTH
        BE_APP -->|"calls_bloodDonation"| BDON
        BE_APP -->|"calls_bloodRequest"| BREQ
        BE_APP -->|"calls_digilocker"| DIGI
        BE_APP -->|"calls_maps"| MAPS
        BE_APP -->|"utilizes_models"| MODELS
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        DB_CONF["Database Configuration (db.py)"]:::database
        DB_MIG["Database Migrations"]:::database
        DB["PostgreSQL Database"]:::database
        DB_CONF -->|"connects_to"| DB
        DB_MIG -->|"manages_schema"| DB
    end

    %% Interactions Between Layers
    FE -->|"API_requests"| BE_APP
    BE_APP -->|"executes_C_R_U_D"| DB_CONF
    BE_APP -->|"triggers_migrations"| DB_MIG

    %% Click Events
    click FE "https://github.com/brighteyekid/bloodsync/tree/main/src"
    click BE_APP "https://github.com/brighteyekid/bloodsync/blob/main/backend/src/app.py"
    click AUTH "https://github.com/brighteyekid/bloodsync/blob/main/backend/src/api/services/auth.py"
    click BDON "https://github.com/brighteyekid/bloodsync/blob/main/backend/src/api/services/blood_donation.py"
    click BREQ "https://github.com/brighteyekid/bloodsync/blob/main/backend/src/api/services/blood_request.py"
    click DIGI "https://github.com/brighteyekid/bloodsync/blob/main/backend/src/api/services/digilocker_integration.py"
    click MAPS "https://github.com/brighteyekid/bloodsync/blob/main/backend/src/api/services/maps.py"
    click MODELS "https://github.com/brighteyekid/bloodsync/blob/main/backend/src/api/models/model_schema.py"
    click DB_CONF "https://github.com/brighteyekid/bloodsync/blob/main/backend/src/databases/db.py"
    click DB_MIG "https://github.com/brighteyekid/bloodsync/tree/main/backend/src/migrations"

    %% Styles
    classDef frontend fill:#FFDDC1,stroke:#F08A5D,stroke-width:2px,color:#000;
    classDef backend fill:#D3E4CD,stroke:#95C623,stroke-width:2px,color:#000;
    classDef services fill:#F9D56E,stroke:#FAB95B,stroke-width:2px,color:#000;
    classDef models fill:#B7E4C7,stroke:#95C623,stroke-width:2px,color:#000;
    classDef database fill:#C9CCD5,stroke:#707B81,stroke-width:2px,color:#000;
```
