\documentclass[11pt, a4paper]{article}

% --- Packages ---
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[margin=2.5cm]{geometry} % Standard margins
\usepackage{titlesec}
\usepackage{enumitem}
\usepackage{hyperref}
\usepackage{mathptmx} % Times New Roman-like font for a professional look
\usepackage{graphicx} % For the logo
\usepackage{fancyhdr} % For headers/footers

% --- Formatting ---
\titleformat{\section}{\large\bfseries\uppercase}{}{0em}{}[\titlerule]
\titleformat{\subsection}{\bfseries}{}{0em}{}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0.5em}

% --- Header/Footer ---
\pagestyle{fancy}
\fancyhf{}
\rhead{Executive Summary}
\lhead{Amirhossein Shekari}
\cfoot{\thepage}

\begin{document}

% --- Title Area ---
\begin{center}
    \vspace*{0.5cm}
    % If you want your logo, uncomment the line below. 
    % Make sure the path matches your project structure.
    % \includegraphics[width=4cm]{Cover/Logoblu.pdf} \\ 
    \vspace{0.5cm}
    {\Large \textbf{DECENTRALIZED ASSET TRACKING AND MAINTENANCE FOR RAILWAY SYSTEMS USING BLOCKCHAIN TECHNOLOGY}} \\
    \vspace{0.5cm}
    \textbf{Executive Summary of Master's Thesis} \\
    \vspace{0.5cm}
    \begin{tabular}{rl}
        \textbf{Candidate:} & Amirhossein Shekari \\
        \textbf{Student ID:} & S309094 \\
        \textbf{Supervisors:} & Prof. Valentina Gatteschi, Prof. Marco Domaneschi, Prof. Valentina Villa \\
        \textbf{Academic Year:} & 2024-2025 \\
        \textbf{Institution:} & Politecnico di Torino \\
    \end{tabular}
    \vspace{0.5cm}
    \hrule
\end{center}

\section{1. Motivation and Problem Statement}

The railway industry is a safety-critical sector that relies on the management of complex, hierarchical physical assets (trains, wagons, and component equipment). Traditional asset management systems in this domain currently face three fundamental challenges:

\begin{enumerate}[leftmargin=*]
    \item \textbf{Data Silos \& Fragmentation:} Stakeholders (operators, maintenance crews, manufacturers, and regulators) maintain isolated, centralized databases. There is no single, interoperable source of truth regarding an asset's lifecycle.
    \item \textbf{Lack of Trust and Integrity:} Centralized records can be altered, lost, or falsified. An operator cannot cryptographically verify if a maintenance report provided by a third-party crew is authentic, leading to costly redundant audits.
    \item \textbf{Inefficiency:} Reliance on manual data entry and paper-based logs introduces latency and human error, preventing the industry from moving toward real-time Predictive Maintenance (PdM).
\end{enumerate}


\section{2. Proposed Solution: A 3-Tier Hybrid Architecture}

This thesis proposes and implements a \textbf{Hybrid Blockchain System}. The core innovation is the intelligent separation of data: \textbf{Critical Asset Data} is stored on an immutable blockchain to ensure trust, while \textbf{User/Application Data} is stored off-chain to ensure performance and privacy.

The system is implemented via a 3-tier architecture:

\subsection*{Tier 1: The Data Layer (Blockchain Core)}
\begin{itemize}[noitemsep]
    \item \textbf{Technology:} Solidity Smart Contract deployed on the \textbf{Sepolia Testnet}.
    \item \textbf{Function:} Acts as the immutable ledger for asset identity and maintenance history.
    \item \textbf{Data Structure:} Implements a hierarchical relational model (\texttt{Train} $\rightarrow$ \texttt{Wagon} $\rightarrow$ \texttt{Equipment}) using optimized mapping strategies.
    \item \textbf{Key Innovation (Gas Optimization):} The contract utilizes \textbf{struct packing} (using \texttt{uint32} instead of \texttt{uint256} for IDs/timestamps) and \textbf{custom errors} to minimize storage costs.
\end{itemize}

\subsection*{Tier 2: The Logic Layer (Intelligent Middleware)}
\begin{itemize}[noitemsep]
    \item \textbf{Technology:} Python \textbf{FastAPI}.
    \item \textbf{Function:} Acts as the secure bridge between the user and the blockchain.
    \item \textbf{Hybrid Logic:} 
    \begin{itemize}
        \item \textbf{Off-Chain:} Manages user authentication (JWT) and sessions using a local \textbf{SQLite} database to ensure GDPR compliance and zero-latency logins.
        \item \textbf{On-Chain:} Manages private keys and orchestrates transaction signing/submission to the Ethereum network via \textbf{Alchemy}.
    \end{itemize}
    \item \textbf{Validation:} Uses \textbf{Pydantic} schemas to pre-validate data, preventing invalid transactions from wasting gas.
\end{itemize}

\subsection*{Tier 3: The Presentation Layer (User Interface)}
\begin{itemize}[noitemsep]
    \item \textbf{Technology:} \textbf{React} (TypeScript) with TailwindCSS.
    \item \textbf{Function:} A mobile-first interface for maintenance staff.
    \item \textbf{Key Innovation (PWA):} The frontend is built as a \textbf{Progressive Web App}. It utilizes Service Workers to cache the application shell, allowing mechanics to view data and draft reports even in \textbf{offline environments} (e.g., railway tunnels) where internet connectivity is absent.
\end{itemize}

\section{3. Experimental Evaluation and Results}

To validate the feasibility of the system, a rigorous experimental evaluation was conducted using a production-grade environment (Hetzner VPS, Dockerized deployment).

\subsection*{A. Smart Contract Efficiency (Gas Costs)}
A comparative analysis was performed between a standard ``Naive`` implementation and the thesis's ``Optimized`` contract.

\begin{itemize}[noitemsep]
    \item \textbf{Result:} The optimization strategies (struct packing, custom errors) resulted in a \textbf{15\% reduction in gas costs} for adding equipment and a \textbf{7\% reduction} for adding wagons.
    \item \textbf{Economic Implication:} On a Layer 2 network (like Optimism), the cost of recording a maintenance event is projected to be \textbf{$<$ \$0.02}, proving the system is economically viable for large-scale fleets.
\end{itemize}

\subsection*{B. System Performance (Latency)}
The system's response times were measured to validate the hybrid architecture's trade-offs.

\begin{center}
\begin{tabular}{|l|l|l|l|}
\hline
\textbf{Operation Type} & \textbf{Action} & \textbf{Latency (approx.)} & \textbf{Implication} \\
\hline
Off-Chain Read & User Login & \textbf{$\sim$727 ms} & Secure, standard web speed. \\
On-Chain Read & View Asset List & \textbf{$\sim$255 ms} & Instant retrieval via API caching. \\
On-Chain Write & Update Maintenance & \textbf{$\sim$13.72 s} & Slower due to block confirmation. \\
\hline
\end{tabular}
\end{center}

\textbf{Conclusion:} The system provides a fast ``Web2-like`` experience for 90\% of interactions (reading/viewing). The $\sim$14s delay is isolated only to critical write operations, which is an acceptable trade-off to gain global immutability.

\subsection*{C. Usability and PWA Verification}
Google Lighthouse audits confirmed the quality of the frontend engineering:
\begin{itemize}[noitemsep]
    \item \textbf{Accessibility:} \textbf{98/100} (Ensuring usability for diverse staff).
    \item \textbf{PWA Capabilities:} Validated Service Worker registration and Manifest detection, confirming the app is installable and offline-capable.
\end{itemize}

\section{4. Conclusion}

This thesis successfully bridges the gap between theoretical blockchain frameworks and practical industrial application. By designing a \textbf{Hybrid Architecture}, the system solves the ``Trilemma`` of railway asset tracking:

\begin{enumerate}[noitemsep]
    \item \textbf{Trust} is guaranteed via the Blockchain.
    \item \textbf{Privacy/Speed} is maintained via the Off-chain Middleware.
    \item \textbf{Usability} is ensured via the Offline-First PWA.
\end{enumerate}

The result is a working, full-stack prototype that offers a scalable blueprint for the future of secure, interoperable railway maintenance.

\end{document}