# Common Development Workflows

This guide provides examples of common software development workflows and how to use the Project Memory system to track them.

## Initial Project Setup

When starting a new project, establish the basic structure in the knowledge graph.

### 1. Create the Project Entity

```json
{
  "name": "create_entities",
  "arguments": {
    "entities": [
      {
        "name": "Weather_App",
        "entityType": "Project",
        "observations": [
          "Mobile weather application with React Native",
          "Started on 2023-10-01",
          "MVP targeted for December 2023"
        ]
      }
    ]
  }
}
```

### 2. Add Core Components

```json
{
  "name": "create_entities",
  "arguments": {
    "entities": [
      {
        "name": "Mobile_Frontend",
        "entityType": "Component",
        "observations": [
          "React Native application for iOS and Android",
          "Uses Expo framework",
          "Implements location-based services"
        ]
      },
      {
        "name": "Weather_API_Service",
        "entityType": "Component",
        "observations": [
          "Node.js backend service",
          "Interfaces with OpenWeatherMap API",
          "Provides caching layer for weather data"
        ]
      }
    ]
  }
}
```

### 3. Define Component Relationships

```json
{
  "name": "create_relations",
  "arguments": {
    "relations": [
      {
        "from": "Weather_App",
        "to": "Mobile_Frontend",
        "relationType": "contains"
      },
      {
        "from": "Weather_App",
        "to": "Weather_API_Service",
        "relationType": "contains"
      },
      {
        "from": "Mobile_Frontend",
        "to": "Weather_API_Service",
        "relationType": "depends_on"
      }
    ]
  }
}
```

## Architecture Decision Process

When making architecture decisions, document them with rationales.

### 1. Record the Decision

```json
{
  "name": "create_entities",
  "arguments": {
    "entities": [
      {
        "name": "Redux_Implementation",
        "entityType": "Decision",
        "observations": [
          "Decision made on 2023-10-15",
          "Chose Redux for state management",
          "Alternatives considered: Context API, MobX, Recoil",
          "Primary factor: Need for complex state with time-travel debugging"
        ]
      }
    ]
  }
}
```

### 2. Link Decision to Components

```json
{
  "name": "create_relations",
  "arguments": {
    "relations": [
      {
        "from": "Mobile_Frontend",
        "to": "Redux_Implementation",
        "relationType": "uses"
      }
    ]
  }
}
```

### 3. Add Technology Entity

```json
{
  "name": "create_entities",
  "arguments": {
    "entities": [
      {
        "name": "Redux",
        "entityType": "Technology",
        "observations": [
          "Version: 4.2.0",
          "Using Redux Toolkit for simplified syntax",
          "Implementing slice pattern for feature organization"
        ]
      }
    ]
  }
}
```

### 4. Link Decision to Technology

```json
{
  "name": "create_relations",
  "arguments": {
    "relations": [
      {
        "from": "Redux_Implementation",
        "to": "Redux",
        "relationType": "led_to"
      },
      {
        "from": "Mobile_Frontend",
        "to": "Redux",
        "relationType": "uses"
      }
    ]
  }
}
```

## Bug Tracking Workflow

When bugs are encountered, track them in the knowledge graph.

### 1. Record Bug with Issue Entity

```json
{
  "name": "record_issue",
  "arguments": {
    "component": "Mobile_Frontend",
    "description": "Location permission denied causes app crash",
    "errorMessage": "TypeError: Cannot read property 'coords' of undefined",
    "status": "Open"
  }
}
```

### 2. Document the Fix

```json
{
  "name": "add_observations",
  "arguments": {
    "observations": [
      {
        "entityName": "Issue_1634567890",
        "contents": [
          "Fixed by adding null check before accessing location.coords",
          "Added graceful fallback to default location",
          "PR #42 implements the fix",
          "Status: Resolved"
        ]
      }
    ]
  }
}
```

## Feature Implementation Workflow

When developing new features, track the implementation details.

### 1. Create Feature Component

