# bloom-housing/bloom architecture

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

- Interactive diagram: https://gitdiagram.com/bloom-housing/bloom
- Repository: https://github.com/bloom-housing/bloom

## Overview

##### Main Components

a) Frontend Applications:
- Public Site (Next.js application for general public)
- Partners Site (Next.js application for housing developers/managers)
- UI Component Libraries:
- UI Seeds (design system components)
- UI Components (legacy component library)

b) Backend Services:
- NestJS API Server
- Prisma ORM Layer
- PostgreSQL Database

c) Shared Components:
- Shared Helpers Package
- Authentication Services
- File Storage (for assets/images)

**┌─ Client Layer ─────────────────────────────────────┐**
- ┌─ Public Site ─┐  ┌─ Partners Site ┐            │
- (Next.js)   │  │    (Next.js)   │            │
- ┘  └────────────────┘            │
- ┌─ UI Libraries ────────────────────┐            │
- Seeds  │  UI Components Library  │            │
- ┘  │
- Shared Layer ──────────────────────────────────┐  │
- Shared Helpers (Types/Components/Utils)      │  │
- ┘ │

**┌─ API Layer ────────────────────────────────────────┐**
- ┌─ NestJS API Server ────────────────────────┐    │
- Controllers │ Services │ Guards │ DTOs    │    │
- ┘    │
- ┌─ Prisma ORM Layer ─────────────────────────┐    │
- Schema │ Migrations │ Seed Scripts      │    │
- ┘    │
- ┘

**┌─ Data Layer ───────────────────────────────────────┐**
- PostgreSQL Database                      │
- ┘

##### Key Relationships

- One-way dependency from frontends to shared helpers
- Data flow from API through Prisma to PostgreSQL
- Authentication flow across components

##### Additional Elements

- External integrations (email service, SMS service)
- Development tools (Jest, Cypress)
- Deployment paths
- Security boundaries

##### Important Details to Note

- Version control workflow
- API endpoints groups (listings, applications, users)
- Environment configuration flow
- Testing boundaries

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Layer"]
        direction TB
        PublicSite["Public Site\n(Next.js)"]:::frontend
        PartnersSite["Partners Site\n(Next.js)"]:::frontend
        
        subgraph UILibs["UI Libraries"]
            direction TB
            Seeds["UI Seeds"]:::frontend
            UIComponents["UI Components Library"]:::frontend
        end
    end

    subgraph Shared["Shared Layer"]
        direction TB
        SharedHelpers["Shared Helpers\n(Types/Components/Utils)"]:::shared
        AuthHelpers["Auth Helpers"]:::security
    end

    subgraph API["API Layer"]
        direction TB
        subgraph NestJS["NestJS API Server"]
            direction TB
            Controllers["Controllers"]:::api
            Services["Services"]:::api
            Guards["Guards"]:::security
            DTOs["DTOs"]:::api
        end
        
        subgraph PrismaORM["Prisma ORM Layer"]
            direction TB
            Schema["Schema"]:::database
            Migrations["Migrations"]:::database
            SeedScripts["Seed Scripts"]:::database
        end
    end

    subgraph Data["Data Layer"]
        PostgreSQL[(PostgreSQL Database)]:::database
    end

    %% Relationships
    PublicSite <--> Controllers
    PartnersSite <--> Controllers
    PublicSite --> SharedHelpers
    PartnersSite --> SharedHelpers
    Controllers <--> Services
    Services --> Guards
    Services <--> PrismaORM
    PrismaORM <--> PostgreSQL
    Guards <--> AuthHelpers
    
    %% Click Events
    click PublicSite "https://github.com/bloom-housing/bloom/tree/main/sites/public"
    click PartnersSite "https://github.com/bloom-housing/bloom/tree/main/sites/partners"
    click Controllers "https://github.com/bloom-housing/bloom/tree/main/api/src/controllers"
    click Services "https://github.com/bloom-housing/bloom/tree/main/api/src/services"
    click Guards "https://github.com/bloom-housing/bloom/tree/main/api/src/guards"
    click DTOs "https://github.com/bloom-housing/bloom/tree/main/api/src/dtos"
    click Schema "https://github.com/bloom-housing/bloom/blob/main/api/prisma/schema.prisma"
    click Migrations "https://github.com/bloom-housing/bloom/tree/main/api/prisma/migrations"
    click SeedScripts "https://github.com/bloom-housing/bloom/tree/main/api/prisma/seed-helpers"
    click SharedHelpers "https://github.com/bloom-housing/bloom/tree/main/shared-helpers"
    click AuthHelpers "https://github.com/bloom-housing/bloom/tree/main/shared-helpers/src/auth"

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef shared fill:#2ecc71,stroke:#27ae60,color:white
    classDef api fill:#e74c3c,stroke:#c0392b,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef security fill:#9b59b6,stroke:#8e44ad,color:white

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        SharedComp["Shared Component"]:::shared
        APIComp["API Component"]:::api
        DBComp["Database Component"]:::database
        SecurityComp["Security Component"]:::security
    end
```
