This commit is contained in:
geoffsee
2025-07-11 16:18:34 -04:00
parent 8956579eff
commit 8545aa8699
32 changed files with 4448 additions and 0 deletions

65
examples/README.md Normal file
View File

@@ -0,0 +1,65 @@
# Examples Directory
This directory contains comprehensive examples demonstrating how to use both versions of the professional hierarchy models.
## Structure
- `v1/` - Examples for the simpler 4-layer hierarchy model (Domain → Specialization → Role → Responsibility)
- `v2/` - Examples for the advanced 6-layer hierarchy model (Domain → Industry → Profession → Field → Role → Task)
## Prerequisites
Make sure you have the required dependencies installed:
```bash
bun install
```
For v1 and v2 examples, you'll also need:
```bash
bun add mobx-state-tree mobx uuid
bun add -d @types/uuid
```
## Running Examples
Each example can be run independently using Bun:
```bash
# Run v1 examples
bun run examples/v1/healthcare-example.ts
bun run examples/v1/technology-example.ts
# Run v2 examples
bun run examples/v2/software-company-example.ts
bun run examples/v2/healthcare-system-example.ts
```
## Testing Examples
You can also run the test files to see the examples in action:
```bash
# Test v1 examples
bun test examples/v1/
# Test v2 examples
bun test examples/v2/
```
## Example Scenarios
### V1 Examples (4-layer hierarchy)
- **Healthcare Example**: Models medical professionals with specializations, roles, and responsibilities
- **Technology Example**: Models software engineering domain with various specializations
### V2 Examples (6-layer hierarchy)
- **Software Company Example**: Complete modeling of a tech company's professional structure
- **Healthcare System Example**: Comprehensive healthcare organization modeling
Each example demonstrates:
- Creating and structuring hierarchies
- Adding attributes/skills/tools
- CRUD operations
- Querying and traversing the hierarchy
- Real-world use cases and best practices

View File

