# Pipeline Algorithm

- ### Basic CRUD Operations

  1. #### Create

     1. The frontend
        - Opens the Prompt Registry pane
        - Validates the payload before sending it to the server
        - Sends a POST request to the backend
     2. The backend
        - receives the request
        - Validates the payload
        - Stores the record in the database
        - Sends a response to the frontend
     3. The frontend
        - Receives the response from the backend
        - Notifies the user of succes or failure

  2. #### Read

     1. The frontend
        - Opens the Prompt Registry pane
        - Sends a GET request to the backend, requesting data
     2. The backend
        - Receives the request
        - Validates the payload
        - Fetches the record from the database
        - Sends a response to the frontend
     3. The frontend
        - Receives the response from the backend
        - Hydrates the Promp Registry

  3. #### Update

     1. The frontend
        - Opens the Prompt Registry pane
        - Makes local changes to an existing record
        - Validates the payload before sending it to the server
        - Sends an UPDATE request to the backend
     2. The backend
        - Receives the request
        - Validates the payload
        - Updates the record in the database
        - Sends a response to the frontend
     3. The frontend
        - Receives the response from the backend
        - Notifies the user of success or failure

  4. #### Delete

     1. The frontend
        - Opens the Prompt Registry pane
        - Locates an existing record
        - Validates the payload before sending it to the server
        - Sends a DELETE request to the backend
     2. The backend
        - Receives the request
        - Validates the payload
        - Deletes the record from the database
        - Sends a response to the frontend
     3. The frontend
        - Receives the response from the backend
        - Notifies the user of success or failure

- ### Compiler Job

  1. #### Frontend Initialization

     - Opens the compiler configuration pane and establishes settings.
     - Opens the terminal and selects the target script.
     - Validates the payload data structure.

  2. #### Job Dispatch

     - Frontend transmits the payload to the server via HTTP POST.
     - Server receives and validates the incoming payload.
     - Server responds with a unique Job ID and begins asynchronous execution.
     - Frontend subscribes to the task by initiating a polling loop (HTTP GET) using the Job ID.

  3. #### Native Compilation

     - Server passes the validated payload to the C++ compiler via Pybind11.
     - Compiler executes the pipeline and saves output artifacts to disk.
     - Compiler returns the execution manifest back across the Pybind11 boundary.

  4. #### State Synchronization

     - Backend receives the manifest and persists it to the database.
     - Frontend polling loop detects the job status transition from "building" to "success".
     - Frontend issues a final GET request to fetch the manifest and hydrate the interface.

- ### Neural Request

  1. #### Frontend Initialization

     - Opens the prompt dashboard.
     - Selects a designated PromptPair and target Python script.
     - Validates the payload data structure.

  2. #### Backend Dispatch

     - Frontend transmits the payload to the server via HTTP POST.
     - Backend receives and validates the incoming request.
     - Backend persists the initial payload state in the database.

  3. #### LLM Execution & Persistence

     - Backend routes the payload to the designated local LLM server via HTTP POST.
     - LLM server processes the prompt and returns the generated inference.
     - Backend receives the inference result and updates the database record.

  4. #### State Synchronization

     - Backend returns the final inference response to the frontend.
     - Frontend renders the comparative results within the dual-pane Inference Window.