Skip to main content

Microservice Story Manager

Microservice Story Manager is a Python library for managing user stories and microservices, optimizing story assignments, and visualizing microservice dependencies. It provides tools for organizing user stories, assigning them to microservices, and optimizing these assignments using various algorithms.

Features

  • User Story Management: Create, store, and manage user stories with detailed attributes.
  • Microservice Management: Organize user stories into microservices.
  • Dependency Visualization: Visualize dependencies between microservices based on user story relationships.
  • Genetic Algorithm Assignment: Optimize the assignment of user stories to microservices using genetic algorithms.
  • Customizable Fitness Functions: Define your own criteria for optimal story distribution.
  • Multi-language Support: Error messages available in multiple languages.
  • Metrics Calculation: Calculate various metrics such as coupling, cohesion, granularity, complexity, and semantic similarity.
  • Comparative Analysis: Compare different fitness functions and their impact on microservice architecture.
  • Detailed Visualization: View microservices with their assigned stories, including identifiers and titles.
  • Particle Swarm Optimization: Alternative method for optimizing story assignments using particle swarm optimization.

Installation

You can install the Microservice Story Manager using pip:

Installation

You can install the Microservice Story Manager using pip:

pip install microservice-story-manager

Quickstart

Here's a quick example of how to use the Microservice Story Manager to manage user stories and optimize their assignment to microservices:

from microservice_story_manager import UserStoryManager, MicroserviceManager, MicroserviceVisualizer, GeneticMicroserviceAssigner, FitnessFunctions, MetricsVisualizer

# Initialize managers
user_story_manager = UserStoryManager()
user_story_manager.load_stories_from_csv('path/to/your/stories.csv')

microservice_manager = MicroserviceManager(user_story_manager)

# Create microservices
for _ in range(5):
    microservice_manager.create_microservice()

# Create FitnessFunctions instance
fitness_functions = FitnessFunctions(MicroserviceMetricsManager(microservice_manager))

# Choose fitness functions to compare
functions_to_compare = [
    (fitness_functions.f1, "f1", True),
    (fitness_functions.f2, "f2", True)
]

results = []

for func, name, minimize in functions_to_compare:
    assigner = GeneticMicroserviceAssigner(user_story_manager, microservice_manager, func, minimize)
    optimized_manager, fitness_value, detailed_metrics, story_assignments = assigner.optimize_assignments(generations=20, population_size=50)
    results.append((name, optimized_manager, fitness_value, detailed_metrics, story_assignments))

    print(f"\nResults for fitness function {name}:")
    print(f"Best fitness: {fitness_value}")
    print(f"Detailed metrics: {detailed_metrics}")
    print("\nStory Assignments:")
    for ms_id, stories in story_assignments.items():
        print(f"\nMicroservice {ms_id}:")
        for story in stories:
            print(f"  - {story}")

# Compare metrics
MetricsVisualizer.compare_metrics(results[0][3], results[1][3], results[0][0], results[1][0])

# Compare fitness values
MetricsVisualizer.compare_fitness_values([result[2] for result in results], [result[0] for result in results])

# Visualize the optimized microservices
for name, manager, _, _, _ in results:
    visualizer = MicroserviceVisualizer(manager)
    visualizer.plot_microservices(title=f"Optimized Microservices using {name}")

Detailed Usage

User Story Management

The UserStoryManager class is used to create, store, and manage user stories. You can create user stories manually or load them from a CSV file. Here's an example of how to create a user story:

user_story_manager = UserStoryManager()
user_story_manager.load_stories_from_csv('stories.csv')

Microservice Management

The MicroserviceManager class is used to organize user stories into microservices. You can create microservices manually or let the manager create them for you. Here's an example of how to create microservices:

microservice_manager = MicroserviceManager(user_story_manager)
ms_id = microservice_manager.create_microservice()
microservice_manager.add_story_to_microservice(ms_id, story_id)

Genetic Microservice Assigner

The GeneticMicroserviceAssigner class is used to optimize the assignment of user stories to microservices using genetic algorithms. You can define your own fitness function to determine the optimal assignment. Here's an example of how to use the assigner:

assigner = GeneticMicroserviceAssigner(user_story_manager, microservice_manager)
assigner.optimize_assignment(fitness_function, population_size=100, generations=50)

Particle Swarm Optimization

The ParticleSwarmOptimization class is an alternative method for optimizing story assignments. You can use it in place of the genetic algorithm assigner. Here's an example of how to use the particle swarm optimization:

pso_assigner = PSOMicroserviceAssigner(user_story_manager, microservice_manager)
best_particle = pso_assigner.optimize_assignment(population_size=50, generations=100)
pso_assigner.assign_stories_to_microservices(best_particle)

Microservice Visualizer

The MicroserviceVisualizer class is used to visualize the dependencies between microservices based on user story relationships. Here's an example of how to use the visualizer:

visualizer = MicroserviceVisualizer(microservice_manager)
visualizer.plot_microservices(base_color='lightblue')

Customization

You can customize various aspects of the library:

  • Define your own fitness functions for optimization algorithms.
  • Adjust visualization parameters like colors and node sizes.
  • Implement additional optimization algorithms.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for microservice-story-manager 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for microservice-story-manager 0.2.0
File Size Uploaded Provenance Actions
microservice_story_manager-0.2.0.tar.gz 623.0 kB Without provenance Details for microservice_story_manager-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for microservice-story-manager 0.2.0
File Interpreter ABI Platform Actions
microservice_story_manager-0.2.0-py3-none-any.whl Python 3 none any Details for microservice_story_manager-0.2.0-py3-none-any.whl

Total release size: 1.2 MB

Release files / microservice_story_manager-0.2.0.tar.gz

Download URL microservice_story_manager-0.2.0.tar.gz
Size 623.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c95933ac48f27f675daeb8aca85c6db070ff1528d81100d35cf24bf202df0fa1
BLAKE2b-256 checksum
How to use checksums
876c3bf99c61e4bdcd77010f1293d64fb0f9a73ef1be300a5c719b78f775ac62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.12.0b2 Darwin/23.5.0

Release files / microservice_story_manager-0.2.0-py3-none-any.whl

Download URL microservice_story_manager-0.2.0-py3-none-any.whl
Size 625.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9e5c94906ac249b6394f04440fed29646351d94eaf92455a52fe9f6429379fe
BLAKE2b-256 checksum
How to use checksums
7916d05221ed3dad880e7ea21d30ef15257361e886e7c182ce49c2cc4294c255
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.12.0b2 Darwin/23.5.0

Security for microservice-story-manager 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page