Skip to main content

Development Setup

This guide covers setting up a complete development environment for working with the LLM Platform.

Development Tools​

Required Tools​

  • VS Code or Cursor IDE - Recommended editors
  • Node.js 20+ and npm 9+
  • PHP 8.3+ and Composer 2.x
  • Docker Desktop or Colima
  • DDEV for Drupal development
  • PHP Intelephense
  • Drupal Smart Snippets
  • TypeScript/JavaScript
  • ESLint
  • Prettier
  • GitLens

Project Structure​

LLM/
β”œβ”€β”€ _CommonNPM/ # TypeScript/Node.js packages
β”œβ”€β”€ _DrupalSource/ # Drupal modules, themes, recipes
β”œβ”€β”€ llm-platform/ # DDEV development environment
β”œβ”€β”€ Models/ # AI models and training
β”œβ”€β”€ LLM-Tools/ # Infrastructure tools
└── Helm-Charts/ # Kubernetes deployments

TypeScript Development​

Setup​

cd _CommonNPM/[package-name]
npm install
npm run build
npm test

Development Workflow​

# Watch mode for development
npm run dev

# Run tests in watch mode
npm run test:watch

# Check TypeScript types
npm run typecheck

# Lint and format
npm run lint:fix

TDD Workflow​

# Start TDD cycle
npx @bluefly/tddai tdd start

# Write failing test (RED)
npm run test

# Implement code (GREEN)
npm run test

# Refactor (REFACTOR)
npm run test

# Validate coverage
npx @bluefly/tddai validate

Drupal Development​

DDEV Setup​

cd llm-platform
ddev config --project-type=drupal10
ddev start
ddev composer install
ddev drush site:install --existing-config

Module Development​

# Enable a module
ddev drush en module_name -y

# Clear cache
ddev drush cr

# Run updates
ddev drush updb

# Export configuration
ddev drush cex

Syncing Changes​

After making changes in DDEV, sync back to source:

# Sync a module
cp -r web/modules/contrib/module_name/* ../../../_DrupalSource/Modules/module_name/

# Sync configuration
ddev drush cex
cp -r config/sync/* ../../../_DrupalSource/Config/

AI Provider Setup​

Ollama (Local Development)​

# Install Ollama
curl -fsSL https://ollama.com/install.sh | sh

# Start Ollama service
ollama serve

# Pull models
ollama pull llama3.2:7b
ollama pull nomic-embed-text

# Configure in .env
echo "OLLAMA_HOST=http://localhost:11434" >> .env

OpenAI (Alternative)​

# Set API key in .env
echo "OPENAI_API_KEY=your-key-here" >> .env

Database Setup​

Qdrant Vector Database​

# Using Docker
docker run -p 6333:6333 qdrant/qdrant

# Configure in .env
echo "QDRANT_URL=http://localhost:6333" >> .env

Testing​

Run All Tests​

# TypeScript packages
cd _CommonNPM
npm run test:all

# Drupal modules
cd llm-platform
ddev phpunit

Code Coverage​

# Generate coverage report
npm run test:coverage

# View coverage
open coverage/index.html

Debugging​

TypeScript Debugging​

In VS Code, use the included .vscode/launch.json:

{
"type": "node",
"request": "launch",
"name": "Debug TypeScript",
"program": "${workspaceFolder}/src/index.ts",
"preLaunchTask": "tsc: build",
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
}

PHP/Drupal Debugging​

# Enable Xdebug in DDEV
ddev xdebug on

# Configure IDE for port 9003

Git Workflow​

Branch Naming​

  • feature/description - New features
  • fix/description - Bug fixes
  • docs/description - Documentation
  • test/description - Test additions

Commit Messages​

Follow conventional commits:

feat: add new AI provider
fix: resolve connection timeout
docs: update installation guide
test: add coverage for API endpoints

Performance Optimization​

Node.js​

# Profile performance
node --inspect src/index.js

# Memory analysis
node --trace-gc src/index.js

Drupal​

# Enable development settings
ddev drush config:set system.performance css.preprocess 0
ddev drush config:set system.performance js.preprocess 0

# Profile with XHProf
ddev xhprof on

Troubleshooting​

Common Issues​

  1. Port conflicts: Change ports in .env or DDEV config
  2. Permission errors: chmod -R 755 files/
  3. Module not found: ddev composer require
  4. TypeScript errors: npm run clean && npm run build

Getting Help​

Next Steps​