# dev-nikhil02/war-of-survival architecture

> Architecture diagram of the GitHub repository dev-nikhil02/war-of-survival, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dev-nikhil02/war-of-survival
- Repository: https://github.com/dev-nikhil02/war-of-survival

## Overview

##### Project type and purpose
- This is an end-to-end machine-learning classification web app built on the Titanic Kaggle dataset.
- It consists of two major phases: a Training phase (data exploration, feature engineering, model training) and a Deployment phase (packaged model served via a Streamlit UI).

##### File structure
Top-level directories:
- .devcontainer: local VS Code/container setup
- Training: Jupyter notebooks + raw CSVs for model building
- Deployment: Streamlit app code plus saved model and scaler pickles
- assests: images (feature importance, confusion matrix)
- readme.md: project overview
Key files:
- Training/Titanic_Survival_Prediction.ipynb – end-to-end ML notebook
- Deployment/app.py – Streamlit application entry point
- Deployment/random_forest_model_titanic.pkl, scaler.pkl – serialized artifacts
- Deployment/requirements.txt – deployment dependencies

##### README for additional insights
- Algorithm: Random Forest with MinMaxScaler
- Hyperparameter tuning via RandomizedSearchCV, 5-fold CV
- Deployment platform: Streamlit (optionally Streamlit Cloud)
- Inputs: Age, Fare, FamilySize, Pclass, Sex, Embarked, Title → scaled → model → prediction

a. Main components
1. Data Storage:
- Raw CSVs (train.csv, test.csv) in the Training folder
2. Preprocessing & Feature Engineering:
- Notebook cell blocks or modularized scripts (impute, encode, scale)
3. Model Training Pipeline:
- Random Forest training block, hyperparameter tuning, cross-validation
4. Artifact Storage:
- Serialized model (random_forest_model_titanic.pkl)
- Serialized scaler (scaler.pkl)
5. Deployment Environment:
- Docker/.devcontainer for reproducible dev environment
- Streamlit app (app.py) served on local host or Streamlit Cloud
6. User Interface (Streamlit UI):
- Input widgets → sends feature vector to inference module → displays result
7. External Services (optional):
- Streamlit Cloud hosting
- GitHub repo for CI/CD (if any)

b. Relationships and interactions
- Data Storage → Preprocessing → Model Training → Artifact Storage
- Artifact Storage → Deployment Environment → Streamlit UI
- User Input (UI) → Scaler → Model → Prediction → UI output
- Dev container → ensures identical env for both Training and Deployment

c. Architectural patterns / design principles
- Separation of concerns: training vs. serving
- Reproducibility: containerized environment (.devcontainer), pinned requirements
- Modular ML pipeline: distinct stages (extract, transform, train, serialize, serve)

d. Key technologies & libraries
- Python, Jupyter Notebook for training
- pandas, scikit-learn (RandomForestClassifier, MinMaxScaler, RandomizedSearchCV)
- joblib for serialization
- Streamlit for web UI
- Docker/VS Code Dev Containers for environment consistency

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Training Phase
    subgraph "Training Phase"
        RawData["Raw Data (CSV)"]:::data
        Preprocessing["Feature Engineering Module\n(Jupyter Notebook)"]:::compute
        Training["Model Training & Tuning\n(Random Forest, RandomizedSearchCV)"]:::compute
        ModelArtifact["Serialized Model\n(random_forest_model_titanic.pkl)"]:::data
        ScalerArtifact["Serialized Scaler\n(scaler.pkl)"]:::data
        Visuals["Evaluation & Visualization Assets\n(assests/)"]:::data
    end

    %% Serving Phase
    subgraph "Serving Phase"
        DevContainer["Dev Container Config\n(.devcontainer/devcontainer.json)"]:::config
        Requirements["Deployment Dependencies\n(requirements.txt)"]:::config
        App["Streamlit App & Inference\n(app.py)"]:::runtime
        User["End User\n(Streamlit UI)"]:::external
    end

    %% Documentation
    Documentation["Project Documentation & Overview\n(readme.md)"]:::config

    %% Connections
    RawData --> Preprocessing
    Preprocessing --> Training
    Training --> ModelArtifact
    Training --> ScalerArtifact
    Training --> Visuals

    ModelArtifact --> App
    ScalerArtifact --> App

    DevContainer --> Preprocessing
    DevContainer --> App
    Requirements --> App

    App --> User
    User --> App

    Documentation --- RawData

    %% Click Events
    click RawData "https://github.com/dev-nikhil02/war-of-survival/blob/main/Training/train.csv"
    click Preprocessing "https://github.com/dev-nikhil02/war-of-survival/blob/main/Training/Titanic_Survival_Prediction.ipynb"
    click Training "https://github.com/dev-nikhil02/war-of-survival/blob/main/Training/Titanic_Survival_Prediction.ipynb"
    click ModelArtifact "https://github.com/dev-nikhil02/war-of-survival/blob/main/Deployment/random_forest_model_titanic.pkl"
    click ScalerArtifact "https://github.com/dev-nikhil02/war-of-survival/blob/main/Deployment/scaler.pkl"
    click App "https://github.com/dev-nikhil02/war-of-survival/blob/main/Deployment/app.py"
    click Requirements "https://github.com/dev-nikhil02/war-of-survival/blob/main/Deployment/requirements.txt"
    click DevContainer "https://github.com/dev-nikhil02/war-of-survival/blob/main/.devcontainer/devcontainer.json"
    click Visuals "https://github.com/dev-nikhil02/war-of-survival/tree/main/assests/"
    click Documentation "https://github.com/dev-nikhil02/war-of-survival/blob/main/readme.md"

    %% Styles
    classDef data fill:#D0E6F7,stroke:#4A90E2,color:#000
    classDef compute fill:#DFF2D8,stroke:#3C763D,color:#000
    classDef runtime fill:#FDEBD0,stroke:#F39C12,color:#000
    classDef config fill:#ECECEC,stroke:#A6A6A6,color:#000
    classDef external fill:#F2F2F2,stroke:#999,color:#000
```
