# vj220803/titanic_survival architecture

> Architecture diagram of the GitHub repository vj220803/titanic_survival, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vj220803/titanic_survival
- Repository: https://github.com/vj220803/titanic_survival

## Overview

##### Project type and purpose
- This is a standalone machine-learning classification project (“Titanic Survival Prediction”) whose primary goal is to train a Random Forest model on tabular data and expose prediction functionality via a Python app (app.py).
- It includes exploratory data analysis (EDA) and model-building in a Jupyter notebook, serialized artifacts (model and encoders), and a lightweight serving layer.

##### File structure
Top-level files:
- Titanic_CODSOFT.ipynb – notebook that implements the entire ML pipeline: data loading, EDA, preprocessing, training, evaluation.
- Titanic-Dataset.csv – raw data source.
- titanic_model.pkl, le_sex.pkl, le_embarked.pkl – serialized artifacts from training (model and encoders).
- app.py – Python script acting as the inference service (likely Flask or FastAPI).
- requirements.txt – lists Python dependencies.
- Book1_Titanic.twbx – Tableau workbook for visualizing feature insights.

##### README for additional insights
- The README confirms steps: data loading, cleaning, feature encoding, model training, and evaluation metrics.
- It mentions a “UI Dashboard” (Tableau) link.

a. Main components
1. Data Layer
- Titanic-Dataset.csv (source CSV)
- Tableau workbook (Book1_Titanic.twbx) for visualization (optional)
2. Training Pipeline
- Jupyter Notebook (Titanic_CODSOFT.ipynb) orchestrates:
- Data ingestion (pandas)
- Preprocessing (fill missing, label encoding)
- Feature selection
- Model training (scikit-learn RandomForest)
- Model evaluation
- Produces artifacts: titanic_model.pkl, le_sex.pkl, le_embarked.pkl
3. Inference/API Layer
- app.py: loads pickled model & encoders, exposes an HTTP endpoint (Flask/FastAPI)
- Accepts JSON/post parameters (Pclass, Sex, Age, etc.), returns predicted “Survived” label
4. Client/UI Layer
- Could be:
- A simple web page or Postman/cURL tests against the API
- Tableau Dashboard for visual exploration (reads CSV or API)
b. Relationships & interactions
- Training pipeline reads raw CSV → processes → outputs model artifacts.
- Inference layer loads artifacts at startup → receives user input → applies same preprocessing → invokes model.predict → returns result.
- Optional: Tableau connects directly to CSV or calls the API for live predictions.
c. Architectural patterns & design principles
- Separation of concerns: training vs inference; data vs model serving
- Reproducibility: notebook documents everything, artifacts ensure identical preprocessing in inference
- Stateless API: no persistent session, model loaded once in memory
d. Key technologies
- Python, pandas, scikit-learn, Flask or FastAPI (in app.py)
- Jupyter Notebook (for pipeline orchestration)
- pickle for serialization
- Tableau (for viz)

##### Elements
- Raw Data → Notebook
- Notebook → Model Artifacts
- Model Artifacts → Inference API
- Client → Inference API → Response
- Raw Data → Tableau (optional)
- Blue for data stores (CSV, pickles)
- Green for compute components (Notebook, API)
- Orange for user-facing/UI (Client, Tableau)

##### Final advice
- Be detailed but avoid clutter: group related files/artifacts under each component.
- Essential flow: Data → Train → Artifacts → Serve → Consume.

## Diagram (Mermaid)

```mermaid
graph TB

    subgraph "Data Layer"
        DS1["Titanic-Dataset.csv"]:::dataStore
        DS2["Book1_Titanic.twbx"]:::ui
    end

    subgraph "Training Pipeline"
        NB["Titanic_CODSOFT.ipynb"]:::compute
        RP1["requirements.txt"]:::compute
    end

    subgraph "Model Artifacts"
        MA1["titanic_model.pkl"]:::dataStore
        MA2["le_sex.pkl"]:::dataStore
        MA3["le_embarked.pkl"]:::dataStore
    end

    subgraph "Inference/API Layer"
        API["app.py"]:::compute
        RP2["requirements.txt"]:::compute
    end

    subgraph "Documentation"
        Readme["README.md"]:::doc
    end

    subgraph "Client/UI Layer"
        Client["Client Application"]:::ui
        Tableau["Tableau Dashboard"]:::ui
    end

    DS1 -->|"CSV"| NB
    Readme -->|"guides pipeline"| NB
    NB -->|"pickled artifacts"| MA1
    NB -->|"pickled artifacts"| MA2
    NB -->|"pickled artifacts"| MA3
    MA1 -->|"load artifacts"| API
    MA2 -->|"load artifacts"| API
    MA3 -->|"load artifacts"| API
    Client -->|"HTTP/JSON"| API
    API -->|"JSON Response"| Client
    DS1 -->|"CSV"| Tableau
    API -->|"HTTP/JSON"| Tableau

    click DS1 "https://github.com/vj220803/titanic_survival/blob/main/Titanic-Dataset.csv"
    click DS2 "https://github.com/vj220803/titanic_survival/blob/main/Book1_Titanic.twbx"
    click NB "https://github.com/vj220803/titanic_survival/blob/main/Titanic_CODSOFT.ipynb"
    click RP1 "https://github.com/vj220803/titanic_survival/blob/main/requirements.txt"
    click MA1 "https://github.com/vj220803/titanic_survival/blob/main/titanic_model.pkl"
    click MA2 "https://github.com/vj220803/titanic_survival/blob/main/le_sex.pkl"
    click MA3 "https://github.com/vj220803/titanic_survival/blob/main/le_embarked.pkl"
    click API "https://github.com/vj220803/titanic_survival/blob/main/app.py"
    click RP2 "https://github.com/vj220803/titanic_survival/blob/main/requirements.txt"
    click Readme "https://github.com/vj220803/titanic_survival/blob/main/README.md"

    classDef dataStore fill:#bbdefb,stroke:#1e88e5,color:#0d47a1
    classDef compute fill:#c8e6c9,stroke:#2e7d32,color:#1b5e20
    classDef ui fill:#ffe0b2,stroke:#ef6c00,color:#e65100
    classDef doc fill:#f0f4c3,stroke:#827717,color:#33691e
```
