YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
π¬ Mathematical Optimization of Hybrid Software Architectures
Balancing Coupling and Cohesion β INPT Β· CEDoc 2TI Β· SEEDS Research Team
Supervisor: Prof. Driss ALLAKI Β· Duration: 2 months Β· Team: 2β3 interns
π Project Overview
Modern software systems increasingly blend monolithic and microservice paradigms. While monoliths offer simplicity and maintainability, microservices bring scalability and independence. The challenge lies in how to split a system β poor decomposition creates tight inter-module coupling and weak intra-module cohesion, making systems brittle and hard to evolve.
This project builds a mathematically grounded decision-support tool that recommends optimal hybrid architectures. We model a software system as a weighted dependency graph and use combinatorial optimization to find component groupings that maximize cohesion within clusters and minimize coupling across them.
π Results Summary
All three methods successfully recover the ground-truth decomposition:
| Metric | Spectral | Genetic Algorithm | Louvain | Ground Truth |
|---|---|---|---|---|
| Modularity Q | 0.7571 | 0.7571 | 0.7571 | 0.7571 |
| Avg. Cohesion | 0.5036 | 0.5036 | 0.5036 | 0.5036 |
| Avg. Coupling | 0.0114 | 0.0114 | 0.0114 | 0.0114 |
| NMI | 1.0000 | 1.0000 | 1.0000 | 1.0000 |
| ARI | 1.0000 | 1.0000 | 1.0000 | 1.0000 |
| Runtime (s) | 0.078 | 2.847 | 0.004 | β |
Visual Comparison
π― Objectives
| # | Objective | Status |
|---|---|---|
| 1 | Formalize software systems as weighted graphs | β |
| 2 | Define quantitative metrics for cohesion & coupling | β |
| 3 | Formulate decomposition as multi-objective optimization | β |
| 4 | Implement and compare three solution strategies | β |
| 5 | Build visualization and evaluation tools | β |
ποΈ Repository Structure
project/
β
βββ README.md β You are here
βββ intro_for_new_members.pdf β Start here if you are new!
β
βββ data/
β βββ synthetic_dependency_graph.csv β Edge list (320 edges, 60 nodes)
β βββ node_clusters.csv β Ground-truth cluster assignments
β
βββ notebooks/
β βββ 01_spectral_clustering.ipynb β Solution 1: Spectral Graph Partitioning
β βββ 02_metaheuristic_ga.ipynb β Solution 2: Genetic Algorithm
β βββ 03_community_detection.ipynb β Solution 3: Louvain + Final Comparison
β
βββ reports/
βββ 01_graph_visualization.png β Graph + adjacency matrix
βββ 01_eigenvalue_spectrum.png β Eigengap analysis
βββ 01_spectral_results.png β Spectral embedding visualization
βββ 01_spectral_evaluation.png β Cohesion/coupling/confusion matrix
βββ 01_fiedler_analysis.png β Fiedler vector analysis
βββ 02_ga_convergence.png β GA fitness convergence
βββ 02_ga_results.png β GA clustering visualization
βββ 02_ga_sensitivity.png β GA hyperparameter sensitivity
βββ 02_ga_landscape.png β Fitness landscape visualization
βββ 03_louvain_results.png β Louvain community detection
βββ 03_resolution_analysis.png β Resolution parameter sweep
βββ 03_louvain_hierarchy.png β Hierarchical decomposition
βββ 03_final_comparison.png β All methods compared
βββ *.csv β Numerical results per method
π§ How to Work This Project β Step by Step
Step 0 β Read the Intro PDF First (New Members)
File:
intro_for_new_members.pdf
Covers: software architecture basics, Kubernetes & containers, coupling/cohesion problem, existing approaches, and why we need math.
Step 1 β Understand the Dataset
File:
data/synthetic_dependency_graph.csv
| Column | Description |
|---|---|
source |
Source component (e.g., auth_00, billing_03) |
target |
Target component |
weight |
Dependency strength (0.0β1.0) |
true_cluster |
Ground-truth cluster label (0β4) or "cross" for inter-cluster edges |
The graph has 60 nodes across 5 services (auth, billing, catalog, orders, notify) with 320 edges.
Step 2 β Run the Three Notebooks
π Notebook 1 β Spectral Graph Partitioning
Uses the graph Laplacian $L = D β A$ and its eigenvectors. The eigengap heuristic correctly identifies K=5 clusters.
π Notebook 2 β Genetic Algorithm
Evolutionary optimization with tournament selection, uniform crossover, and random mutation. Includes sensitivity analysis and fitness landscape visualization.
π Notebook 3 β Louvain Community Detection
Greedy modularity maximization with resolution parameter analysis. Includes the final three-method comparison.
π Mathematical Definitions
Modularity Q
Cohesion (intra-cluster density)
Coupling (inter-cluster density)
π¦ Dependencies
pip install networkx numpy scipy pandas scikit-learn matplotlib seaborn pyvis plotly python-louvain
π Deliverables
-
README.mdβ Project documentation -
intro_for_new_members.pdfβ Onboarding document (7 pages) -
data/synthetic_dependency_graph.csvβ Dataset (320 edges, 60 nodes, 5 clusters) -
data/node_clusters.csvβ Ground-truth labels -
notebooks/01_spectral_clustering.ipynbβ Spectral method (21 cells) -
notebooks/02_metaheuristic_ga.ipynbβ Genetic algorithm (23 cells) -
notebooks/03_community_detection.ipynbβ Louvain + comparison (22 cells) -
reports/*.pngβ 13 publication-quality figures -
reports/*.csvβ Numerical results for all methods
π₯ Team & Roles
| Role | Responsibility |
|---|---|
| Intern A | Graph modeling, dataset generation, math formalization |
| Intern B | Optimization implementation (notebooks 1 & 2) |
| Intern C | Evaluation, visualization, notebook 3 & report |
π¬ Contact
Supervisor: MSC β INPT, Rabat
Research Team: R2
"A good decomposition is not just clean code β it is a mathematical optimum."





