# mahmoud-shehataa/car-type-detection architecture

> Architecture diagram of the GitHub repository mahmoud-shehataa/car-type-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mahmoud-shehataa/car-type-detection
- Repository: https://github.com/mahmoud-shehataa/car-type-detection

## Overview

This repository trains and serves a 196-class Stanford Cars image classifier. The main user workflow is uploading a car photo in the Streamlit Classifier page, loading the saved model, preprocessing the image, and returning a class label and confidence. The README also documents a notebook-based training workflow using Stanford Cars and Xception transfer learning. Training details are documented but the notebook source was not sampled; the graph shows only that documented relationship, not internal training steps.

Main entry points: [`src/car_classifier/inference.py`](https://github.com/mahmoud-shehataa/car-type-detection/blob/main/src/car_classifier/inference.py) (Prediction and preprocessing), [`app/streamlit_app.py`](https://github.com/mahmoud-shehataa/car-type-detection/blob/main/app/streamlit_app.py) (Page navigation), [`src/car_classifier/labels.py`](https://github.com/mahmoud-shehataa/car-type-detection/blob/main/src/car_classifier/labels.py) (Class-name lookup), [`app/pages/classifier.py`](https://github.com/mahmoud-shehataa/car-type-detection/blob/main/app/pages/classifier.py) (Image classifier page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Streamlit app"]
  node_app_entry["Page navigation<br/>[streamlit_app.py]"]
  node_home["Project overview<br/>[home.py]"]
  node_classifier["Image classifier page<br/>[classifier.py]"]
end

subgraph group_runtime["Inference runtime"]
  node_inference["Prediction and preprocessing<br/>[inference.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
  node_labels["Class-name lookup<br/>[labels.py]"]
end

subgraph group_training["Training and artifacts"]
  node_label_data["Ordered class names<br/>[class_names.txt]"]
  node_model["Trained Keras model<br/>[model_v2.keras]"]
  node_notebook["Model training"]
end

node_user(("User"))
node_dataset[("Stanford Cars dataset")]

node_user -->|"opens app"| node_app_entry
node_app_entry -->|"routes to"| node_home
node_app_entry -->|"routes to"| node_classifier
node_user -->|"uploads image"| node_classifier
node_classifier -->|"requests prediction"| node_inference
node_inference -->|"reads settings"| node_config
node_inference -->|"loads labels"| node_labels
node_labels -->|"reads label path"| node_config
node_labels -->|"reads names"| node_label_data
node_inference -->|"loads model"| node_model
node_dataset -->|"trains on"| node_notebook
node_notebook -->|"produces model"| node_model

click node_app_entry "https://github.com/mahmoud-shehataa/car-type-detection/blob/main/app/streamlit_app.py"
click node_home "https://github.com/mahmoud-shehataa/car-type-detection/blob/main/app/pages/home.py"
click node_classifier "https://github.com/mahmoud-shehataa/car-type-detection/blob/main/app/pages/classifier.py"
click node_inference "https://github.com/mahmoud-shehataa/car-type-detection/blob/main/src/car_classifier/inference.py"
click node_config "https://github.com/mahmoud-shehataa/car-type-detection/blob/main/src/car_classifier/config.py"
click node_labels "https://github.com/mahmoud-shehataa/car-type-detection/blob/main/src/car_classifier/labels.py"
click node_label_data "https://github.com/mahmoud-shehataa/car-type-detection/blob/main/data/class_names.txt"
click node_model "https://github.com/mahmoud-shehataa/car-type-detection/blob/main/models/model_v2.keras"
click node_notebook "https://github.com/mahmoud-shehataa/car-type-detection/blob/main/notebooks/car_type_classification.ipynb"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app_entry,node_home,node_classifier,node_user toneBlue
class node_inference,node_config,node_labels,node_dataset toneAmber
class node_label_data,node_model,node_notebook toneMint
```

## Components

### Streamlit app

- [Page navigation](https://github.com/mahmoud-shehataa/car-type-detection/blob/main/app/streamlit_app.py): `app/streamlit_app.py`
- [Project overview](https://github.com/mahmoud-shehataa/car-type-detection/blob/main/app/pages/home.py): `app/pages/home.py`
- [Image classifier page](https://github.com/mahmoud-shehataa/car-type-detection/blob/main/app/pages/classifier.py): `app/pages/classifier.py`

### Inference runtime

- [Prediction and preprocessing](https://github.com/mahmoud-shehataa/car-type-detection/blob/main/src/car_classifier/inference.py): `src/car_classifier/inference.py`
- [Runtime configuration](https://github.com/mahmoud-shehataa/car-type-detection/blob/main/src/car_classifier/config.py): `src/car_classifier/config.py`
- [Class-name lookup](https://github.com/mahmoud-shehataa/car-type-detection/blob/main/src/car_classifier/labels.py): `src/car_classifier/labels.py`

### Training and artifacts

- [Ordered class names](https://github.com/mahmoud-shehataa/car-type-detection/blob/main/data/class_names.txt): `data/class_names.txt`
- [Trained Keras model](https://github.com/mahmoud-shehataa/car-type-detection/blob/main/models/model_v2.keras): `models/model_v2.keras`
- [Model training](https://github.com/mahmoud-shehataa/car-type-detection/blob/main/notebooks/car_type_classification.ipynb): `notebooks/car_type_classification.ipynb`

### Other components

- **User**
- **Stanford Cars dataset**

## Connections

- User → Page navigation: opens app (evidence: `README.md`)
- Page navigation → Project overview: routes to (evidence: `app/streamlit_app.py`)
- Page navigation → Image classifier page: routes to (evidence: `app/streamlit_app.py`)
- User → Image classifier page: uploads image (evidence: `app/pages/classifier.py`)
- Image classifier page → Prediction and preprocessing: requests prediction (evidence: `app/pages/classifier.py`)
- Prediction and preprocessing → Runtime configuration: reads settings (evidence: `src/car_classifier/inference.py`)
- Prediction and preprocessing → Class-name lookup: loads labels (evidence: `src/car_classifier/inference.py`)
- Class-name lookup → Runtime configuration: reads label path (evidence: `src/car_classifier/labels.py`)
- Class-name lookup → Ordered class names: reads names (evidence: `src/car_classifier/labels.py`)
- Prediction and preprocessing → Trained Keras model: loads model (evidence: `src/car_classifier/inference.py`)
- Stanford Cars dataset → Model training: trains on (evidence: `README.md`)
- Model training → Trained Keras model: produces model (evidence: `README.md`)
