# janbriddhi/floatingbloodbank architecture

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

- Interactive diagram: https://gitdiagram.com/janbriddhi/floatingbloodbank
- Repository: https://github.com/janbriddhi/floatingbloodbank

## Overview

##### Project Type and Purpose
- This is a Laravel-based API project designed to manage blood donation activities. It connects three main user groups: Blood Requesters, NGOs, and Super Admin/Staff.
- The API helps handle user registrations, blood requests, donor management, assignment of requests, and administrative oversight—all central to the blood donation process.

##### File Structure for Architectural Insights
- The top-level directories (app, config, database, routes, public, resources) indicate the conventional structure of a Laravel application.
- Key directories include:
- app/Http/Controllers: Contains controllers handling HTTP requests.
- app/Models: Contains the User model (representative of the domain models).
- routes: Files such as api.php and web.php define routing and entry points.
- config: Contains various configuration files (app, database, mail, etc.) that provide insight into the system’s operational parameters.
- database: Includes migrations, seeders, and factories to setup and populate the database.
- Dockerfile, docker-compose.yml, and the docker directory: These indicate containerized deployment with separate definitions for Nginx (web server) and PHP (application server).

##### Key Components to be Represented
a. Client/Request Flow:
- External Clients use endpoints via an API gateway (public/index.php) that initiates requests into the system.
b. Application Layer:
- HTTP Layer: Represented by the Laravel routing mechanism (routes/api.php, routes/web.php).
- Controller Layer: Managed by the Controllers in the app/Http/Controllers directory.
- Business Logic and Domain Models: Handled within Controllers, Models (e.g., app/Models/User.php), and possibly service providers (app/Providers).
c. Data Persistence:
- Database Layer: Shown by the migrations and seeders which map out how data such as users, donor records, and requests are structured and maintained. Although the specific database system isn’t detailed, typical Laravel setups use MySQL or PostgreSQL.
d. Infrastructure and Deployment:
- Dockerized Environment: Include containers for web server (Nginx, based on docker/nginx config files) and the PHP application (configured via docker/php). Additionally, the docker-compose file orchestrates these services.
- Additional build or configuration artifacts (e.g., composer.json, package.json, vite.config.js) that support dependency management and asset bundling.

##### Identification of Relationships and Data Flow
- Request Flow: Show the client initiating a request that goes through the Web Server (Nginx) → Laravel Framework (public/index.php) → Router (routes/api.php/web.php) → Controllers → Models → Database.
- Business Processes: Include flows related to blood request submission, donor management, and administrative operations.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Client Layer
    subgraph "Client Layer"
        Client["External Clients"]:::client
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        NGINX["Nginx Container"]:::infrastructure
        PHP["PHP Container"]:::infrastructure
        Compose["docker-compose.yml"]:::infrastructure
        DOCKERFILE["Dockerfile"]:::infrastructure
    end

    %% Laravel Application Layer
    subgraph "Laravel Application"
        API_GW["API Gateway"]:::laravel
        subgraph "Routing Layer"
            API_Routes["API Routes"]:::laravel
            WEB_Routes["Web Routes"]:::laravel
        end
        Controllers["Controllers"]:::laravel
        ServiceProv["Service Providers"]:::laravel
        DomainModel["Domain Model (User)"]:::laravel
        Config["Configuration"]:::laravel
    end

    %% Data Persistence Layer
    subgraph "Data Persistence"
        Migrations["Migrations"]:::database
        Seeders["Database Seeders"]:::database
        DB["Database"]:::database
    end

    %% Connections
    Client -->|"sends request"| NGINX
    NGINX -->|"forwards request"| API_GW
    API_GW -->|"dispatches to"| API_Routes
    API_GW -->|"dispatches to"| WEB_Routes
    API_Routes --> Controllers
    WEB_Routes --> Controllers
    Controllers -->|"handles logic"| ServiceProv
    Controllers -->|"invokes"| DomainModel
    ServiceProv -->|"loads"| Config
    DomainModel -->|"persists data"| DB
    Migrations --> DB
    Seeders --> DB

    %% Infrastructure internal connection (representing containerized deployment)
    PHP --- API_GW
    NGINX --- PHP
    Compose --- DOCKERFILE

    %% Click Events
    click API_GW "https://github.com/janbriddhi/floatingbloodbank/blob/main/public/index.php"
    click API_Routes "https://github.com/janbriddhi/floatingbloodbank/blob/main/routes/api.php"
    click WEB_Routes "https://github.com/janbriddhi/floatingbloodbank/blob/main/routes/web.php"
    click Controllers "https://github.com/janbriddhi/floatingbloodbank/tree/main/app/Http/Controllers"
    click DomainModel "https://github.com/janbriddhi/floatingbloodbank/blob/main/app/Models/User.php"
    click ServiceProv "https://github.com/janbriddhi/floatingbloodbank/blob/main/app/Providers/AppServiceProvider.php"
    click Migrations "https://github.com/janbriddhi/floatingbloodbank/tree/main/database/migrations"
    click Seeders "https://github.com/janbriddhi/floatingbloodbank/blob/main/database/seeders/DatabaseSeeder.php"
    click NGINX "https://github.com/janbriddhi/floatingbloodbank/blob/main/docker/nginx/laravel.conf"
    click PHP "https://github.com/janbriddhi/floatingbloodbank/blob/main/docker/php/custom.ini"
    click Compose "https://github.com/janbriddhi/floatingbloodbank/blob/main/docker-compose.yml"
    click DOCKERFILE "https://github.com/janbriddhi/floatingbloodbank/tree/main/Dockerfile"
    click Config "https://github.com/janbriddhi/floatingbloodbank/blob/main/config/app.php"

    %% Styles
    classDef client fill:#F9E79F,stroke:#D35400,stroke-width:2px;
    classDef infrastructure fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef laravel fill:#D5F5E3,stroke:#28B463,stroke-width:2px;
    classDef database fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
```