```json
{
  "name": "create_entities",
  "arguments": {
    "entities": [
      {
        "name": "Forecast_Chart",
        "entityType": "Component",
        "observations": [
          "7-day forecast visualization with interactive chart",
          "Uses D3.js for rendering",
          "Shows temperature, precipitation, and wind data"
        ]
      }
    ]
  }
}
```

### 2. Link to Parent Component

```json
{
  "name": "create_relations",
  "arguments": {
    "relations": [
      {
        "from": "Mobile_Frontend",
        "to": "Forecast_Chart",
        "relationType": "contains"
      }
    ]
  }
}
```

### 3. Update Implementation Progress

```json
{
  "name": "add_observations",
  "arguments": {
    "observations": [
      {
        "entityName": "Forecast_Chart",
        "contents": [
          "Basic temperature graph implemented",
          "Added responsive sizing for different devices",
          "TODO: Implement precipitation visualization"
        ]
      }
    ]
  }
}
```

## Technical Debt Management

Track technical debt and planned refactorings.

### 1. Document Technical Debt

```json
{
  "name": "create_entities",
  "arguments": {
    "entities": [
      {
        "name": "API_Client_Refactoring",
        "entityType": "Decision",
        "observations": [
          "Current API client implementation has duplicate code",
          "Need to refactor into service classes",
          "Priority: Medium",
          "Planned for Q1 2024"
        ]
      }
    ]
  }
}
```

### 2. Link to Affected Components

```json
{
  "name": "create_relations",
  "arguments": {
    "relations": [
      {
        "from": "Mobile_Frontend",
        "to": "API_Client_Refactoring",
        "relationType": "affected_by"
      }
    ]
  }
}
```

## Project Status Tracking

Track overall project status and milestone achievements.

### 1. Add Project Status

```json
{
  "name": "add_observations",
  "arguments": {
    "observations": [
      {
        "entityName": "Weather_App",
        "contents": [
          "MVP features 50% complete as of Nov 5, 2023",
          "Current focus: location-based forecasts",
          "On track for December release"
        ]
      }
    ]
  }
}
```

### 2. Create Milestone Entity

```json
{
  "name": "create_entities",
  "arguments": {
    "entities": [
      {
        "name": "Beta_Release",
        "entityType": "Milestone",
        "observations": [
          "Target date: November 15, 2023",
          "Requirements: Core weather display, location services, basic forecast",
          "Status: In Progress"
        ]
      }
    ]
  }
}
```

### 3. Link Milestone to Project

```json
{
  "name": "create_relations",
  "arguments": {
    "relations": [
      {
        "from": "Weather_App",
        "to": "Beta_Release",
        "relationType": "contains"
      }
    ]
  }
}
```

## Cross-Project Dependencies

Track dependencies between different projects.

### 1. Create Related Project

```json
{
  "name": "create_entities",
  "arguments": {
    "entities": [
      {
        "name": "Weather_Data_Platform",
        "entityType": "Project",
        "observations": [
          "Backend data aggregation platform",
          "Collects weather data from multiple sources",
          "Provides unified API for weather applications"
        ]
      }
    ]
  }
}
```

### 2. Define Inter-Project Dependencies

```json
{
  "name": "create_relations",
  "arguments": {
    "relations": [
      {
        "from": "Weather_API_Service",
        "to": "Weather_Data_Platform",
        "relationType": "depends_on"
      }
    ]
  }
}
```

## Memory Retrieval Workflows

Use these techniques to retrieve information from the knowledge graph.

### Project Overview

```json
{
  "name": "get_project_overview",
  "arguments": {
    "projectName": "Weather_App"
  }
}
```

### Component Details

```json
{
  "name": "get_related_entities",
  "arguments": {
    "entityName": "Mobile_Frontend",
    "depth": 2
  }
}
```

### Issue History

```json
{
  "name": "find_development_history",
  "arguments": {
    "entity": "Mobile_Frontend",
    "entityType": "Issue",
    "timeframe": "last_month"
  }
}
```

### Technology Stack

```json
{
  "name": "search_nodes",
  "arguments": {
    "query": "Technology"
  }
}
```

### Decision History

```json
{
  "name": "find_development_history",
  "arguments": {
    "entity": "Weather_App",
    "entityType": "Decision"
  }
}
```