# incubyte/goalcraft architecture

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

- Interactive diagram: https://gitdiagram.com/incubyte/goalcraft
- Repository: https://github.com/incubyte/goalcraft

## Overview

##### Project Type and Purpose
- The project is clearly a full-stack application with two major parts:
- A client-side application (under the “okr-client” folder) built with React, Vite, and Tailwind CSS. This part is responsible for the user interface and experience.
- A server-side application (under the “okr-nest” folder) built using NestJS. It manages APIs, business logic, and communication with the database through Prisma.
- The README reinforces that the goal is to “empower you in setting, tracking, and achieving your goals” and provides separate instructions to start the client and server.

##### File Structure
- For the client (“okr-client”):
- Contains typical frontend assets: components (display, form, modals, UI elements), hooks, context providers, and configuration files.
- The “src” directory is organized into subdirectories for components (with further subfolders for display, form, etc.) and context, suggesting a modular structure.
- For the server (“okr-nest”):
- Uses NestJS’s modular approach. There are dedicated modules for “objectives”, “key-results”, and “rag” (which might be a red-amber-green status module).
- There is a "prisma" folder with schema and migration files – indicating the use of Prisma ORM for database management.
- Test directories (including E2E tests) indicate a focus on service reliability.

a. Main Components:
- User Interface (Frontend): Represented by the React-based okr-client. Illustrate subcomponents like display, form, and modal components alongside context management (e.g., okr-data and okr-form providers).
- API/Backend Service: Represented by the NestJS okr-nest application. Divide it into its core modules:
- Objectives Module (including controllers, services, and DTOs)
- Key Results Module
- Rag Module
- Database Layer: Represented by Prisma-driven database access, as indicated in the “okr-nest/prisma” folder and migration scripts.
- External Services and Tooling: Optionally show how CI/CD (as seen from .github workflows) and testing (E2E and unit tests) integrate into the overall process.

b. Relationships and Interactions:
- The Frontend sends API requests (HTTP REST calls) to the Backend.
- The Backend handles these requests using dedicated controllers and services for objectives, key results, and rag management.
- Interactions flow from the Backend to the Database via Prisma.
- Optionally, include CI/CD pipelines (GitHub workflows) that manage deployment and testing, though these are ancillary to the core user flow.

c. Architectural Patterns and Design Principles:
- Separation of concerns: distinct client and server domains.
- Modularity within both client (with isolated components and context providers) and server (using NestJS modules).
- The server uses dependency injection, a common NestJS pattern, and a clear layered structure (controllers → services → database access). The client uses composable React components accompanied by hooks and context for state management.

d. Technologies and Frameworks:
- Client: React, Vite, Tailwind CSS, with state management built using context and custom hooks.
- Server: NestJS, Prisma for DB interactions, and a modular structure (using controllers, services, etc.).
- Testing frameworks for unit, integration, and E2E tests are also integrated into the project.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side (okr-client)
    subgraph "Client (okr-client)"
        CA1["Client Application (React UI)"]:::client
        subgraph "UI Components"
            D["Display Components"]:::component
            F["Form Components"]:::component
            M1["Key Result Modal"]:::component
            M2["Prompt Modal"]:::component
        end
        subgraph "State Management"
            C1["OKR Data Provider"]:::context
            C2["OKR Form Provider"]:::context
        end
    end

    %% Backend Service (okr-nest)
    subgraph "API/Backend Service (okr-nest)"
        B1["Objectives Module"]:::backend
        B2["Key Results Module"]:::backend
        B3["Rag Module"]:::backend
        B4["Prisma Service"]:::backend
    end

    %% Database Layer (Prisma)
    subgraph "Database Layer"
        DB1["Prisma Schema & Migrations"]:::db
    end

    %% CI/CD and Testing
    subgraph "CI/CD & Testing"
        CI["CI/CD Pipeline"]:::cicd
        T["Backend Testing"]:::test
    end

    %% Internal Client Relationships
    D -->|"updates"| CA1
    F -->|"updates"| CA1
    M1 -->|"triggers"| CA1
    M2 -->|"triggers"| CA1
    C1 -->|"provides"| CA1
    C2 -->|"provides"| CA1

    %% Client to Backend Communication
    CA1 -->|"API_calls"| B1
    CA1 -->|"API_calls"| B2
    CA1 -->|"API_calls"| B3

    %% Backend Module Interactions
    B1 -->|"uses"| B4
    B2 -->|"uses"| B4
    B3 -->|"uses"| B4

    %% Backend to Database
    B4 -->|"queries"| DB1

    %% CI/CD and Testing Interactions with Backend
    CI -->|"deploys&tests"| B1
    CI -->|"deploys&tests"| B2
    CI -->|"deploys&tests"| B3
    T -->|"tests"| B1
    T -->|"tests"| B2
    T -->|"tests"| B3

    %% Click Events
    click CA1 "https://github.com/incubyte/goalcraft/tree/master/okr-client/"
    click D "https://github.com/incubyte/goalcraft/tree/master/okr-client/src/components/display/"
    click F "https://github.com/incubyte/goalcraft/tree/master/okr-client/src/components/form/"
    click M1 "https://github.com/incubyte/goalcraft/tree/master/okr-client/src/components/keyresult-modal/"
    click M2 "https://github.com/incubyte/goalcraft/tree/master/okr-client/src/components/prompt-modal/"
    click C1 "https://github.com/incubyte/goalcraft/tree/master/okr-client/src/context/okr-data/"
    click C2 "https://github.com/incubyte/goalcraft/tree/master/okr-client/src/context/okr-form/"
    click B1 "https://github.com/incubyte/goalcraft/tree/master/okr-nest/src/objectives/"
    click B2 "https://github.com/incubyte/goalcraft/tree/master/okr-nest/src/key-results/"
    click B3 "https://github.com/incubyte/goalcraft/tree/master/okr-nest/src/rag/"
    click B4 "https://github.com/incubyte/goalcraft/tree/master/okr-nest/src/prisma/"
    click DB1 "https://github.com/incubyte/goalcraft/tree/master/okr-nest/prisma/"
    click CI "https://github.com/incubyte/goalcraft/blob/master/.github/workflows/main.yml"
    click T "https://github.com/incubyte/goalcraft/tree/master/okr-nest/test/"

    %% Styles
    classDef client fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef component fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef context fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef backend fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef db fill:#D2B4DE,stroke:#512E5F,stroke-width:2px;
    classDef cicd fill:#FDEBD0,stroke:#D35400,stroke-width:2px;
    classDef test fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
```
