# jeffreysanford/craft-fusion architecture

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

- Interactive diagram: https://gitdiagram.com/jeffreysanford/craft-fusion
- Repository: https://github.com/jeffreysanford/craft-fusion

## Overview

##### Project Type & Purpose
- Craft Fusion is a monorepo-managed, modern web application framework that integrates an Angular frontend (craft-web), a NestJS backend (craft-nest), and Go microservices (craft-go). It is built with a focus on performance, scalability, and an excellent developer experience.
- The project leverages Nx for monorepo management and includes integrated testing setups (unit, e2e) and design system tooling.

##### Main Components
A. Angular Frontend (craft-web):
– This is the user interface built in Angular and using Material Design.
– It handles the client-side application and presentation, routing, and user interactions.
– Represent its internal modules such as shared components (user menus, themes, charts, etc.), pages (admin, landing, reports, projects), and utilities.

B. NestJS Backend (craft-nest):
– Acts as the primary API server with type-safe endpoints, authentication, authorization, health monitoring, and business logic.
– Mark dependency injection and service layers that connect to further microservices or third-party APIs.

C. Go Microservices (craft-go):
– A high-performance auxiliary service that likely handles specific tasks such as metrics, OAuth, and record management.
– Include components like HTTP handlers (oauth_handler.go, record_handler.go, metrics_handler.go) and repository integration from craft-go.

D. Nx Monorepo & Tooling:
– Represent that the entire project is managed as one workspace. Note inter-project dependencies and the common tooling for testing, linting, and building.
– Include supporting testing modules (craft-web-e2e and craft-nest-e2e) that help verify the integration and functionality of the system.

E. External/Supporting Elements (Optional if applicable):
– Although not explicitly detailed, you may indicate connections to databases, external APIs (for financial data, for example) or third-party services as “external services” if the project integrates these.
– Include CI/CD pipelines (GitHub workflows) as part of the deployment pipeline for production builds.

##### Relationships & Data Flows
- If necessary, illustrate the integration points from backend components toward external services or databases.
- Nx’s build processes and deployment pipelines feeding into production builds (using outputs from the dist/ directory).

##### Architectural Patterns & Design Principles
– Client (Angular) vs. API (NestJS) vs. Microservices (Go).
- Modularity, where each component (frontend, backend, microservices) is further separated into feature modules or services.
- Dependency injection (especially in NestJS) and clear API boundaries.
- Monorepo organization which simplifies dependency management and testing across projects.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Nx Monorepo & Common Tooling"
        direction TB
        MONOREPO["Workspace"]:::tooling
        NX_CONFIG["Nx Config"]:::tooling
        PKG_CONFIG["Package Config"]:::tooling
        MONOREPO --> NX_CONFIG
        MONOREPO --> PKG_CONFIG
    end

    subgraph "Frontend Layer: Angular (craft-web)"
        direction TB
        ANG["Angular Frontend (craft-web)"]:::frontend
        ANG_PAGES["Pages (admin,landing,reports,projects)"]:::frontend
        ANG_SHARED["Shared Components (user_menus,themes,charts)"]:::frontend
        ANG_UTILS["Utilities"]:::frontend
        ANG --> ANG_PAGES
        ANG --> ANG_SHARED
        ANG --> ANG_UTILS
    end

    subgraph "Backend Layer: NestJS (craft-nest)"
        direction TB
        NJS["NestJS Backend (craft-nest)"]:::backend
        NJS_AUTH["Auth (Authentication/Authorization)"]:::backend
        NJS_LOG["Logging"]:::backend
        NJS_HEALTH["Health Monitoring"]:::backend
        NJS_DOCS["Documents Module"]:::backend
        NJS_FINANCE["Financial Data (alpha-vantage)"]:::backend
        NJS_DOMAIN["Domain Modules (recipes,records,user_management)"]:::backend
        NJS --> NJS_AUTH
        NJS --> NJS_LOG
        NJS --> NJS_HEALTH
        NJS --> NJS_DOCS
        NJS --> NJS_FINANCE
        NJS --> NJS_DOMAIN
    end

    subgraph "Microservices Layer: Go (craft-go)"
        direction TB
        GO["Go Microservices (craft-go)"]:::microservices
        GO_OAUTH["OAuth Handler"]:::microservices
        GO_RECORD["Record Handler"]:::microservices
        GO_METRICS["Metrics Handler"]:::microservices
        GO --> GO_OAUTH
        GO --> GO_RECORD
        GO --> GO_METRICS
    end

    subgraph "Testing & CI/CD"
        direction TB
        T_ANG["Angular End-to-End Tests (craft-web-e2e)"]:::testing
        T_NJS["NestJS End-to-End Tests (craft-nest-e2e)"]:::testing
        CI["CI/CD Pipeline (GitHubActions)"]:::ci
    end

    %% Connect major layers through the workspace
    MONOREPO --> ANG
    MONOREPO --> NJS
    MONOREPO --> GO
    MONOREPO --> T_ANG
    MONOREPO --> T_NJS
    MONOREPO --> CI

    %% Data and control flows
    ANG -->|"API_calls"| NJS
    NJS -->|"Invokes_microservices"| GO
    T_ANG -->|"Tests_UI"| ANG
    T_NJS -->|"Tests_API"| NJS
    CI -->|"Deploys"| MONOREPO

    %% External services used by NestJS Backend
    EXT["External Services/APIs"]:::external
    NJS -->|"Fetches_Data"| EXT

    %% Click Events
    click ANG "https://github.com/jeffreysanford/craft-fusion/tree/master/apps/craft-web"
    click NJS "https://github.com/jeffreysanford/craft-fusion/tree/master/apps/craft-nest"
    click GO "https://github.com/jeffreysanford/craft-fusion/tree/master/apps/craft-go"
    click T_NJS "https://github.com/jeffreysanford/craft-fusion/tree/master/apps/craft-nest-e2e"
    click T_ANG "https://github.com/jeffreysanford/craft-fusion/tree/master/apps/craft-web-e2e"
    click NX_CONFIG "https://github.com/jeffreysanford/craft-fusion/blob/master/nx.json"
    click PKG_CONFIG "https://github.com/jeffreysanford/craft-fusion/blob/master/package.json"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef backend fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef microservices fill:#A9DFBF,stroke:#1E8449,stroke-width:2px;
    classDef testing fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef ci fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef tooling fill:#CCD1D1,stroke:#566573,stroke-width:2px;
    classDef external fill:#FAD7A0,stroke:#D35400,stroke-width:2px;

    class ANG,ANG_PAGES,ANG_SHARED,ANG_UTILS frontend
    class NJS,NJS_AUTH,NJS_LOG,NJS_HEALTH,NJS_DOCS,NJS_FINANCE,NJS_DOMAIN backend
    class GO,GO_OAUTH,GO_RECORD,GO_METRICS microservices
    class T_ANG,T_NJS testing
    class CI ci
    class MONOREPO,NX_CONFIG,PKG_CONFIG tooling
    class EXT external
```