@@ -0,0 +1,349 @@
import { ProfessionModel, Domain, Specialization, Role, Responsibility, Attribute } from "../../lib/v1";
console.log("=== Healthcare Professional Hierarchy Example (V1) ===\n");
const professionModel = ProfessionModel.create({
domains: []
});
// Create the Healthcare domain
const healthcareDomain = Domain.create({
name: "Healthcare",
description: "Medical and health services domain",
specializations: [],
coreAttributes: [
{
name: "Medical Ethics",
type: "Trait",
description: "Understanding of medical ethics and patient care principles"
},
{
name: "Communication",
type: "Skill",
description: "Effective communication with patients and colleagues"
},
{
name: "Electronic Health Records",
type: "Tool",
description: "Proficiency with EHR systems"
}
]
});
// Add specializations to Healthcare domain
const cardiology = Specialization.create({
name: "Cardiology",
focus: "Heart and cardiovascular system disorders",
coreAttributes: [
{
name: "Cardiac Catheterization",
type: "Skill",
description: "Performing cardiac catheterization procedures"
},
{
name: "ECG Interpretation",
type: "Skill",
description: "Reading and interpreting electrocardiograms"
},
{
name: "Echocardiogram Machine",
type: "Tool",
description: "Operating echocardiogram equipment"
}
],
roles: []
});
const pediatrics = Specialization.create({
name: "Pediatrics",
focus: "Medical care of infants, children, and adolescents",
coreAttributes: [
{
name: "Child Psychology",
type: "Skill",
description: "Understanding child development and psychology"
},
{
name: "Vaccination Protocols",
type: "Skill",
description: "Knowledge of pediatric vaccination schedules"
},
{
name: "Pediatric Stethoscope",
type: "Tool",
description: "Specialized stethoscope for children"
}
],
roles: []
});
// Create roles for Cardiology
const cardiologist = Role.create({
title: "Cardiologist",
seniority: "Senior",
responsibilities: [],
requiredAttributes: [
{
name: "Board Certification",
type: "Trait",
description: "Board certified in cardiology"
},
{
name: "Surgical Skills",
type: "Skill",
description: "Advanced surgical techniques for cardiac procedures"
}
]
});
const cardiacNurse = Role.create({
title: "Cardiac Nurse",
seniority: "Mid",
responsibilities: [],
requiredAttributes: [
{
name: "Critical Care Experience",
type: "Trait",
description: "Experience in critical care environments"
},
{
name: "Medication Administration",
type: "Skill",
description: "Safe administration of cardiac medications"
}
]
});
// Create responsibilities for Cardiologist
const diagnosisResponsibility = Responsibility.create({
title: "Cardiac Diagnosis",
outcome: "Accurate diagnosis of cardiovascular conditions",
requiredAttributes: [
{
name: "Diagnostic Imaging",
type: "Skill",
description: "Interpreting cardiac imaging studies"
},
{
name: "Clinical Assessment",
type: "Skill",
description: "Comprehensive cardiovascular examination"
}
]
});
const treatmentPlanningResponsibility = Responsibility.create({
title: "Treatment Planning",
outcome: "Comprehensive treatment plans for cardiac patients",
requiredAttributes: [
{
name: "Evidence-Based Medicine",
type: "Skill",
description: "Applying current research to treatment decisions"
},
{
name: "Risk Assessment",
type: "Skill",
description: "Evaluating patient risk factors"
}
]
});
// Create responsibilities for Cardiac Nurse
const patientMonitoringResponsibility = Responsibility.create({
title: "Patient Monitoring",
outcome: "Continuous monitoring of cardiac patients' vital signs and condition",
requiredAttributes: [
{
name: "Telemetry Monitoring",
type: "Skill",
description: "Monitoring cardiac rhythms via telemetry"
},
{
name: "Cardiac Monitor",
type: "Tool",
description: "Operating cardiac monitoring equipment"
}
]
});
// Create roles for Pediatrics
const pediatrician = Role.create({
title: "Pediatrician",
seniority: "Senior",
responsibilities: [],
requiredAttributes: [
{
name: "Pediatric Board Certification",
type: "Trait",
description: "Board certified in pediatrics"
},
{
name: "Developmental Assessment",
type: "Skill",
description: "Assessing child development milestones"
}
]
});
const pediatricNurse = Role.create({
title: "Pediatric Nurse",
seniority: "Mid",
responsibilities: [],
requiredAttributes: [
{
name: "Pediatric Nursing Certification",
type: "Trait",
description: "Certified in pediatric nursing"
},
{
name: "Family Communication",
type: "Skill",
description: "Communicating effectively with children and families"
}
]
});
// Create responsibilities for Pediatrician
const wellChildExamResponsibility = Responsibility.create({
title: "Well-Child Examinations",
outcome: "Regular health assessments and preventive care for children",
requiredAttributes: [
{
name: "Growth Assessment",
type: "Skill",
description: "Evaluating child growth patterns"
},
{
name: "Immunization Knowledge",
type: "Skill",
description: "Current knowledge of vaccination schedules"
}
]
});
const developmentalScreeningResponsibility = Responsibility.create({
title: "Developmental Screening",
outcome: "Early identification of developmental delays or disorders",
requiredAttributes: [
{
name: "Screening Tools",
type: "Tool",
description: "Standardized developmental screening instruments"
},
{
name: "Behavioral Assessment",
type: "Skill",
description: "Assessing child behavior and development"
}
]
});
// Assemble the hierarchy
cardiologist.responsibilities.push(diagnosisResponsibility, treatmentPlanningResponsibility);
cardiacNurse.responsibilities.push(patientMonitoringResponsibility);
pediatrician.responsibilities.push(wellChildExamResponsibility, developmentalScreeningResponsibility);
cardiology.roles.push(cardiologist, cardiacNurse);
pediatrics.roles.push(pediatrician, pediatricNurse);
healthcareDomain.specializations.push(cardiology, pediatrics);
professionModel.domains.push(healthcareDomain);
// Demonstrate the hierarchy
console.log("🏥 Healthcare Domain Structure:");
console.log(`Domain: ${healthcareDomain.name}`);
console.log(`Description: ${healthcareDomain.description}`);
console.log(`Core Attributes: ${healthcareDomain.coreAttributes.length}`);
healthcareDomain.coreAttributes.forEach(attr => {
console.log(` - ${attr.name} (${attr.type}): ${attr.description}`);
});
console.log(`\nSpecializations: ${healthcareDomain.specializations.length}`);
healthcareDomain.specializations.forEach(spec => {
console.log(`\n📋 ${spec.name}`);
console.log(` Focus: ${spec.focus}`);
console.log(` Core Attributes: ${spec.coreAttributes.length}`);
spec.coreAttributes.forEach(attr => {
console.log(` - ${attr.name} (${attr.type}): ${attr.description}`);
});
console.log(` Roles: ${spec.roles.length}`);
spec.roles.forEach(role => {
console.log(`\n 👨‍⚕️ ${role.title} (${role.seniority} Level)`);
console.log(` Required Attributes: ${role.requiredAttributes.length}`);
role.requiredAttributes.forEach(attr => {
console.log(` - ${attr.name} (${attr.type}): ${attr.description}`);
});
console.log(` Responsibilities: ${role.responsibilities.length}`);
role.responsibilities.forEach(resp => {
console.log(`\n 📝 ${resp.title}`);
console.log(` Outcome: ${resp.outcome}`);
console.log(` Required Attributes: ${resp.requiredAttributes.length}`);
resp.requiredAttributes.forEach(attr => {
console.log(` - ${attr.name} (${attr.type}): ${attr.description}`);
});
});
});
});
// Demonstrate querying capabilities
console.log("\n" + "=".repeat(60));
console.log("🔍 QUERYING EXAMPLES");
console.log("=".repeat(60));
// Find all skills across the domain
const allSkills = healthcareDomain.specializations
.flatMap(spec => [
...spec.coreAttributes.filter(attr => attr.type === "Skill"),
...spec.roles.flatMap(role => [
...role.requiredAttributes.filter(attr => attr.type === "Skill"),
...role.responsibilities.flatMap(resp =>
resp.requiredAttributes.filter(attr => attr.type === "Skill")
)
])
]);
console.log(`\n💪 All Skills in Healthcare Domain (${allSkills.length}):`);
allSkills.forEach(skill => {
console.log(` - ${skill.name}: ${skill.description}`);
});
// Find all tools
const allTools = healthcareDomain.specializations
.flatMap(spec => [
...spec.coreAttributes.filter(attr => attr.type === "Tool"),
...spec.roles.flatMap(role => [
...role.requiredAttributes.filter(attr => attr.type === "Tool"),
...role.responsibilities.flatMap(resp =>
resp.requiredAttributes.filter(attr => attr.type === "Tool")
)
])
]);
console.log(`\n🛠 All Tools in Healthcare Domain (${allTools.length}):`);
allTools.forEach(tool => {
console.log(` - ${tool.name}: ${tool.description}`);
});
// Find all senior-level roles
const seniorRoles = healthcareDomain.specializations
.flatMap(spec => spec.roles)
.filter(role => role.seniority === "Senior");
console.log(`\n🎖 Senior-Level Roles (${seniorRoles.length}):`);
seniorRoles.forEach(role => {
console.log(` - ${role.title}`);
});
console.log("\n" + "=".repeat(60));
console.log("✅ Healthcare example completed successfully!");
console.log("=".repeat(60));

