# jasonlryan/cmo architecture

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

- Interactive diagram: https://gitdiagram.com/jasonlryan/cmo
- Repository: https://github.com/jasonlryan/cmo

## Overview

##### Project Overview
- The project is the CMO Assessment Tool, a system for evaluating Chief Marketing Officer candidates. It integrates multiple processes such as transcript analysis (using OpenAI), skill scoring, depth level assessment, and generating comprehensive reports.
- The codebase is divided into frontend and backend, with the backend containing the core service logic, configuration files, prompt management, and database integration via Supabase.

##### Main Components
- Frontend – handles UI, interfaces, and user interactions (found in the frontend directory).
- Backend – the core processing area, with subdirectories that include:
- config: Contains benchmark and depth level configurations.
- prompts: Manages OpenAI prompt data and the loader for transcript analysis.
- services: Contains the primary service modules implementing business logic.
- templates: Provides JS templates for generating profiles and reports.
- tests: Contains test cases for backend functionality.
- Documentation and scripts – supporting files that provide guidelines and development utilities.

##### Service Components (in backend/services)
- assessment.js: Likely contains logic to aggregate data, compute assessments, and coordinate scoring.
- openai.js: Handles the integration with the OpenAI API used for analyzing transcripts.
- scoring.js: Implements algorithms to determine candidate scores based on input data.
- startup.js: Likely initializes services and runs any onboarding or startup procedures.
- supabase.js: Manages interactions with Supabase, including data storage or retrieval.

##### Diagramming the Service Components and Their Interactions
- “Config” (configuration files such as benchmarks.json and depthLevels.json).
- “Prompts” (housing OpenAI-related files and promptLoader.js).
- “Services” (the core focus – assessment, openai, scoring, startup, and supabase).
- “Templates” (for generating data structures such as CMO Profiles and reports).
- “Tests” (for validating backend functionality).

- “Assessment Service”: Coordinates the overall candidate evaluation by using inputs from other services.
- “Supabase Service”: Manages persistence by updating or retrieving candidate records. This service might interact with both the Assessment and Scoring services for saving the results.
- “Startup Service”: Handles initialization tasks that ensure all services are properly bootstrapped.

c. Relationships:
- “Prompts” component to the “OpenAI Service,” noting that prompts are loaded using a dedicated promptLoader.
- Optionally, show how “Templates” feed into report generation based on outputs from the “Assessment Service.”

##### Important Architectural Patterns & Design Principles
- Modular design: The backend is separated into distinct units — services, configuration, and prompts — each with a specific responsibility.
- Clear separation of concerns: Each service module (assessment, scoring, openai, startup, supabase) encapsulates its own functionality, which facilitates maintainability and testing.
- Dependency management: Services interact through well-defined interfaces, for example, the Assessment Service consuming outputs from OpenAI and Scoring Services.
- Integration with external APIs: Special emphasis on the OpenAI integration, which is centrally managed through the OpenAI Service, while database operations are abstracted by the Supabase Service.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top Level Components
    A["Frontend UI"]:::frontend
    B["Backend"]:::backend
    
    %% Frontend Click Event
    click A "https://github.com/jasonlryan/cmo/tree/main/frontend/"

    %% Backend Subcomponents
    subgraph "Backend"
        direction TB
        C["Config"]:::config
        D["Prompts"]:::prompt
        E["Services"]:::service
        F["Templates"]:::template
        G["Tests"]:::test
    end

    %% Config Click Events
    click C "https://github.com/jasonlryan/cmo/tree/main/backend/config/"
    click C "https://github.com/jasonlryan/cmo/blob/main/backend/config.js"

    %% Prompts Click Event
    click D "https://github.com/jasonlryan/cmo/tree/main/backend/prompts/"

    %% Templates and Tests Click Events
    click F "https://github.com/jasonlryan/cmo/tree/main/backend/templates/"
    click G "https://github.com/jasonlryan/cmo/tree/main/backend/tests/"

    %% Services Sub-components
    subgraph "Services" 
        direction TB
        H["Assessment Service"]:::service
        I["OpenAI Service"]:::service
        J["Scoring Service"]:::service
        K["Startup Service"]:::service
        L["Supabase Service"]:::service
    end

    %% Services Click Events
    click H "https://github.com/jasonlryan/cmo/blob/main/backend/services/assessment.js"
    click I "https://github.com/jasonlryan/cmo/blob/main/backend/services/openai.js"
    click J "https://github.com/jasonlryan/cmo/blob/main/backend/services/scoring.js"
    click K "https://github.com/jasonlryan/cmo/blob/main/backend/services/startup.js"
    click L "https://github.com/jasonlryan/cmo/blob/main/backend/services/supabase.js"

    %% Relationships between Backend components
    D -->|"providesPrompts"| I
    I -->|"sendsTranscriptData"| J
    H -->|"usesOpenAI"| I
    H -->|"usesScoring"| J
    H -->|"updatesResults"| L
    J -->|"persistsData"| L
    K -->|"initializes"| H
    H -->|"generatesReports"| F

    %% Color styling for nodes
    classDef frontend fill:#FFEBCC,stroke:#B58900,stroke-width:2px;
    classDef backend fill:#E0F7FA,stroke:#00796B,stroke-width:2px;
    classDef config fill:#FFF3E0,stroke:#E65100,stroke-width:2px;
    classDef prompt fill:#E8F5E9,stroke:#2E7D32,stroke-width:2px;
    classDef service fill:#F3E5F5,stroke:#6A1B9A,stroke-width:2px;
    classDef template fill:#E3F2FD,stroke:#1565C0,stroke-width:2px;
    classDef test fill:#FBE9E7,stroke:#D84315,stroke-width:2px;
```
