mirror of
https://github.com/andwati/predictive_analysis.git
synced 2026-10-18 08:42:52 +00:00
generated diagrams
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
"""
|
||||
System Overview Diagram
|
||||
High-level view of the entire Student Success Prediction system
|
||||
"""
|
||||
|
||||
from diagrams import Diagram, Cluster, Edge
|
||||
from diagrams.onprem.client import Users
|
||||
from diagrams.generic.storage import Storage
|
||||
from diagrams.programming.language import Python
|
||||
from diagrams.programming.framework import Django
|
||||
from diagrams.onprem.analytics import Tableau
|
||||
from diagrams.onprem.inmemory import Redis
|
||||
from diagrams.aws.ml import SagemakerModel
|
||||
from diagrams.generic.compute import Rack
|
||||
from diagrams.onprem.monitoring import Grafana
|
||||
from diagrams.generic.network import Internet
|
||||
|
||||
with Diagram("Student Success Prediction - System Overview",
|
||||
filename="diagrams/00_system_overview",
|
||||
show=False,
|
||||
direction="TB"):
|
||||
|
||||
# System Title and Context
|
||||
title = Storage("Student Success Prediction System\n• 93.84% Accuracy Random Forest Model\n• 36 Features, 3 Outcomes\n• 4,424 Student Dataset")
|
||||
|
||||
# Phase 1: Data Analysis & Model Development
|
||||
with Cluster("Phase 1: Data Analysis & Model Development"):
|
||||
raw_data = Storage("Raw Dataset\ndata.csv")
|
||||
eda_process = Tableau("Exploratory Data Analysis\n• Data quality assessment\n• Statistical analysis\n• Feature insights")
|
||||
ml_pipeline = Python("ML Pipeline\n• Feature engineering\n• Model training\n• Performance validation")
|
||||
model_artifacts = SagemakerModel("Model Artifacts\n• Random Forest (93.84%)\n• Preprocessing info\n• Feature mappings")
|
||||
|
||||
# Phase 2: Application Development
|
||||
with Cluster("Phase 2: Application Development"):
|
||||
modular_architecture = Rack("Modular Architecture\n• Component separation\n• Configuration management\n• Utility services")
|
||||
|
||||
auth_system = Redis("Authentication System\n• Role-based access\n• Session management\n• Security controls")
|
||||
|
||||
ui_components = Django("UI Components\n• Rose Pine theme\n• Interactive forms\n• Responsive design")
|
||||
|
||||
streamlit_app = Django("Streamlit Application\n• Main dashboard\n• User interface\n• API integration")
|
||||
|
||||
# Phase 3: Production Deployment
|
||||
with Cluster("Phase 3: Production Deployment"):
|
||||
deployment_options = Rack("Deployment Options\n• Streamlit Cloud\n• Docker containers\n• Traditional servers")
|
||||
|
||||
monitoring = Grafana("Monitoring & Analytics\n• Performance metrics\n• User analytics\n• System health")
|
||||
|
||||
security = Redis("Security & Compliance\n• Data protection\n• Access control\n• Audit logging")
|
||||
|
||||
# End Users and Outcomes
|
||||
with Cluster("Stakeholders & Users"):
|
||||
students = Users("Students\n• Academic planning\n• Risk assessment\n• Personal insights")
|
||||
educators = Users("Educators\n• Student analytics\n• Intervention planning\n• Performance tracking")
|
||||
administrators = Users("Administrators\n• System management\n• User oversight\n• Strategic planning")
|
||||
|
||||
# Global Internet Access
|
||||
internet = Internet("Global Access\nSecure HTTPS")
|
||||
|
||||
# System Flow
|
||||
title >> raw_data >> eda_process >> ml_pipeline >> model_artifacts
|
||||
|
||||
model_artifacts >> modular_architecture
|
||||
modular_architecture >> auth_system
|
||||
modular_architecture >> ui_components
|
||||
auth_system >> streamlit_app
|
||||
ui_components >> streamlit_app
|
||||
|
||||
streamlit_app >> deployment_options
|
||||
deployment_options >> monitoring
|
||||
deployment_options >> security
|
||||
|
||||
internet >> streamlit_app
|
||||
streamlit_app >> students
|
||||
streamlit_app >> educators
|
||||
streamlit_app >> administrators
|
||||
|
||||
# Key Metrics and Features
|
||||
with Cluster("Key System Metrics"):
|
||||
accuracy_metric = Storage("Model Performance\n• 93.84% Test Accuracy\n• Balanced class performance\n• Robust generalization")
|
||||
|
||||
feature_count = Storage("Feature Engineering\n• 36 input features\n• 105+ encoded features\n• Comprehensive preprocessing")
|
||||
|
||||
user_experience = Storage("User Experience\n• 3 user roles\n• Intuitive interface\n• Real-time predictions")
|
||||
|
||||
scalability = Storage("Scalability\n• Cloud deployment\n• Modular architecture\n• Production-ready")
|
||||
|
||||
# Connect metrics to main system
|
||||
streamlit_app >> accuracy_metric
|
||||
ml_pipeline >> feature_count
|
||||
ui_components >> user_experience
|
||||
deployment_options >> scalability
|
||||
@@ -0,0 +1,63 @@
|
||||
"""
|
||||
Data Flow Architecture Diagram
|
||||
Shows the complete data pipeline from raw data to model predictions
|
||||
"""
|
||||
|
||||
from diagrams import Diagram, Cluster, Edge
|
||||
from diagrams.onprem.database import PostgreSQL
|
||||
from diagrams.onprem.inmemory import Redis
|
||||
from diagrams.programming.language import Python
|
||||
from diagrams.onprem.analytics import Tableau
|
||||
from diagrams.onprem.client import Users
|
||||
from diagrams.onprem.workflow import Airflow
|
||||
from diagrams.generic.storage import Storage
|
||||
from diagrams.generic.compute import Rack
|
||||
from diagrams.aws.ml import SagemakerModel
|
||||
from diagrams.programming.framework import Django
|
||||
from diagrams.onprem.monitoring import Grafana
|
||||
|
||||
with Diagram("Student Success Prediction - Data Flow Architecture",
|
||||
filename="diagrams/01_data_flow_architecture",
|
||||
show=False,
|
||||
direction="TB"):
|
||||
|
||||
# Data Sources
|
||||
with Cluster("Data Sources"):
|
||||
raw_data = Storage("Raw Dataset\n(data.csv)\n4,424 students\n37 features")
|
||||
|
||||
# Data Processing Pipeline
|
||||
with Cluster("Data Processing Pipeline"):
|
||||
eda_notebook = Python("Exploratory Data Analysis\n(predictive_analysis.ipynb)")
|
||||
data_cleaning = Rack("Data Cleaning\n• Remove apostrophes\n• Fix typos\n• Handle duplicates")
|
||||
feature_eng = Rack("Feature Engineering\n• One-hot encoding\n• Label encoding\n• Scaling")
|
||||
|
||||
# Model Development
|
||||
with Cluster("Model Development"):
|
||||
model_training = Python("Model Training\n(train_and_save_model.py)")
|
||||
model_validation = Grafana("Model Validation\n• Cross-validation\n• Performance metrics")
|
||||
model_storage = Storage("Model Artifacts\n• random_forest_model.pkl\n• preprocessing_info.json")
|
||||
|
||||
# Production System
|
||||
with Cluster("Production Dashboard"):
|
||||
auth_system = Redis("Authentication\n• Session management\n• Role-based access")
|
||||
streamlit_app = Django("Streamlit App\n(app.py)")
|
||||
|
||||
with Cluster("Modular Components"):
|
||||
theme_config = Python("Theme Config\n• Rose Pine CSS\n• UI constants")
|
||||
form_components = Python("Form Components\n• Input validation\n• User interface")
|
||||
model_utils = Python("Model Utils\n• Preprocessing\n• Inference")
|
||||
|
||||
# End Users
|
||||
users = Users("End Users\n• Students\n• Educators\n• Administrators")
|
||||
|
||||
# Data Flow
|
||||
raw_data >> eda_notebook >> data_cleaning >> feature_eng
|
||||
feature_eng >> model_training >> model_validation >> model_storage
|
||||
|
||||
model_storage >> model_utils
|
||||
auth_system >> streamlit_app
|
||||
theme_config >> streamlit_app
|
||||
form_components >> streamlit_app
|
||||
model_utils >> streamlit_app
|
||||
|
||||
streamlit_app >> users
|
||||
@@ -0,0 +1,50 @@
|
||||
"""
|
||||
EDA Process Flow Diagram
|
||||
Shows the exploratory data analysis workflow and key insights
|
||||
"""
|
||||
|
||||
from diagrams import Diagram, Cluster, Edge
|
||||
from diagrams.generic.storage import Storage
|
||||
from diagrams.generic.compute import Rack
|
||||
from diagrams.programming.language import Python
|
||||
from diagrams.onprem.analytics import Tableau
|
||||
from diagrams.onprem.monitoring import Grafana
|
||||
|
||||
with Diagram("Exploratory Data Analysis Process Flow",
|
||||
filename="diagrams/02_eda_process_flow",
|
||||
show=False,
|
||||
direction="TB"):
|
||||
|
||||
# Data Input
|
||||
raw_dataset = Storage("Raw Dataset\ndata.csv\n4,424 rows × 37 columns")
|
||||
|
||||
# EDA Steps
|
||||
with Cluster("Data Quality Assessment"):
|
||||
data_info = Rack("Data Info\n• No missing values\n• No duplicates\n• Mixed data types")
|
||||
column_analysis = Rack("Column Analysis\n• 36 predictors\n• 1 target variable\n• Column name cleanup")
|
||||
|
||||
with Cluster("Statistical Analysis"):
|
||||
descriptive_stats = Grafana("Descriptive Statistics\n• Central tendencies\n• Distributions\n• Outlier detection")
|
||||
correlation_analysis = Grafana("Correlation Analysis\n• Feature relationships\n• Multicollinearity check")
|
||||
|
||||
with Cluster("Visualization & Insights"):
|
||||
target_distribution = Tableau("Target Distribution\n• Graduate: 50%\n• Dropout: 32%\n• Enrolled: 17%")
|
||||
feature_plots = Tableau("Feature Analysis\n• Histograms\n• Box plots\n• Categorical counts")
|
||||
pattern_discovery = Tableau("Pattern Discovery\n• Key predictors\n• Risk factors\n• Success indicators")
|
||||
|
||||
# Key Findings
|
||||
with Cluster("Key Findings"):
|
||||
class_imbalance = Rack("Class Imbalance\nIdentified for modeling")
|
||||
high_cardinality = Rack("High Cardinality\nCourse (51 values)\nApplication order (9 values)")
|
||||
data_quality = Rack("Data Quality\nClean dataset\nReady for modeling")
|
||||
|
||||
# Data Flow
|
||||
raw_dataset >> data_info >> descriptive_stats
|
||||
raw_dataset >> column_analysis >> correlation_analysis
|
||||
descriptive_stats >> target_distribution
|
||||
correlation_analysis >> feature_plots
|
||||
target_distribution >> pattern_discovery
|
||||
|
||||
pattern_discovery >> class_imbalance
|
||||
pattern_discovery >> high_cardinality
|
||||
pattern_discovery >> data_quality
|
||||
@@ -0,0 +1,63 @@
|
||||
"""
|
||||
Machine Learning Pipeline Architecture
|
||||
Shows the complete ML workflow from preprocessing to model deployment
|
||||
"""
|
||||
|
||||
from diagrams import Diagram, Cluster, Edge
|
||||
from diagrams.generic.storage import Storage
|
||||
from diagrams.generic.compute import Rack
|
||||
from diagrams.programming.language import Python
|
||||
from diagrams.aws.ml import SagemakerModel
|
||||
from diagrams.onprem.monitoring import Grafana
|
||||
from diagrams.generic.database import SQL
|
||||
|
||||
with Diagram("Machine Learning Pipeline Architecture",
|
||||
filename="diagrams/03_ml_pipeline_architecture",
|
||||
show=False,
|
||||
direction="TB"):
|
||||
|
||||
# Input Data
|
||||
clean_data = Storage("Cleaned Dataset\n• 4,424 samples\n• 36 features\n• 3 target classes")
|
||||
|
||||
# Preprocessing Pipeline
|
||||
with Cluster("Data Preprocessing"):
|
||||
feature_encoding = Rack("Feature Encoding\n• Label encoding (target)\n• One-hot encoding (categorical)")
|
||||
data_splitting = Rack("Data Splitting\n• Train: 75%\n• Test: 25%\n• Stratified split")
|
||||
feature_alignment = Rack("Feature Alignment\n• Consistent column order\n• Missing feature handling")
|
||||
|
||||
# Model Training
|
||||
with Cluster("Model Training & Validation"):
|
||||
model_training = Python("Random Forest Training\n• n_estimators=100\n• random_state=42")
|
||||
cross_validation = Grafana("Cross Validation\n• 5-fold CV\n• Performance metrics")
|
||||
hyperparameter_tuning = Grafana("Hyperparameter Tuning\n• Grid search\n• Best parameters")
|
||||
|
||||
# Model Evaluation
|
||||
with Cluster("Model Evaluation"):
|
||||
performance_metrics = Grafana("Performance Metrics\n• Accuracy: 93.84%\n• Precision/Recall\n• F1-Score")
|
||||
confusion_matrix = Grafana("Confusion Matrix\n• Class-wise performance\n• Error analysis")
|
||||
feature_importance = Grafana("Feature Importance\n• Top predictors\n• Impact analysis")
|
||||
|
||||
# Model Persistence
|
||||
with Cluster("Model Artifacts"):
|
||||
model_pickle = Storage("Model Pickle\nrandom_forest_model.pkl")
|
||||
preprocessing_info = SQL("Preprocessing Info\npreprocessing_info.json\n• Feature names\n• Encodings\n• Mappings")
|
||||
|
||||
# Model Validation Results
|
||||
with Cluster("Validation Results"):
|
||||
accuracy_report = Rack("Accuracy Report\n• Training: 100%\n• Testing: 93.84%\n• Generalization: Good")
|
||||
class_performance = Rack("Class Performance\n• Graduate: 95% F1\n• Dropout: 92% F1\n• Enrolled: 88% F1")
|
||||
|
||||
# Data Flow
|
||||
clean_data >> feature_encoding >> data_splitting
|
||||
data_splitting >> model_training >> cross_validation
|
||||
cross_validation >> hyperparameter_tuning >> performance_metrics
|
||||
|
||||
performance_metrics >> confusion_matrix
|
||||
performance_metrics >> feature_importance
|
||||
|
||||
model_training >> model_pickle
|
||||
feature_encoding >> preprocessing_info
|
||||
feature_alignment >> preprocessing_info
|
||||
|
||||
performance_metrics >> accuracy_report
|
||||
confusion_matrix >> class_performance
|
||||
@@ -0,0 +1,71 @@
|
||||
"""
|
||||
Application Architecture Diagram
|
||||
Shows the modular Streamlit application structure and components
|
||||
"""
|
||||
|
||||
from diagrams import Diagram, Cluster, Edge
|
||||
from diagrams.onprem.client import Users
|
||||
from diagrams.onprem.inmemory import Redis
|
||||
from diagrams.programming.framework import Django, React
|
||||
from diagrams.programming.language import Python
|
||||
from diagrams.generic.storage import Storage
|
||||
from diagrams.generic.compute import Rack
|
||||
from diagrams.onprem.network import Nginx
|
||||
|
||||
with Diagram("Streamlit Application Architecture",
|
||||
filename="diagrams/04_application_architecture",
|
||||
show=False,
|
||||
direction="TB"):
|
||||
|
||||
# Users
|
||||
users = Users("End Users\n• Students\n• Educators\n• Administrators")
|
||||
|
||||
# Web Interface
|
||||
streamlit_frontend = Django("Streamlit Frontend\n• Rose Pine Theme\n• Responsive UI\n• Interactive Forms")
|
||||
|
||||
# Authentication Layer
|
||||
with Cluster("Authentication System"):
|
||||
auth_service = Redis("Authentication Service\n• Session management\n• Role-based access\n• Security validation")
|
||||
user_roles = Rack("User Roles\n• Admin (full access)\n• Educator (analytics)\n• User (predictions)")
|
||||
|
||||
# Application Core
|
||||
with Cluster("Application Core (app.py)"):
|
||||
main_app = Python("Main Application\n• Request routing\n• Session handling\n• Error management")
|
||||
auth_decorator = Python("Auth Decorator\n• @require_auth\n• Permission checks\n• Session validation")
|
||||
|
||||
# Configuration Layer
|
||||
with Cluster("Configuration (src/config/)"):
|
||||
theme_config = React("Theme Configuration\n• Rose Pine CSS\n• Color constants\n• UI styling")
|
||||
mappings_config = Storage("Feature Mappings\n• Human-readable labels\n• Preset templates\n• Validation rules")
|
||||
|
||||
# Utility Services
|
||||
with Cluster("Utility Services (src/utils/)"):
|
||||
model_utils = Python("Model Utilities\n• Model loading\n• Preprocessing\n• Prediction logic")
|
||||
auth_utils = Python("Auth Utilities\n• User validation\n• Session management\n• Password hashing")
|
||||
|
||||
# UI Components
|
||||
with Cluster("UI Components (src/components/)"):
|
||||
form_components = React("Form Components\n• Input sections\n• Validation feedback\n• Preset selection")
|
||||
prediction_display = React("Prediction Display\n• Results visualization\n• Confidence scores\n• Recommendations")
|
||||
|
||||
# Model Layer
|
||||
with Cluster("Model Layer"):
|
||||
trained_model = Storage("Trained Model\nrandom_forest_model.pkl\n93.84% accuracy")
|
||||
preprocessing_pipeline = Storage("Preprocessing Pipeline\npreprocessing_info.json\nFeature transformations")
|
||||
|
||||
# Data Flow
|
||||
users >> streamlit_frontend
|
||||
streamlit_frontend >> auth_service >> user_roles
|
||||
auth_service >> main_app >> auth_decorator
|
||||
|
||||
main_app >> theme_config
|
||||
main_app >> mappings_config
|
||||
main_app >> form_components
|
||||
main_app >> prediction_display
|
||||
|
||||
form_components >> model_utils
|
||||
model_utils >> trained_model
|
||||
model_utils >> preprocessing_pipeline
|
||||
model_utils >> prediction_display
|
||||
|
||||
auth_decorator >> auth_utils
|
||||
@@ -0,0 +1,87 @@
|
||||
"""
|
||||
Deployment Architecture Diagram
|
||||
Shows the deployment options and infrastructure for the application
|
||||
"""
|
||||
|
||||
from diagrams import Diagram, Cluster, Edge
|
||||
from diagrams.onprem.client import Users
|
||||
from diagrams.saas.cdn import Cloudflare
|
||||
from diagrams.programming.framework import Django
|
||||
from diagrams.onprem.container import Docker
|
||||
from diagrams.k8s.compute import Pod
|
||||
from diagrams.generic.storage import Storage
|
||||
from diagrams.generic.network import Internet
|
||||
from diagrams.aws.compute import EC2
|
||||
from diagrams.gcp.compute import GKE
|
||||
|
||||
with Diagram("Deployment Architecture Options",
|
||||
filename="diagrams/05_deployment_architecture",
|
||||
show=False,
|
||||
direction="TB"):
|
||||
|
||||
# Users
|
||||
users = Users("Global Users")
|
||||
internet = Internet("Internet")
|
||||
|
||||
# Deployment Option 1: Streamlit Cloud
|
||||
with Cluster("Option 1: Streamlit Cloud (Recommended)"):
|
||||
streamlit_cloud = Django("Streamlit Cloud\n• Automatic deployment\n• GitHub integration\n• SSL/HTTPS\n• Global CDN")
|
||||
github_repo = Storage("GitHub Repository\n• Source code\n• Model artifacts\n• Configuration")
|
||||
|
||||
# Cloud features
|
||||
cloud_features = [
|
||||
Storage("Automatic Scaling"),
|
||||
Storage("Monitoring & Logs"),
|
||||
Storage("Custom Domain Support")
|
||||
]
|
||||
|
||||
# Deployment Option 2: Docker Container
|
||||
with Cluster("Option 2: Docker Deployment"):
|
||||
docker_container = Docker("Docker Container\n• Streamlit app\n• Python runtime\n• Dependencies")
|
||||
container_registry = Storage("Container Registry\n• Docker Hub\n• AWS ECR\n• GCR")
|
||||
|
||||
# Container orchestration options
|
||||
with Cluster("Orchestration Options"):
|
||||
kubernetes = Pod("Kubernetes\n• Pod management\n• Auto-scaling\n• Load balancing")
|
||||
cloud_run = GKE("Cloud Run/Fargate\n• Serverless containers\n• Pay-per-use\n• Auto-scaling")
|
||||
|
||||
# Deployment Option 3: Traditional Server
|
||||
with Cluster("Option 3: Traditional Server"):
|
||||
web_server = EC2("Web Server\n• EC2/Compute Engine\n• Nginx reverse proxy\n• SSL certificate")
|
||||
app_server = Django("Application Server\n• Streamlit process\n• PM2/Supervisor\n• Process management")
|
||||
|
||||
# Shared Resources
|
||||
with Cluster("Shared Resources"):
|
||||
model_storage = Storage("Model Storage\n• Trained models\n• Preprocessing info\n• Version control")
|
||||
monitoring = Storage("Monitoring\n• Application logs\n• Performance metrics\n• Error tracking")
|
||||
backup = Storage("Backup & Recovery\n• Model versioning\n• Configuration backup\n• Disaster recovery")
|
||||
|
||||
# Data Flow
|
||||
users >> internet
|
||||
|
||||
# Streamlit Cloud flow
|
||||
internet >> streamlit_cloud
|
||||
github_repo >> streamlit_cloud
|
||||
streamlit_cloud >> cloud_features[0]
|
||||
streamlit_cloud >> cloud_features[1]
|
||||
streamlit_cloud >> cloud_features[2]
|
||||
|
||||
# Docker flow
|
||||
internet >> docker_container
|
||||
container_registry >> docker_container
|
||||
docker_container >> kubernetes
|
||||
docker_container >> cloud_run
|
||||
|
||||
# Traditional server flow
|
||||
internet >> web_server >> app_server
|
||||
|
||||
# Shared resources connections
|
||||
streamlit_cloud >> model_storage
|
||||
docker_container >> model_storage
|
||||
app_server >> model_storage
|
||||
|
||||
streamlit_cloud >> monitoring
|
||||
kubernetes >> monitoring
|
||||
app_server >> monitoring
|
||||
|
||||
model_storage >> backup
|
||||
@@ -0,0 +1,70 @@
|
||||
"""
|
||||
Feature Engineering Pipeline Diagram
|
||||
Shows the detailed feature transformation and encoding process
|
||||
"""
|
||||
|
||||
from diagrams import Diagram, Cluster, Edge
|
||||
from diagrams.generic.storage import Storage
|
||||
from diagrams.generic.compute import Rack
|
||||
from diagrams.programming.language import Python
|
||||
from diagrams.onprem.analytics import Tableau
|
||||
from diagrams.generic.database import SQL
|
||||
|
||||
with Diagram("Feature Engineering Pipeline",
|
||||
filename="diagrams/06_feature_engineering_pipeline",
|
||||
show=False,
|
||||
direction="TB"):
|
||||
|
||||
# Raw Features Input
|
||||
raw_features = Storage("Raw Features (37)\n• 36 predictors\n• 1 target variable\n• Mixed data types")
|
||||
|
||||
# Categorical Features Processing
|
||||
with Cluster("Categorical Feature Processing"):
|
||||
categorical_features = Rack("Categorical Features\n• Marital status\n• Application mode\n• Course\n• Nationality\n• Mother's/Father's qualification\n• Mother's/Father's occupation\n• Displaced\n• Educational special needs\n• Debtor\n• Tuition fees up to date\n• Gender\n• Scholarship holder\n• International")
|
||||
|
||||
label_encoding = Python("Label Encoding\n• Target variable\n• Dropout = 0\n• Enrolled = 1\n• Graduate = 2")
|
||||
|
||||
one_hot_encoding = Python("One-Hot Encoding\n• Categorical predictors\n• Binary columns creation\n• Feature expansion")
|
||||
|
||||
# Numerical Features Processing
|
||||
with Cluster("Numerical Feature Processing"):
|
||||
numerical_features = Rack("Numerical Features\n• Application order\n• Previous qualification grade\n• Admission grade\n• Age at enrollment\n• Curricular units (1st & 2nd sem)\n• Unemployment rate\n• Inflation rate\n• GDP")
|
||||
|
||||
feature_validation = Python("Feature Validation\n• Range checks\n• Outlier detection\n• Data type validation")
|
||||
|
||||
feature_scaling = Python("Feature Scaling\n• Optional for tree models\n• Standardization available\n• Normalization available")
|
||||
|
||||
# Feature Engineering Output
|
||||
with Cluster("Engineered Features"):
|
||||
encoded_features = Storage("Encoded Features (~105)\n• Original numerical (14)\n• One-hot encoded categorical (90+)\n• Label encoded target (1)")
|
||||
|
||||
feature_mapping = SQL("Feature Mapping\n• Original → Encoded names\n• Category mappings\n• Reverse mappings")
|
||||
|
||||
preprocessing_metadata = SQL("Preprocessing Metadata\n• Encoding schemes\n• Feature names\n• Transformation info")
|
||||
|
||||
# Quality Assurance
|
||||
with Cluster("Quality Assurance"):
|
||||
feature_consistency = Rack("Feature Consistency\n• Column order preservation\n• Missing feature handling\n• Shape validation")
|
||||
|
||||
data_validation = Rack("Data Validation\n• No missing values\n• Consistent data types\n• Feature alignment")
|
||||
|
||||
pipeline_testing = Tableau("Pipeline Testing\n• Train/test consistency\n• Transformation verification\n• Edge case handling")
|
||||
|
||||
# Data Flow
|
||||
raw_features >> categorical_features >> one_hot_encoding
|
||||
raw_features >> numerical_features >> feature_validation
|
||||
|
||||
categorical_features >> label_encoding
|
||||
numerical_features >> feature_scaling
|
||||
|
||||
one_hot_encoding >> encoded_features
|
||||
label_encoding >> encoded_features
|
||||
feature_validation >> encoded_features
|
||||
feature_scaling >> encoded_features
|
||||
|
||||
encoded_features >> feature_mapping
|
||||
encoded_features >> preprocessing_metadata
|
||||
|
||||
encoded_features >> feature_consistency
|
||||
feature_consistency >> data_validation
|
||||
data_validation >> pipeline_testing
|
||||
@@ -0,0 +1,79 @@
|
||||
"""
|
||||
User Journey and Interaction Flow Diagram
|
||||
Shows how different user types interact with the application
|
||||
"""
|
||||
|
||||
from diagrams import Diagram, Cluster, Edge
|
||||
from diagrams.onprem.client import Users, User
|
||||
from diagrams.programming.framework import Django
|
||||
from diagrams.onprem.inmemory import Redis
|
||||
from diagrams.generic.compute import Rack
|
||||
from diagrams.onprem.analytics import Tableau
|
||||
from diagrams.generic.storage import Storage
|
||||
|
||||
with Diagram("User Journey and Interaction Flow",
|
||||
filename="diagrams/07_user_journey_flow",
|
||||
show=False,
|
||||
direction="TB"):
|
||||
|
||||
# User Types
|
||||
with Cluster("User Types"):
|
||||
student_user = User("Student\n• Personal predictions\n• Academic planning\n• Risk assessment")
|
||||
educator_user = User("Educator\n• Student analytics\n• Intervention planning\n• Batch predictions")
|
||||
admin_user = User("Administrator\n• System management\n• User oversight\n• Full access")
|
||||
|
||||
# Authentication Flow
|
||||
with Cluster("Authentication Flow"):
|
||||
login_page = Django("Login Page\n• Credential input\n• Role selection\n• Security validation")
|
||||
auth_service = Redis("Authentication Service\n• Session creation\n• Role assignment\n• Access control")
|
||||
session_management = Redis("Session Management\n• Timeout handling\n• Security checks\n• State persistence")
|
||||
|
||||
# Application Interface
|
||||
with Cluster("Application Interface"):
|
||||
main_dashboard = Django("Main Dashboard\n• Role-based UI\n• Feature access\n• Navigation menu")
|
||||
|
||||
# Student workflow
|
||||
with Cluster("Student Workflow"):
|
||||
personal_form = Rack("Personal Information Form\n• Basic demographics\n• Academic history\n• Family background")
|
||||
academic_form = Rack("Academic Performance Form\n• Current grades\n• Curricular units\n• Progress tracking")
|
||||
prediction_results = Tableau("Prediction Results\n• Outcome probability\n• Confidence scores\n• Recommendations")
|
||||
|
||||
# Educator workflow
|
||||
with Cluster("Educator Workflow"):
|
||||
student_management = Rack("Student Management\n• Batch input\n• Template selection\n• Data validation")
|
||||
analytics_dashboard = Tableau("Analytics Dashboard\n• Class performance\n• Risk indicators\n• Intervention alerts")
|
||||
reporting_tools = Tableau("Reporting Tools\n• Performance reports\n• Trend analysis\n• Export capabilities")
|
||||
|
||||
# Admin workflow
|
||||
with Cluster("Admin Workflow"):
|
||||
user_management = Rack("User Management\n• Account creation\n• Role assignment\n• Access control")
|
||||
system_monitoring = Tableau("System Monitoring\n• Usage statistics\n• Performance metrics\n• Error logs")
|
||||
model_management = Storage("Model Management\n• Version control\n• Performance tracking\n• Updates")
|
||||
|
||||
# Prediction Engine
|
||||
with Cluster("Prediction Engine"):
|
||||
input_validation = Rack("Input Validation\n• Data quality checks\n• Range validation\n• Required fields")
|
||||
feature_processing = Rack("Feature Processing\n• Encoding\n• Transformation\n• Alignment")
|
||||
model_inference = Storage("Model Inference\n• Random Forest prediction\n• Confidence calculation\n• Result formatting")
|
||||
|
||||
# User Journey Flows
|
||||
|
||||
# Student journey
|
||||
student_user >> login_page >> auth_service >> main_dashboard
|
||||
main_dashboard >> personal_form >> academic_form
|
||||
academic_form >> input_validation >> feature_processing >> model_inference
|
||||
model_inference >> prediction_results
|
||||
|
||||
# Educator journey
|
||||
educator_user >> login_page >> auth_service >> main_dashboard
|
||||
main_dashboard >> student_management >> analytics_dashboard
|
||||
student_management >> input_validation >> feature_processing >> model_inference
|
||||
model_inference >> reporting_tools
|
||||
|
||||
# Admin journey
|
||||
admin_user >> login_page >> auth_service >> main_dashboard
|
||||
main_dashboard >> user_management >> system_monitoring >> model_management
|
||||
|
||||
# Session management connections
|
||||
auth_service >> session_management
|
||||
session_management >> main_dashboard
|
||||
@@ -0,0 +1,93 @@
|
||||
"""
|
||||
Security and Authentication Architecture Diagram
|
||||
Shows the comprehensive security model and authentication flow
|
||||
"""
|
||||
|
||||
from diagrams import Diagram, Cluster, Edge
|
||||
from diagrams.onprem.client import Users
|
||||
from diagrams.onprem.security import Oauth
|
||||
from diagrams.onprem.inmemory import Redis
|
||||
from diagrams.programming.language import Python
|
||||
from diagrams.generic.compute import Rack
|
||||
from diagrams.generic.storage import Storage
|
||||
from diagrams.onprem.network import Nginx
|
||||
from diagrams.generic.database import SQL
|
||||
|
||||
with Diagram("Security and Authentication Architecture",
|
||||
filename="diagrams/08_security_architecture",
|
||||
show=False,
|
||||
direction="TB"):
|
||||
|
||||
# External Users
|
||||
users = Users("External Users\n• Students\n• Educators\n• Administrators")
|
||||
|
||||
# Security Perimeter
|
||||
with Cluster("Security Perimeter"):
|
||||
https_gateway = Nginx("HTTPS Gateway\n• SSL/TLS encryption\n• Certificate management\n• Secure headers")
|
||||
rate_limiting = Rack("Rate Limiting\n• Request throttling\n• DDoS protection\n• Abuse prevention")
|
||||
|
||||
# Authentication Layer
|
||||
with Cluster("Authentication System"):
|
||||
login_handler = Oauth("Login Handler\n• Credential validation\n• Multi-factor support\n• Brute force protection")
|
||||
|
||||
password_security = Python("Password Security\n• Hashing (bcrypt/scrypt)\n• Salt generation\n• Strength validation")
|
||||
|
||||
session_store = Redis("Session Store\n• Secure session tokens\n• Expiration management\n• Cross-site protection")
|
||||
|
||||
# Authorization Layer
|
||||
with Cluster("Authorization System"):
|
||||
role_manager = Python("Role Manager\n• Role definitions\n• Permission mapping\n• Access control")
|
||||
|
||||
permission_engine = Rack("Permission Engine\n• Route protection\n• Resource access\n• Action authorization")
|
||||
|
||||
with Cluster("User Roles & Permissions"):
|
||||
admin_permissions = Storage("Admin Permissions\n• Full system access\n• User management\n• Model updates\n• System configuration")
|
||||
|
||||
educator_permissions = Storage("Educator Permissions\n• Student analytics\n• Batch predictions\n• Reporting tools\n• Limited admin")
|
||||
|
||||
user_permissions = Storage("User Permissions\n• Personal predictions\n• Profile management\n• Basic analytics\n• Read-only access")
|
||||
|
||||
# Security Middleware
|
||||
with Cluster("Security Middleware"):
|
||||
auth_decorator = Python("Auth Decorator\n• @require_auth\n• Route protection\n• Session validation")
|
||||
|
||||
input_sanitization = Rack("Input Sanitization\n• XSS prevention\n• SQL injection protection\n• Data validation")
|
||||
|
||||
csrf_protection = Rack("CSRF Protection\n• Token validation\n• State verification\n• Request authentication")
|
||||
|
||||
# Application Security
|
||||
with Cluster("Application Security"):
|
||||
secure_storage = Storage("Secure Storage\n• Encrypted data\n• Access logs\n• Audit trails")
|
||||
|
||||
error_handling = Rack("Error Handling\n• Secure error messages\n• Log sanitization\n• Information disclosure prevention")
|
||||
|
||||
monitoring = SQL("Security Monitoring\n• Failed login attempts\n• Suspicious activity\n• Access pattern analysis")
|
||||
|
||||
# Data Protection
|
||||
with Cluster("Data Protection"):
|
||||
data_encryption = Storage("Data Encryption\n• At-rest encryption\n• In-transit encryption\n• Key management")
|
||||
|
||||
privacy_controls = Rack("Privacy Controls\n• Data anonymization\n• PII protection\n• Consent management")
|
||||
|
||||
backup_security = Storage("Backup Security\n• Encrypted backups\n• Access controls\n• Recovery procedures")
|
||||
|
||||
# Security Flow
|
||||
users >> https_gateway >> rate_limiting >> login_handler
|
||||
login_handler >> password_security >> session_store
|
||||
|
||||
session_store >> role_manager >> permission_engine
|
||||
|
||||
role_manager >> admin_permissions
|
||||
role_manager >> educator_permissions
|
||||
role_manager >> user_permissions
|
||||
|
||||
permission_engine >> auth_decorator >> input_sanitization
|
||||
input_sanitization >> csrf_protection
|
||||
|
||||
auth_decorator >> secure_storage
|
||||
csrf_protection >> error_handling
|
||||
error_handling >> monitoring
|
||||
|
||||
secure_storage >> data_encryption
|
||||
data_encryption >> privacy_controls
|
||||
privacy_controls >> backup_security
|
||||
@@ -0,0 +1,200 @@
|
||||
# Architecture Diagrams
|
||||
|
||||
This directory contains comprehensive architectural diagrams for the Student Success Prediction project, created using the Python `diagrams` library.
|
||||
|
||||
## 📋 Overview
|
||||
|
||||
The diagrams visualize the complete system architecture from data analysis through production deployment, providing clear documentation for developers, stakeholders, and system administrators.
|
||||
|
||||
## 🎯 Diagram Categories
|
||||
|
||||
### 1. Data Flow Architecture (`01_data_flow_architecture.py`)
|
||||
- **Purpose**: Shows the complete data pipeline from raw data to model predictions
|
||||
- **Key Components**: Data sources, processing pipeline, model development, production system
|
||||
- **Audience**: Data scientists, developers, project managers
|
||||
|
||||
### 2. EDA Process Flow (`02_eda_process_flow.py`)
|
||||
- **Purpose**: Visualizes the exploratory data analysis workflow and key insights
|
||||
- **Key Components**: Data quality assessment, statistical analysis, visualization insights
|
||||
- **Audience**: Data analysts, researchers, stakeholders
|
||||
|
||||
### 3. ML Pipeline Architecture (`03_ml_pipeline_architecture.py`)
|
||||
- **Purpose**: Details the machine learning workflow from preprocessing to model deployment
|
||||
- **Key Components**: Preprocessing, training, validation, model persistence
|
||||
- **Audience**: ML engineers, data scientists, technical leads
|
||||
|
||||
### 4. Application Architecture (`04_application_architecture.py`)
|
||||
- **Purpose**: Shows the modular Streamlit application structure and components
|
||||
- **Key Components**: Authentication, UI components, configuration, utilities
|
||||
- **Audience**: Frontend developers, full-stack developers, architects
|
||||
|
||||
### 5. Deployment Architecture (`05_deployment_architecture.py`)
|
||||
- **Purpose**: Illustrates deployment options and infrastructure choices
|
||||
- **Key Components**: Streamlit Cloud, Docker containers, traditional servers
|
||||
- **Audience**: DevOps engineers, system administrators, deployment teams
|
||||
|
||||
### 6. Feature Engineering Pipeline (`06_feature_engineering_pipeline.py`)
|
||||
- **Purpose**: Details the feature transformation and encoding processes
|
||||
- **Key Components**: Categorical/numerical processing, encoding schemes, validation
|
||||
- **Audience**: Data engineers, ML engineers, data scientists
|
||||
|
||||
### 7. User Journey Flow (`07_user_journey_flow.py`)
|
||||
- **Purpose**: Maps how different user types interact with the application
|
||||
- **Key Components**: User roles, workflows, interface interactions
|
||||
- **Audience**: UX designers, product managers, business analysts
|
||||
|
||||
### 8. Security Architecture (`08_security_architecture.py`)
|
||||
- **Purpose**: Comprehensive security model and authentication flows
|
||||
- **Key Components**: Authentication, authorization, data protection, monitoring
|
||||
- **Audience**: Security engineers, compliance officers, architects
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
### Install Dependencies
|
||||
|
||||
```bash
|
||||
# Install diagrams library and dependencies
|
||||
pip install -r diagrams/requirements.txt
|
||||
```
|
||||
|
||||
**Note**: You'll also need Graphviz installed on your system:
|
||||
- **Windows**: Download from https://graphviz.org/download/ or use `choco install graphviz`
|
||||
- **macOS**: `brew install graphviz`
|
||||
- **Linux**: `sudo apt-get install graphviz` (Ubuntu/Debian) or `sudo yum install graphviz` (RHEL/CentOS)
|
||||
|
||||
### Generate All Diagrams
|
||||
|
||||
```bash
|
||||
# Generate all diagrams at once
|
||||
python diagrams/generate_all_diagrams.py
|
||||
```
|
||||
|
||||
### Generate Individual Diagrams
|
||||
|
||||
```bash
|
||||
# Generate specific diagram
|
||||
cd diagrams
|
||||
python 01_data_flow_architecture.py
|
||||
```
|
||||
|
||||
## 📁 Output Files
|
||||
|
||||
After generation, you'll find PNG image files in the `diagrams/` directory:
|
||||
|
||||
```
|
||||
diagrams/
|
||||
├── 01_data_flow_architecture.png
|
||||
├── 02_eda_process_flow.png
|
||||
├── 03_ml_pipeline_architecture.png
|
||||
├── 04_application_architecture.png
|
||||
├── 05_deployment_architecture.png
|
||||
├── 06_feature_engineering_pipeline.png
|
||||
├── 07_user_journey_flow.png
|
||||
├── 08_security_architecture.png
|
||||
└── ... (source .py files)
|
||||
```
|
||||
|
||||
## 🎨 Customization
|
||||
|
||||
### Modifying Diagrams
|
||||
|
||||
1. **Edit Source Files**: Modify the `.py` files to change diagram content
|
||||
2. **Update Styling**: Adjust colors, layouts, and visual elements
|
||||
3. **Add Components**: Include new services or modify existing ones
|
||||
4. **Change Layout**: Modify `direction` parameter ("TB", "LR", "BT", "RL")
|
||||
|
||||
### Example Customization
|
||||
|
||||
```python
|
||||
# Change diagram direction from top-bottom to left-right
|
||||
with Diagram("My Custom Diagram",
|
||||
filename="diagrams/custom_diagram",
|
||||
show=False,
|
||||
direction="LR"): # Changed from "TB"
|
||||
# ... diagram components
|
||||
```
|
||||
|
||||
### Adding New Diagrams
|
||||
|
||||
1. Create a new `.py` file in the `diagrams/` directory
|
||||
2. Follow the existing naming convention: `09_my_new_diagram.py`
|
||||
3. Add the new script to `generate_all_diagrams.py`
|
||||
4. Use consistent styling and component types
|
||||
|
||||
## 🔧 Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
**Graphviz not found error**:
|
||||
```bash
|
||||
# Ensure Graphviz is installed and in PATH
|
||||
dot -V # Should show version info
|
||||
```
|
||||
|
||||
**Import errors**:
|
||||
```bash
|
||||
# Reinstall diagrams library
|
||||
pip uninstall diagrams
|
||||
pip install diagrams==0.23.4
|
||||
```
|
||||
|
||||
**Permission errors**:
|
||||
```bash
|
||||
# Ensure write permissions in diagrams directory
|
||||
chmod 755 diagrams/
|
||||
```
|
||||
|
||||
**Large diagram files**:
|
||||
- Reduce number of components
|
||||
- Simplify cluster structures
|
||||
- Use abbreviated labels
|
||||
|
||||
### Performance Tips
|
||||
|
||||
1. **Batch Generation**: Use `generate_all_diagrams.py` for efficiency
|
||||
2. **Selective Updates**: Only regenerate changed diagrams during development
|
||||
3. **Output Format**: PNG is default; SVG available for scalability
|
||||
4. **Caching**: Generated images are cached until source files change
|
||||
|
||||
## 📊 Integration
|
||||
|
||||
### Documentation Integration
|
||||
|
||||
Include diagrams in documentation:
|
||||
|
||||
```markdown
|
||||

|
||||
```
|
||||
|
||||
### Presentation Use
|
||||
|
||||
- High-resolution PNG files suitable for presentations
|
||||
- SVG format available for scalable graphics
|
||||
- Consistent styling across all diagrams
|
||||
|
||||
### Version Control
|
||||
|
||||
- Include source `.py` files in version control
|
||||
- Consider excluding generated `.png` files (large binary files)
|
||||
- Use CI/CD to regenerate diagrams automatically
|
||||
|
||||
## 🤝 Contributing
|
||||
|
||||
When adding new diagrams:
|
||||
|
||||
1. **Follow Naming Convention**: `##_descriptive_name.py`
|
||||
2. **Add Documentation**: Update this README with diagram description
|
||||
3. **Consistent Styling**: Use similar component types and colors
|
||||
4. **Test Generation**: Verify diagram generates without errors
|
||||
5. **Update Master Script**: Add new diagram to `generate_all_diagrams.py`
|
||||
|
||||
## 📚 Resources
|
||||
|
||||
- **Diagrams Library**: https://diagrams.mingrammer.com/
|
||||
- **Graphviz Documentation**: https://graphviz.org/documentation/
|
||||
- **Icon Reference**: https://diagrams.mingrammer.com/docs/nodes/overview
|
||||
- **Styling Guide**: https://diagrams.mingrammer.com/docs/guides/diagram
|
||||
|
||||
## 📄 License
|
||||
|
||||
These diagrams are part of the Student Success Prediction project and follow the same license terms.
|
||||
@@ -0,0 +1,82 @@
|
||||
"""
|
||||
Master Script to Generate All Architecture Diagrams
|
||||
Run this script to generate all diagram images at once
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
def generate_diagram(script_name):
|
||||
"""Generate a single diagram by running its Python script"""
|
||||
try:
|
||||
print(f"Generating {script_name}...")
|
||||
result = subprocess.run([sys.executable, script_name],
|
||||
capture_output=True, text=True, cwd="diagrams")
|
||||
|
||||
if result.returncode == 0:
|
||||
print(f"✅ Successfully generated {script_name}")
|
||||
else:
|
||||
print(f"❌ Error generating {script_name}:")
|
||||
print(result.stderr)
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Exception while generating {script_name}: {e}")
|
||||
|
||||
def main():
|
||||
"""Generate all architecture diagrams"""
|
||||
|
||||
# Check if diagrams library is installed
|
||||
try:
|
||||
import diagrams
|
||||
print("✅ Diagrams library found")
|
||||
except ImportError:
|
||||
print("❌ Diagrams library not found. Installing...")
|
||||
subprocess.run([sys.executable, "-m", "pip", "install", "-r", "diagrams/requirements.txt"])
|
||||
print("✅ Diagrams library installed")
|
||||
|
||||
# List of diagram scripts to generate
|
||||
diagram_scripts = [
|
||||
"00_system_overview.py",
|
||||
"01_data_flow_architecture.py",
|
||||
"02_eda_process_flow.py",
|
||||
"03_ml_pipeline_architecture.py",
|
||||
"04_application_architecture.py",
|
||||
"05_deployment_architecture.py",
|
||||
"06_feature_engineering_pipeline.py",
|
||||
"07_user_journey_flow.py",
|
||||
"08_security_architecture.py"
|
||||
]
|
||||
|
||||
print("🚀 Starting diagram generation...")
|
||||
print("=" * 50)
|
||||
|
||||
# Create diagrams directory if it doesn't exist
|
||||
Path("diagrams").mkdir(exist_ok=True)
|
||||
|
||||
# Generate each diagram
|
||||
for script in diagram_scripts:
|
||||
if os.path.exists(f"diagrams/{script}"):
|
||||
generate_diagram(script)
|
||||
else:
|
||||
print(f"⚠️ Script not found: {script}")
|
||||
|
||||
print("=" * 50)
|
||||
print("🎉 Diagram generation complete!")
|
||||
print("\nGenerated diagrams:")
|
||||
|
||||
# List generated PNG files
|
||||
diagrams_dir = Path("diagrams")
|
||||
png_files = list(diagrams_dir.glob("*.png"))
|
||||
|
||||
if png_files:
|
||||
for png_file in sorted(png_files):
|
||||
print(f" 📊 {png_file.name}")
|
||||
else:
|
||||
print(" ⚠️ No PNG files found. Check for errors above.")
|
||||
|
||||
print(f"\nTotal diagrams generated: {len(png_files)}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,144 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Quick Start Guide for Architecture Diagrams
|
||||
Demonstrates the complete workflow from setup to diagram generation
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
def print_header(title):
|
||||
"""Print a formatted header"""
|
||||
print("\n" + "=" * 60)
|
||||
print(f"🎯 {title}")
|
||||
print("=" * 60)
|
||||
|
||||
def print_step(step_num, description):
|
||||
"""Print a formatted step"""
|
||||
print(f"\n📋 Step {step_num}: {description}")
|
||||
print("-" * 40)
|
||||
|
||||
def run_with_confirmation(command, description):
|
||||
"""Run a command with user confirmation"""
|
||||
print(f"\n🔄 Ready to: {description}")
|
||||
print(f"Command: {command}")
|
||||
|
||||
response = input("Proceed? (y/N): ").lower().strip()
|
||||
if response in ['y', 'yes']:
|
||||
try:
|
||||
result = subprocess.run(command, shell=True, cwd=".")
|
||||
if result.returncode == 0:
|
||||
print("✅ Success!")
|
||||
return True
|
||||
else:
|
||||
print("❌ Command failed")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"❌ Error: {e}")
|
||||
return False
|
||||
else:
|
||||
print("⏭️ Skipped")
|
||||
return False
|
||||
|
||||
def main():
|
||||
"""Main demonstration function"""
|
||||
|
||||
print_header("Student Success Prediction - Architecture Diagrams")
|
||||
print("This guide will walk you through setting up and generating")
|
||||
print("comprehensive architecture diagrams for the entire system.")
|
||||
|
||||
# Step 1: Environment Check
|
||||
print_step(1, "Environment Check")
|
||||
print(f"Python Version: {sys.version}")
|
||||
print(f"Current Directory: {os.getcwd()}")
|
||||
print(f"Diagrams Directory Exists: {Path('diagrams').exists()}")
|
||||
|
||||
# Step 2: Setup Dependencies
|
||||
print_step(2, "Setup Dependencies")
|
||||
print("This will install the required Python packages and check Graphviz.")
|
||||
|
||||
if run_with_confirmation("python diagrams/setup.py", "Run setup script"):
|
||||
print("✅ Dependencies are ready!")
|
||||
else:
|
||||
print("⚠️ You may need to install dependencies manually:")
|
||||
print(" pip install diagrams>=0.23.4 graphviz>=0.20.1")
|
||||
|
||||
# Step 3: Generate Overview
|
||||
print_step(3, "Generate System Overview")
|
||||
print("Create a high-level overview of the entire system.")
|
||||
|
||||
if run_with_confirmation("cd diagrams && python 00_system_overview.py",
|
||||
"Generate system overview diagram"):
|
||||
if Path("diagrams/00_system_overview.png").exists():
|
||||
print("🖼️ System overview generated successfully!")
|
||||
print(" File: diagrams/00_system_overview.png")
|
||||
|
||||
# Step 4: Generate All Diagrams
|
||||
print_step(4, "Generate All Architecture Diagrams")
|
||||
print("This will create all 9 comprehensive architecture diagrams.")
|
||||
|
||||
if run_with_confirmation("python diagrams/generate_all_diagrams.py",
|
||||
"Generate all diagrams"):
|
||||
|
||||
# List generated files
|
||||
diagrams_dir = Path("diagrams")
|
||||
png_files = list(diagrams_dir.glob("*.png"))
|
||||
|
||||
if png_files:
|
||||
print(f"\n🎉 Successfully generated {len(png_files)} diagrams:")
|
||||
for png_file in sorted(png_files):
|
||||
print(f" 📊 {png_file.name}")
|
||||
else:
|
||||
print("⚠️ No diagram files found. Check for errors above.")
|
||||
|
||||
# Step 5: Integration Guide
|
||||
print_step(5, "Integration and Usage")
|
||||
print("\n📚 How to use these diagrams:")
|
||||
print(" • Documentation: Include in README.md, wikis, or docs")
|
||||
print(" • Presentations: High-resolution PNG files for slides")
|
||||
print(" • Code Reviews: Reference architecture during reviews")
|
||||
print(" • Onboarding: Help new team members understand the system")
|
||||
print(" • Planning: Use for system evolution and scaling decisions")
|
||||
|
||||
print("\n🔧 Customization:")
|
||||
print(" • Edit .py files in diagrams/ directory to modify diagrams")
|
||||
print(" • Change colors, layouts, and components as needed")
|
||||
print(" • Add new diagrams following the existing patterns")
|
||||
|
||||
print("\n📁 File Structure:")
|
||||
print(" diagrams/")
|
||||
print(" ├── 00_system_overview.png # High-level system view")
|
||||
print(" ├── 01_data_flow_architecture.png # Complete data pipeline")
|
||||
print(" ├── 02_eda_process_flow.png # EDA workflow")
|
||||
print(" ├── 03_ml_pipeline_architecture.png # ML development process")
|
||||
print(" ├── 04_application_architecture.png # Streamlit app structure")
|
||||
print(" ├── 05_deployment_architecture.png # Deployment options")
|
||||
print(" ├── 06_feature_engineering_pipeline.png # Feature processing")
|
||||
print(" ├── 07_user_journey_flow.png # User interaction flows")
|
||||
print(" └── 08_security_architecture.png # Security and auth")
|
||||
|
||||
# Final Summary
|
||||
print_header("Summary and Next Steps")
|
||||
print("✅ Architecture diagrams provide comprehensive system documentation")
|
||||
print("✅ Visual representation helps with understanding and communication")
|
||||
print("✅ Easy to maintain and update as the system evolves")
|
||||
|
||||
print("\n🚀 Recommended Next Steps:")
|
||||
print("1. Review generated diagrams and verify accuracy")
|
||||
print("2. Include key diagrams in project documentation")
|
||||
print("3. Share with team members and stakeholders")
|
||||
print("4. Update diagrams when making system changes")
|
||||
print("5. Use diagrams for technical discussions and planning")
|
||||
|
||||
print("\n📖 For detailed information, see:")
|
||||
print(" • diagrams/README.md - Complete usage guide")
|
||||
print(" • Individual .py files - Diagram source code")
|
||||
print(" • Generated .png files - Final diagram images")
|
||||
|
||||
print("\n🎯 The architecture diagrams are now ready to support your")
|
||||
print(" project documentation, presentations, and team collaboration!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,3 @@
|
||||
# Requirements for generating architectural diagrams
|
||||
diagrams>=0.23.4
|
||||
graphviz>=0.20.1
|
||||
@@ -0,0 +1,202 @@
|
||||
"""
|
||||
Setup Script for Architecture Diagrams
|
||||
Installs dependencies and sets up the environment for diagram generation
|
||||
"""
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
import platform
|
||||
from pathlib import Path
|
||||
|
||||
def run_command(command, description=""):
|
||||
"""Run a shell command and handle errors"""
|
||||
try:
|
||||
if description:
|
||||
print(f"🔄 {description}...")
|
||||
|
||||
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
||||
|
||||
if result.returncode == 0:
|
||||
if description:
|
||||
print(f"✅ {description} completed successfully")
|
||||
return True
|
||||
else:
|
||||
print(f"❌ Error: {result.stderr}")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Exception: {e}")
|
||||
return False
|
||||
|
||||
def check_python_version():
|
||||
"""Check if Python version is compatible"""
|
||||
version = sys.version_info
|
||||
if version.major >= 3 and version.minor >= 8:
|
||||
print(f"✅ Python {version.major}.{version.minor}.{version.micro} is compatible")
|
||||
return True
|
||||
else:
|
||||
print(f"❌ Python {version.major}.{version.minor}.{version.micro} is not compatible (requires Python 3.8+)")
|
||||
return False
|
||||
|
||||
def check_graphviz():
|
||||
"""Check if Graphviz is installed"""
|
||||
print("🔍 Checking Graphviz installation...")
|
||||
|
||||
if run_command("dot -V", ""):
|
||||
print("✅ Graphviz is already installed")
|
||||
return True
|
||||
else:
|
||||
print("❌ Graphviz not found")
|
||||
return False
|
||||
|
||||
def install_graphviz():
|
||||
"""Install Graphviz based on the operating system"""
|
||||
system = platform.system().lower()
|
||||
|
||||
print(f"🔧 Installing Graphviz for {system}...")
|
||||
|
||||
if system == "windows":
|
||||
print("📋 Windows detected. Please install Graphviz manually:")
|
||||
print(" 1. Download from: https://graphviz.org/download/")
|
||||
print(" 2. Or use Chocolatey: choco install graphviz")
|
||||
print(" 3. Or use Scoop: scoop install graphviz")
|
||||
print(" 4. Add Graphviz bin directory to PATH")
|
||||
return False
|
||||
|
||||
elif system == "darwin": # macOS
|
||||
if run_command("which brew", ""):
|
||||
return run_command("brew install graphviz", "Installing Graphviz via Homebrew")
|
||||
else:
|
||||
print("❌ Homebrew not found. Please install Graphviz manually:")
|
||||
print(" 1. Install Homebrew: https://brew.sh/")
|
||||
print(" 2. Then run: brew install graphviz")
|
||||
return False
|
||||
|
||||
elif system == "linux":
|
||||
# Try different package managers
|
||||
if run_command("which apt-get", ""):
|
||||
return run_command("sudo apt-get update && sudo apt-get install -y graphviz",
|
||||
"Installing Graphviz via apt-get")
|
||||
elif run_command("which yum", ""):
|
||||
return run_command("sudo yum install -y graphviz",
|
||||
"Installing Graphviz via yum")
|
||||
elif run_command("which dnf", ""):
|
||||
return run_command("sudo dnf install -y graphviz",
|
||||
"Installing Graphviz via dnf")
|
||||
elif run_command("which pacman", ""):
|
||||
return run_command("sudo pacman -S graphviz",
|
||||
"Installing Graphviz via pacman")
|
||||
else:
|
||||
print("❌ No supported package manager found. Please install Graphviz manually.")
|
||||
return False
|
||||
else:
|
||||
print(f"❌ Unsupported operating system: {system}")
|
||||
return False
|
||||
|
||||
def install_python_dependencies():
|
||||
"""Install Python dependencies for diagrams"""
|
||||
print("📦 Installing Python dependencies...")
|
||||
|
||||
# Create diagrams directory if it doesn't exist
|
||||
Path("diagrams").mkdir(exist_ok=True)
|
||||
|
||||
# Install from requirements file
|
||||
if os.path.exists("diagrams/requirements.txt"):
|
||||
return run_command(f"{sys.executable} -m pip install -r diagrams/requirements.txt",
|
||||
"Installing Python packages")
|
||||
else:
|
||||
# Fallback to direct installation
|
||||
packages = ["diagrams>=0.23.4", "graphviz>=0.20.1"]
|
||||
for package in packages:
|
||||
if not run_command(f"{sys.executable} -m pip install {package}",
|
||||
f"Installing {package}"):
|
||||
return False
|
||||
return True
|
||||
|
||||
def verify_installation():
|
||||
"""Verify that everything is installed correctly"""
|
||||
print("🔍 Verifying installation...")
|
||||
|
||||
# Check Python imports
|
||||
try:
|
||||
import diagrams
|
||||
print(f"✅ Diagrams library version: {diagrams.__version__}")
|
||||
except ImportError:
|
||||
print("❌ Failed to import diagrams library")
|
||||
return False
|
||||
|
||||
# Check Graphviz again
|
||||
if not check_graphviz():
|
||||
return False
|
||||
|
||||
# Test diagram generation
|
||||
try:
|
||||
print("🧪 Testing diagram generation...")
|
||||
|
||||
test_code = '''
|
||||
from diagrams import Diagram, Node
|
||||
from diagrams.generic.compute import Rack
|
||||
|
||||
with Diagram("Test Diagram", filename="diagrams/test_diagram", show=False):
|
||||
test_node = Rack("Test Node")
|
||||
'''
|
||||
|
||||
# Write test file
|
||||
with open("diagrams/test_setup.py", "w") as f:
|
||||
f.write(test_code)
|
||||
|
||||
# Run test
|
||||
result = subprocess.run([sys.executable, "diagrams/test_setup.py"],
|
||||
capture_output=True, text=True)
|
||||
|
||||
if result.returncode == 0 and os.path.exists("diagrams/test_diagram.png"):
|
||||
print("✅ Test diagram generated successfully")
|
||||
# Clean up test files
|
||||
os.remove("diagrams/test_setup.py")
|
||||
os.remove("diagrams/test_diagram.png")
|
||||
return True
|
||||
else:
|
||||
print(f"❌ Test diagram generation failed: {result.stderr}")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Test generation exception: {e}")
|
||||
return False
|
||||
|
||||
def main():
|
||||
"""Main setup function"""
|
||||
print("🚀 Architecture Diagrams Setup")
|
||||
print("=" * 40)
|
||||
|
||||
# Check Python version
|
||||
if not check_python_version():
|
||||
sys.exit(1)
|
||||
|
||||
# Check and install Graphviz
|
||||
if not check_graphviz():
|
||||
print("📥 Graphviz installation required...")
|
||||
if not install_graphviz():
|
||||
print("\n⚠️ Please install Graphviz manually and run this script again.")
|
||||
sys.exit(1)
|
||||
|
||||
# Install Python dependencies
|
||||
if not install_python_dependencies():
|
||||
print("❌ Failed to install Python dependencies")
|
||||
sys.exit(1)
|
||||
|
||||
# Verify installation
|
||||
if not verify_installation():
|
||||
print("❌ Installation verification failed")
|
||||
sys.exit(1)
|
||||
|
||||
print("\n" + "=" * 40)
|
||||
print("🎉 Setup completed successfully!")
|
||||
print("\nNext steps:")
|
||||
print(" 1. Generate all diagrams: python diagrams/generate_all_diagrams.py")
|
||||
print(" 2. Generate specific diagram: cd diagrams && python 01_data_flow_architecture.py")
|
||||
print(" 3. View generated PNG files in the diagrams/ directory")
|
||||
print("\n📚 See diagrams/README.md for detailed usage instructions")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user