View File

@@ -0,0 +1,531 @@
import { ProfessionModel, Domain, Specialization, Role, Responsibility, Attribute } from "../../lib/v1";
console.log("=== Technology Professional Hierarchy Example (V1) ===\n");
const professionModel = ProfessionModel.create({
domains: []
});
// Create the Technology domain
const technologyDomain = Domain.create({
name: "Technology",
description: "Software development and technology services domain",
specializations: [],
coreAttributes: [
{
name: "Problem Solving",
type: "Skill",
description: "Analytical thinking and systematic problem-solving approach"
},
{
name: "Version Control",
type: "Tool",
description: "Proficiency with Git and version control systems"
},
{
name: "Continuous Learning",
type: "Trait",
description: "Commitment to staying current with technology trends"
},
{
name: "Agile Methodology",
type: "Skill",
description: "Understanding of Agile/Scrum development processes"
}
]
});
// Create Web Development specialization
const webDevelopment = Specialization.create({
name: "Web Development",
focus: "Building web applications and websites",
coreAttributes: [
{
name: "HTML/CSS",
type: "Skill",
description: "Markup and styling for web interfaces"
},
{
name: "JavaScript",
type: "Skill",
description: "Client-side and server-side JavaScript programming"
},
{
name: "Web Browser DevTools",
type: "Tool",
description: "Browser developer tools for debugging and optimization"
},
{
name: "Responsive Design",
type: "Skill",
description: "Creating mobile-friendly and adaptive layouts"
}
],
roles: []
});
// Create Data Science specialization
const dataScience = Specialization.create({
name: "Data Science",
focus: "Extracting insights from data using statistical and machine learning methods",
coreAttributes: [
{
name: "Statistical Analysis",
type: "Skill",
description: "Statistical methods and hypothesis testing"
},
{
name: "Python/R",
type: "Skill",
description: "Programming languages for data analysis"
},
{
name: "Jupyter Notebooks",
type: "Tool",
description: "Interactive development environment for data science"
},
{
name: "Data Visualization",
type: "Skill",
description: "Creating meaningful visual representations of data"
}
],
roles: []
});
// Create Mobile Development specialization
const mobileDevelopment = Specialization.create({
name: "Mobile Development",
focus: "Building native and cross-platform mobile applications",
coreAttributes: [
{
name: "Mobile UI/UX",
type: "Skill",
description: "Designing user interfaces for mobile devices"
},
{
name: "App Store Guidelines",
type: "Skill",
description: "Understanding platform-specific app store requirements"
},
{
name: "Mobile Testing Frameworks",
type: "Tool",
description: "Tools for testing mobile applications"
}
],
roles: []
});
// Create roles for Web Development
const frontendDeveloper = Role.create({
title: "Frontend Developer",
seniority: "Mid",
responsibilities: [],
requiredAttributes: [
{
name: "React/Vue/Angular",
type: "Skill",
description: "Modern frontend frameworks"
},
{
name: "Cross-browser Compatibility",
type: "Skill",
description: "Ensuring consistent behavior across different browsers"
},
{
name: "Performance Optimization",
type: "Skill",
description: "Optimizing web application performance"
}
]
});
const fullStackDeveloper = Role.create({
title: "Full Stack Developer",
seniority: "Senior",
responsibilities: [],
requiredAttributes: [
{
name: "Backend Development",
type: "Skill",
description: "Server-side programming and API development"
},
{
name: "Database Design",
type: "Skill",
description: "Designing and optimizing database schemas"
},
{
name: "Cloud Platforms",
type: "Tool",
description: "AWS, Azure, or Google Cloud Platform"
}
]
});
// Create roles for Data Science
const dataAnalyst = Role.create({
title: "Data Analyst",
seniority: "Junior",
responsibilities: [],
requiredAttributes: [
{
name: "SQL",
type: "Skill",
description: "Database querying and data manipulation"
},
{
name: "Excel/Spreadsheets",
type: "Tool",
description: "Advanced spreadsheet analysis"
},
{
name: "Business Intelligence Tools",
type: "Tool",
description: "Tableau, Power BI, or similar BI tools"
}
]
});
const machineLearningEngineer = Role.create({
title: "Machine Learning Engineer",
seniority: "Senior",
responsibilities: [],
requiredAttributes: [
{
name: "Machine Learning Algorithms",
type: "Skill",
description: "Understanding of ML algorithms and their applications"
},
{
name: "Model Deployment",
type: "Skill",
description: "Deploying ML models to production environments"
},
{
name: "TensorFlow/PyTorch",
type: "Tool",
description: "Deep learning frameworks"
}
]
});
// Create roles for Mobile Development
const iosDeveloper = Role.create({
title: "iOS Developer",
seniority: "Mid",
responsibilities: [],
requiredAttributes: [
{
name: "Swift/Objective-C",
type: "Skill",
description: "iOS native programming languages"
},
{
name: "Xcode",
type: "Tool",
description: "Apple's integrated development environment"
},
{
name: "iOS SDK",
type: "Skill",
description: "iOS Software Development Kit and frameworks"
}
]
});
// Create responsibilities for Frontend Developer
const uiImplementationResponsibility = Responsibility.create({
title: "User Interface Implementation",
outcome: "Pixel-perfect, responsive user interfaces that match design specifications",
requiredAttributes: [
{
name: "CSS Frameworks",
type: "Tool",
description: "Bootstrap, Tailwind CSS, or similar frameworks"
},
{
name: "Design Systems",
type: "Skill",
description: "Implementing and maintaining design system components"
}
]
});
const frontendTestingResponsibility = Responsibility.create({
title: "Frontend Testing",
outcome: "Comprehensive test coverage for user interface components",
requiredAttributes: [
{
name: "Jest/Cypress",
type: "Tool",
description: "Frontend testing frameworks"
},
{
name: "Test-Driven Development",
type: "Skill",
description: "Writing tests before implementation"
}
]
});
// Create responsibilities for Full Stack Developer
const apiDevelopmentResponsibility = Responsibility.create({
title: "API Development",
outcome: "Robust, scalable APIs that serve frontend applications",
requiredAttributes: [
{
name: "RESTful Services",
type: "Skill",
description: "Designing and implementing REST APIs"
},
{
name: "API Documentation",
type: "Skill",
description: "Creating comprehensive API documentation"
},
{
name: "Postman/Insomnia",
type: "Tool",
description: "API testing and documentation tools"
}
]
});
const systemArchitectureResponsibility = Responsibility.create({
title: "System Architecture",
outcome: "Scalable, maintainable system architecture decisions",
requiredAttributes: [
{
name: "Microservices",
type: "Skill",
description: "Designing microservice architectures"
},
{
name: "Load Balancing",
type: "Skill",
description: "Implementing load balancing strategies"
},
{
name: "Docker/Kubernetes",
type: "Tool",
description: "Containerization and orchestration tools"
}
]
});
// Create responsibilities for Data Analyst
const dataExplorationResponsibility = Responsibility.create({
title: "Data Exploration",
outcome: "Comprehensive understanding of data patterns and anomalies",
requiredAttributes: [
{
name: "Exploratory Data Analysis",
type: "Skill",
description: "Systematic approach to exploring datasets"
},
{
name: "Data Cleaning",
type: "Skill",
description: "Identifying and correcting data quality issues"
}
]
});
// Create responsibilities for Machine Learning Engineer
const modelDevelopmentResponsibility = Responsibility.create({
title: "Model Development",
outcome: "Accurate, efficient machine learning models for production use",
requiredAttributes: [
{
name: "Feature Engineering",
type: "Skill",
description: "Creating and selecting relevant features for ML models"
},
{
name: "Model Validation",
type: "Skill",
description: "Cross-validation and performance evaluation techniques"
},
{
name: "MLflow/Kubeflow",
type: "Tool",
description: "ML pipeline and experiment tracking tools"
}
]
});
// Create responsibilities for iOS Developer
const iosAppDevelopmentResponsibility = Responsibility.create({
title: "iOS App Development",
outcome: "High-quality iOS applications that meet App Store standards",
requiredAttributes: [
{
name: "UIKit/SwiftUI",
type: "Skill",
description: "iOS user interface frameworks"
},
{
name: "Core Data",
type: "Skill",
description: "iOS data persistence framework"
},
{
name: "App Store Connect",
type: "Tool",
description: "Apple's app distribution platform"
}
]
});
// Assemble the hierarchy
frontendDeveloper.responsibilities.push(uiImplementationResponsibility, frontendTestingResponsibility);
fullStackDeveloper.responsibilities.push(apiDevelopmentResponsibility, systemArchitectureResponsibility);
dataAnalyst.responsibilities.push(dataExplorationResponsibility);
machineLearningEngineer.responsibilities.push(modelDevelopmentResponsibility);
iosDeveloper.responsibilities.push(iosAppDevelopmentResponsibility);
webDevelopment.roles.push(frontendDeveloper, fullStackDeveloper);
dataScience.roles.push(dataAnalyst, machineLearningEngineer);
mobileDevelopment.roles.push(iosDeveloper);
technologyDomain.specializations.push(webDevelopment, dataScience, mobileDevelopment);
professionModel.domains.push(technologyDomain);
// Demonstrate the hierarchy
console.log("💻 Technology Domain Structure:");
console.log(`Domain: ${technologyDomain.name}`);
console.log(`Description: ${technologyDomain.description}`);
console.log(`Core Attributes: ${technologyDomain.coreAttributes.length}`);
technologyDomain.coreAttributes.forEach(attr => {
console.log(` - ${attr.name} (${attr.type}): ${attr.description}`);
});
console.log(`\nSpecializations: ${technologyDomain.specializations.length}`);
technologyDomain.specializations.forEach(spec => {
console.log(`\n🔧 ${spec.name}`);
console.log(` Focus: ${spec.focus}`);
console.log(` Core Attributes: ${spec.coreAttributes.length}`);
spec.coreAttributes.forEach(attr => {
console.log(` - ${attr.name} (${attr.type}): ${attr.description}`);
});
console.log(` Roles: ${spec.roles.length}`);
spec.roles.forEach(role => {
console.log(`\n 👨‍💻 ${role.title} (${role.seniority} Level)`);
console.log(` Required Attributes: ${role.requiredAttributes.length}`);
role.requiredAttributes.forEach(attr => {
console.log(` - ${attr.name} (${attr.type}): ${attr.description}`);
});
console.log(` Responsibilities: ${role.responsibilities.length}`);
role.responsibilities.forEach(resp => {
console.log(`\n 📋 ${resp.title}`);
console.log(` Outcome: ${resp.outcome}`);
console.log(` Required Attributes: ${resp.requiredAttributes.length}`);
resp.requiredAttributes.forEach(attr => {
console.log(` - ${attr.name} (${attr.type}): ${attr.description}`);
});
});
});
});
// Demonstrate advanced querying capabilities
console.log("\n" + "=".repeat(60));
console.log("🔍 ADVANCED QUERYING EXAMPLES");
console.log("=".repeat(60));
// Find all programming languages/frameworks (skills containing common tech terms)
const programmingSkills = technologyDomain.specializations
.flatMap(spec => [
...spec.coreAttributes.filter(attr => attr.type === "Skill"),
...spec.roles.flatMap(role => [
...role.requiredAttributes.filter(attr => attr.type === "Skill"),
...role.responsibilities.flatMap(resp =>
resp.requiredAttributes.filter(attr => attr.type === "Skill")
)
])
])
.filter(skill =>
skill.name.includes("/") ||
skill.name.includes("JavaScript") ||
skill.name.includes("Python") ||
skill.name.includes("Swift") ||
skill.name.includes("SQL")
);
console.log(`\n🚀 Programming Languages & Frameworks (${programmingSkills.length}):`);
programmingSkills.forEach(skill => {
console.log(` - ${skill.name}: ${skill.description}`);
});
// Find all development tools
const developmentTools = technologyDomain.specializations
.flatMap(spec => [
...spec.coreAttributes.filter(attr => attr.type === "Tool"),
...spec.roles.flatMap(role => [
...role.requiredAttributes.filter(attr => attr.type === "Tool"),
...role.responsibilities.flatMap(resp =>
resp.requiredAttributes.filter(attr => attr.type === "Tool")
)
])
]);
console.log(`\n🛠 Development Tools (${developmentTools.length}):`);
developmentTools.forEach(tool => {
console.log(` - ${tool.name}: ${tool.description}`);
});
// Find roles by seniority level
const seniorityLevels = ["Junior", "Mid", "Senior"];
seniorityLevels.forEach(level => {
const rolesAtLevel = technologyDomain.specializations
.flatMap(spec => spec.roles)
.filter(role => role.seniority === level);
if (rolesAtLevel.length > 0) {
console.log(`\n🎯 ${level} Level Roles (${rolesAtLevel.length}):`);
rolesAtLevel.forEach(role => {
console.log(` - ${role.title}`);
});
}
});
// Find specializations with the most roles
const specializationsByRoleCount = technologyDomain.specializations
.map(spec => ({ name: spec.name, roleCount: spec.roles.length }))
.sort((a, b) => b.roleCount - a.roleCount);
console.log(`\n📊 Specializations by Role Count:`);
specializationsByRoleCount.forEach(spec => {
console.log(` - ${spec.name}: ${spec.roleCount} roles`);
});
// Calculate total responsibilities across the domain
const totalResponsibilities = technologyDomain.specializations
.flatMap(spec => spec.roles)
.reduce((total, role) => total + role.responsibilities.length, 0);
console.log(`\n📈 Domain Statistics:`);
console.log(` - Total Specializations: ${technologyDomain.specializations.length}`);
console.log(` - Total Roles: ${technologyDomain.specializations.flatMap(spec => spec.roles).length}`);
console.log(` - Total Responsibilities: ${totalResponsibilities}`);
console.log(` - Total Attributes: ${technologyDomain.coreAttributes.length +
technologyDomain.specializations.reduce((total, spec) =>
total + spec.coreAttributes.length +
spec.roles.reduce((roleTotal, role) =>
roleTotal + role.requiredAttributes.length +
role.responsibilities.reduce((respTotal, resp) =>
respTotal + resp.requiredAttributes.length, 0), 0), 0)}`);
console.log("\n" + "=".repeat(60));
console.log("✅ Technology example completed successfully!");
console.log("=".repeat(60));

View File

@@ -0,0 +1,521 @@
import {
Enterprise,
DomainModel,
IndustryModel,
ProfessionModel,
FieldModel,
RoleModel,
TaskModel
} from "../../lib/v2";
console.log("=== Software Company Professional Hierarchy Example (V2) ===\n");
const enterprise = Enterprise.create({});
enterprise.addDomain({
name: "STEM",
description: "Science, Technology, Engineering, and Mathematics domain"
});
const stemDomain = enterprise.domains[0];
stemDomain.addIndustry({
name: "Software",
description: "Software development and technology services industry"
});
const softwareIndustry = stemDomain.industries[0];
softwareIndustry.addProfession({
name: "Software Engineering",
description: "Design, development, and maintenance of software systems"
});
const softwareEngineering = softwareIndustry.professions[0];
const fieldData = [
{
name: "Backend Development",
description: "Server-side application development, APIs, and database management"
},
{
name: "Frontend Development",
description: "User interface and user experience development"
},
{
name: "DevOps Engineering",
description: "Development operations, CI/CD, and infrastructure management"
},
{
name: "Mobile Development",
description: "Native and cross-platform mobile application development"
},
{
name: "Data Engineering",
description: "Data pipeline development and big data processing"
}
];
fieldData.forEach(field => {
softwareEngineering.addField(field);
});
const [backendField, frontendField, devopsField, mobileField, dataField] = softwareEngineering.fields;
const backendRoles = [
{
title: "Senior Backend Engineer",
summary: "Lead backend development initiatives and mentor junior developers"
},
{
title: "API Developer",
summary: "Design and implement RESTful and GraphQL APIs"
},
{
title: "Database Engineer",
summary: "Design, optimize, and maintain database systems"
}
];
backendRoles.forEach(role => {
backendField.addRole(role);
});
const frontendRoles = [
{
title: "React Developer",
summary: "Build modern web applications using React ecosystem"
},
{
title: "UI/UX Engineer",
summary: "Bridge design and development with focus on user experience"
}
];
frontendRoles.forEach(role => {
frontendField.addRole(role);
});
devopsField.addRole({
title: "DevOps Engineer",
summary: "Manage CI/CD pipelines and cloud infrastructure"
});
devopsField.addRole({
title: "Site Reliability Engineer",
summary: "Ensure system reliability, monitoring, and incident response"
});
mobileField.addRole({
title: "iOS Developer",
summary: "Develop native iOS applications using Swift and iOS SDK"
});
mobileField.addRole({
title: "React Native Developer",
summary: "Build cross-platform mobile apps using React Native"
});
dataField.addRole({
title: "Data Pipeline Engineer",
summary: "Build and maintain data processing pipelines"
});
const seniorBackendEngineer = backendField.roles[0];
const apiDeveloper = backendField.roles[1];
const databaseEngineer = backendField.roles[2];
const seniorBackendTasks = [
{
name: "Design system architecture",
description: "Create scalable and maintainable system architecture designs"
},
{
name: "Code review and mentoring",
description: "Review code submissions and mentor junior team members"
},
{
name: "Performance optimization",
description: "Identify and resolve performance bottlenecks in backend systems"
},
{
name: "Technical documentation",
description: "Create and maintain comprehensive technical documentation"
}
];
seniorBackendTasks.forEach(task => {
seniorBackendEngineer.addTask(task);
});
const apiDeveloperTasks = [
{
name: "Design REST endpoints",
description: "Create RESTful API endpoints following best practices"
},
{
name: "Implement GraphQL resolvers",
description: "Build GraphQL schema and resolver functions"
},
{
name: "API documentation",
description: "Document API endpoints using OpenAPI/Swagger specifications"
},
{
name: "API testing",
description: "Write comprehensive tests for API endpoints"
}
];
apiDeveloperTasks.forEach(task => {
apiDeveloper.addTask(task);
});
const databaseEngineerTasks = [
{
name: "Database schema design",
description: "Design efficient and normalized database schemas"
},
{
name: "Query optimization",
description: "Optimize database queries for better performance"
},
{
name: "Database migration scripts",
description: "Create and manage database migration scripts"
},
{
name: "Backup and recovery procedures",
description: "Implement and maintain database backup and recovery strategies"
}
];
databaseEngineerTasks.forEach(task => {
databaseEngineer.addTask(task);
});
const reactDeveloper = frontendField.roles[0];
const uiuxEngineer = frontendField.roles[1];
const reactDeveloperTasks = [
{
name: "Build React components",
description: "Create reusable and performant React components"
},
{
name: "State management implementation",
description: "Implement state management using Redux, Zustand, or Context API"
},
{
name: "Frontend testing",
description: "Write unit and integration tests for React components"
},
{
name: "Bundle optimization",
description: "Optimize webpack bundles for better performance"
}
];
reactDeveloperTasks.forEach(task => {
reactDeveloper.addTask(task);
});
const uiuxEngineerTasks = [
{
name: "Design system implementation",
description: "Implement and maintain design system components"
},
{
name: "Accessibility compliance",
description: "Ensure applications meet WCAG accessibility standards"
},
{
name: "User experience optimization",
description: "Analyze and improve user interaction patterns"
}
];
uiuxEngineerTasks.forEach(task => {
uiuxEngineer.addTask(task);
});
const devopsEngineer = devopsField.roles[0];
const sreEngineer = devopsField.roles[1];
const devopsEngineerTasks = [
{
name: "CI/CD pipeline setup",
description: "Configure continuous integration and deployment pipelines"
},
{
name: "Infrastructure as Code",
description: "Manage infrastructure using Terraform, CloudFormation, or similar tools"
},
{
name: "Container orchestration",
description: "Deploy and manage applications using Docker and Kubernetes"
},
{
name: "Cloud resource management",
description: "Optimize cloud resource usage and costs"
}
];
devopsEngineerTasks.forEach(task => {
devopsEngineer.addTask(task);
});
const sreEngineerTasks = [
{
name: "Monitoring and alerting",
description: "Set up comprehensive monitoring and alerting systems"
},
{
name: "Incident response",
description: "Respond to and resolve production incidents"
},
{
name: "Capacity planning",
description: "Plan and manage system capacity and scaling"
},
{
name: "Post-mortem analysis",
description: "Conduct post-incident analysis and implement improvements"
}
];
sreEngineerTasks.forEach(task => {
sreEngineer.addTask(task);
});
const iosDeveloper = mobileField.roles[0];
const reactNativeDeveloper = mobileField.roles[1];
const iosDeveloperTasks = [
{
name: "iOS app development",
description: "Build native iOS applications using Swift and UIKit/SwiftUI"
},
{
name: "App Store submission",
description: "Prepare and submit apps to the Apple App Store"
},
{
name: "iOS performance optimization",
description: "Optimize app performance and memory usage"
}
];
iosDeveloperTasks.forEach(task => {
iosDeveloper.addTask(task);
});
const reactNativeDeveloperTasks = [
{
name: "Cross-platform development",
description: "Build apps that work on both iOS and Android platforms"
},
{
name: "Native module integration",
description: "Integrate native iOS and Android modules when needed"
},
{
name: "App performance tuning",
description: "Optimize React Native app performance and bundle size"
}
];
reactNativeDeveloperTasks.forEach(task => {
reactNativeDeveloper.addTask(task);
});
const dataPipelineEngineer = dataField.roles[0];
const dataPipelineEngineerTasks = [
{
name: "ETL pipeline development",
description: "Build Extract, Transform, Load pipelines for data processing"
},
{
name: "Data quality monitoring",
description: "Implement data quality checks and monitoring systems"
},
{
name: "Big data processing",
description: "Process large datasets using Spark, Hadoop, or similar technologies"
},
{
name: "Data warehouse management",
description: "Design and maintain data warehouse schemas and processes"
}
];
dataPipelineEngineerTasks.forEach(task => {
dataPipelineEngineer.addTask(task);
});
console.log("🏢 Software Company Hierarchy Structure:");
console.log("=".repeat(60));
console.log(`\n🌐 Domain: ${stemDomain.name}`);
console.log(` Description: ${stemDomain.description}`);
console.log(` Industries: ${stemDomain.industries.length}`);
stemDomain.industries.forEach(industry => {
console.log(`\n 🏭 Industry: ${industry.name}`);
console.log(` Description: ${industry.description}`);
console.log(` Professions: ${industry.professions.length}`);
industry.professions.forEach(profession => {
console.log(`\n 👨‍💼 Profession: ${profession.name}`);
console.log(` Description: ${profession.description}`);
console.log(` Fields: ${profession.fields.length}`);
profession.fields.forEach(field => {
console.log(`\n 🔧 Field: ${field.name}`);
console.log(` Description: ${field.description}`);
console.log(` Roles: ${field.roles.length}`);
field.roles.forEach(role => {
console.log(`\n 👤 Role: ${role.title}`);
console.log(` Summary: ${role.summary}`);
console.log(` Tasks: ${role.tasks.length}`);
role.tasks.forEach((task, index) => {
console.log(` ${index + 1}. ${task.name}`);
if (task.description) {
console.log(`${task.description}`);
}
});
});
});
});
});
console.log("\n" + "=".repeat(60));
console.log("🔍 V2 ADVANCED FEATURES DEMONSTRATION");
console.log("=".repeat(60));
console.log("\n🆔 UUID Identifiers:");
console.log(`Domain ID: ${stemDomain.id}`);
console.log(`Industry ID: ${softwareIndustry.id}`);
console.log(`Profession ID: ${softwareEngineering.id}`);
console.log(`First Field ID: ${backendField.id}`);
console.log(`First Role ID: ${seniorBackendEngineer.id}`);
console.log(`First Task ID: ${seniorBackendEngineer.tasks[0].id}`);
console.log(`\n📊 All Tasks in Software Industry (${softwareIndustry.allTasks.length}):`);
softwareIndustry.allTasks.forEach((task, index) => {
console.log(`${index + 1}. ${task.name}`);
});
console.log(`\n🔧 Tasks by Field:`);
softwareEngineering.fields.forEach(field => {
console.log(`${field.name}: ${field.allTasks.length} tasks`);
});
console.log("\n⚡ CRUD Operations Demonstration:");
console.log("\n Adding new field: 'Quality Assurance'");
softwareEngineering.addField({
name: "Quality Assurance",
description: "Software testing and quality assurance"
});
const qaField = softwareEngineering.fields[softwareEngineering.fields.length - 1];
console.log(`✅ Added field: ${qaField.name} (ID: ${qaField.id})`);
qaField.addRole({
title: "QA Engineer",
summary: "Ensure software quality through comprehensive testing"
});
const qaEngineer = qaField.roles[0];
console.log(`✅ Added role: ${qaEngineer.title} (ID: ${qaEngineer.id})`);
const qaTasks = [
{
name: "Test case development",
description: "Create comprehensive test cases for software features"
},
{
name: "Automated testing",
description: "Develop and maintain automated test suites"
},
{
name: "Bug reporting and tracking",
description: "Identify, document, and track software defects"
}
];
qaTasks.forEach(task => {
qaEngineer.addTask(task);
});
console.log(`✅ Added ${qaTasks.length} tasks to QA Engineer`);
const firstQATask = qaEngineer.tasks[0];
console.log(`\n✏ Updating task: "${firstQATask.name}"`);
firstQATask.update({
name: "Comprehensive Test Case Development",
description: "Create detailed test cases covering functional, integration, and edge cases"
});
console.log(`✅ Updated to: "${firstQATask.name}"`);
console.log(`\n🗑 Removing last task from QA Engineer`);
const taskToRemove = qaEngineer.tasks[qaEngineer.tasks.length - 1];
console.log(`Removing: "${taskToRemove.name}"`);
qaEngineer.removeTask(taskToRemove);
console.log(`✅ Task removed. QA Engineer now has ${qaEngineer.tasks.length} tasks`);
console.log("\n🔍 Advanced Querying:");
const engineerRoles = softwareEngineering.fields
.flatMap(field => field.roles)
.filter(role => role.title.includes("Engineer"));
console.log(`\n👷 Roles with "Engineer" in title (${engineerRoles.length}):`);
engineerRoles.forEach(role => {
console.log(` - ${role.title}`);
});
const fieldTaskCounts = softwareEngineering.fields
.map(field => ({
name: field.name,
taskCount: field.allTasks.length
}))
.sort((a, b) => b.taskCount - a.taskCount);
console.log(`\n📈 Fields by Task Count:`);
fieldTaskCounts.forEach(field => {
console.log(` - ${field.name}: ${field.taskCount} tasks`);
});
const developmentTasks = enterprise.allTasks
.filter(task =>
task.name.toLowerCase().includes("develop") ||
task.description?.toLowerCase().includes("develop")
);
console.log(`\n💻 Development-related Tasks (${developmentTasks.length}):`);
developmentTasks.forEach(task => {
console.log(` - ${task.name}`);
});
console.log("\n📊 Complete Hierarchy Statistics:");
console.log(` - Domains: ${enterprise.domains.length}`);
console.log(` - Industries: ${enterprise.domains.reduce((sum, d) => sum + d.industries.length, 0)}`);
console.log(` - Professions: ${enterprise.domains.reduce((sum, d) => sum + d.industries.reduce((sum2, i) => sum2 + i.professions.length, 0), 0)}`);
console.log(` - Fields: ${enterprise.domains.reduce((sum, d) => sum + d.industries.reduce((sum2, i) => sum2 + i.professions.reduce((sum3, p) => sum3 + p.fields.length, 0), 0), 0)}`);
console.log(` - Roles: ${enterprise.domains.reduce((sum, d) => sum + d.industries.reduce((sum2, i) => sum2 + i.professions.reduce((sum3, p) => sum3 + p.fields.reduce((sum4, f) => sum4 + f.roles.length, 0), 0), 0), 0)}`);
console.log(` - Tasks: ${enterprise.allTasks.length}`);
console.log("\n" + "=".repeat(60));
console.log("✅ Software Company example completed successfully!");
console.log("This example demonstrates the full 6-layer hierarchy with:");
console.log(" • UUID-based identifiers for distributed systems");
console.log(" • Comprehensive CRUD operations");
console.log(" • Compositional queries and views");
console.log(" • Real-world software company structure");
console.log(" • Advanced querying capabilities");
console.log("=".repeat(60));