\doxysection{Application Class Reference}
\hypertarget{classApplication}{}\label{classApplication}\index{Application@{Application}}


Consumer service that manages and authorizes valid financial transactions.  


\doxysubsubsection*{Static Public Member Functions}
\begin{DoxyCompactItemize}
\item 
static void \mbox{\hyperlink{classApplication_a64d4bdb810895ffc94d6df6545333417}{main}} (String\mbox{[}$\,$\mbox{]} args)
\begin{DoxyCompactList}\small\item\em \doxylink{classApplication}{Application} entry point. \end{DoxyCompactList}\item 
static void \mbox{\hyperlink{classApplication_a6c5cb69f6356037259e4536f4b42622b}{consume\+Messages}} (String topic, Consumer$<$ String, \mbox{\hyperlink{classTransaction}{Transaction}} $>$ kafka\+Consumer)
\begin{DoxyCompactList}\small\item\em Subscription and processing loop for Kafka messages. \end{DoxyCompactList}\item 
static Consumer$<$ String, \mbox{\hyperlink{classTransaction}{Transaction}} $>$ \mbox{\hyperlink{classApplication_ac70adb9fd8fc7a0e37b30444e4bc9c08}{create\+Kafka\+Consumer}} (String bootstrap\+Servers, String consumer\+Group)
\begin{DoxyCompactList}\small\item\em Configures and initializes a Kafka Consumer. \end{DoxyCompactList}\item 
static void \mbox{\hyperlink{classApplication_a64d4bdb810895ffc94d6df6545333417}{main}} (String\mbox{[}$\,$\mbox{]} args)
\begin{DoxyCompactList}\small\item\em Main method to start the Banking API Service. \end{DoxyCompactList}\item 
static void \mbox{\hyperlink{classApplication_a125cab15b7a5d17022e5af86a8773e8a}{process\+Transactions}} (\mbox{\hyperlink{classIncomingTransactionsReader}{Incoming\+Transactions\+Reader}} reader, \mbox{\hyperlink{classUserResidenceDatabase}{User\+Residence\+Database}} db, Producer$<$ String, \mbox{\hyperlink{classTransaction}{Transaction}} $>$ producer)
\begin{DoxyCompactList}\small\item\em Orchestrates the flow from transaction ingestion to Kafka production. \end{DoxyCompactList}\item 
static Producer$<$ String, \mbox{\hyperlink{classTransaction}{Transaction}} $>$ \mbox{\hyperlink{classApplication_a0dd0f12a03b8d6390f412e5e7f166e7f}{create\+Kafka\+Producer}} (String bootstrap\+Servers)
\begin{DoxyCompactList}\small\item\em Configures and initializes a high-\/reliability Kafka Producer. \end{DoxyCompactList}\item 
static void \mbox{\hyperlink{classApplication_a64d4bdb810895ffc94d6df6545333417}{main}} (String\mbox{[}$\,$\mbox{]} args)
\begin{DoxyCompactList}\small\item\em \doxylink{classApplication}{Application} entry point. \end{DoxyCompactList}\item 
static void \mbox{\hyperlink{classApplication_a0e52c9f9039021956225a27bdc25cf59}{consume\+Messages}} (List$<$ String $>$ topics, Consumer$<$ String, \mbox{\hyperlink{classTransaction}{Transaction}} $>$ kafka\+Consumer)
\begin{DoxyCompactList}\small\item\em Consumes and processes records from multiple Kafka topics. \end{DoxyCompactList}\item 
static Consumer$<$ String, \mbox{\hyperlink{classTransaction}{Transaction}} $>$ \mbox{\hyperlink{classApplication_ac70adb9fd8fc7a0e37b30444e4bc9c08}{create\+Kafka\+Consumer}} (String bootstrap\+Servers, String consumer\+Group)
\begin{DoxyCompactList}\small\item\em Configures a Kafka Consumer with shared reporting settings. \end{DoxyCompactList}\item 
static void \mbox{\hyperlink{classApplication_a64d4bdb810895ffc94d6df6545333417}{main}} (String\mbox{[}$\,$\mbox{]} args)
\begin{DoxyCompactList}\small\item\em \doxylink{classApplication}{Application} entry point. \end{DoxyCompactList}\item 
static void \mbox{\hyperlink{classApplication_a6c5cb69f6356037259e4536f4b42622b}{consume\+Messages}} (String topic, Consumer$<$ String, \mbox{\hyperlink{classTransaction}{Transaction}} $>$ kafka\+Consumer)
\begin{DoxyCompactList}\small\item\em Main processing loop for incoming suspicious transactions. \end{DoxyCompactList}\item 
static Consumer$<$ String, \mbox{\hyperlink{classTransaction}{Transaction}} $>$ \mbox{\hyperlink{classApplication_ac70adb9fd8fc7a0e37b30444e4bc9c08}{create\+Kafka\+Consumer}} (String bootstrap\+Servers, String consumer\+Group)
\begin{DoxyCompactList}\small\item\em Configures and initializes a Kafka Consumer for notifications. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Consumer service that manages and authorizes valid financial transactions. 

Consumer service responsible for alerting users of potential fraud.

Centralized reporting service for all bank transactions.

The central orchestrator of the distributed banking system.

The Account Manager service subscribes to the "{}valid-\/transactions"{} Kafka topic. Its primary responsibility is to simulate the final authorization of funds and ensure that transactions are processed reliably using manual offset commits.

The Banking API Service acts as the primary Producer. It receives incoming credit card transactions, performs a fraud check by querying a Redis-\/backed \doxylink{classUserResidenceDatabase}{User\+Residence\+Database}, and routes the data to either the \textquotesingle{}valid\textquotesingle{} or \textquotesingle{}suspicious\textquotesingle{} Kafka topics.

This service subscribes to both "{}valid-\/transactions"{} and "{}suspicious-\/transactions"{} topics. It acts as a logger that persists transaction history to the local disk, categorizing them into \textquotesingle{}normal\textquotesingle{} and \textquotesingle{}sus\textquotesingle{} folders for auditing and monthly statement generation.

This microservice monitors the "{}suspicious-\/transactions"{} Kafka topic. When a suspicious transaction is detected by the Banking API, this service notifies the user via console output and logs the notification to a persistent file system for audit purposes. 

\doxysubsection{Member Function Documentation}
\Hypertarget{classApplication_a0e52c9f9039021956225a27bdc25cf59}\label{classApplication_a0e52c9f9039021956225a27bdc25cf59} 
\index{Application@{Application}!consumeMessages@{consumeMessages}}
\index{consumeMessages@{consumeMessages}!Application@{Application}}
\doxysubsubsection{\texorpdfstring{consumeMessages()}{consumeMessages()}\hspace{0.1cm}{\footnotesize\ttfamily [1/3]}}
{\footnotesize\ttfamily static void Application.\+consume\+Messages (\begin{DoxyParamCaption}\item[{List$<$ String $>$}]{topics,  }\item[{Consumer$<$ String, \mbox{\hyperlink{classTransaction}{Transaction}} $>$}]{kafka\+Consumer }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Consumes and processes records from multiple Kafka topics. 

Subscribes to the provided list of topics and enters a polling loop. Each record is delegated to the reporting logic based on its source topic.


\begin{DoxyParams}{Parameters}
{\em topics} & List of topic names to monitor. \\
\hline
{\em kafka\+Consumer} & The initialized Kafka consumer instance. \\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
Safeguard against deserialization errors.
\end{DoxyNote}
\Hypertarget{classApplication_a6c5cb69f6356037259e4536f4b42622b}\label{classApplication_a6c5cb69f6356037259e4536f4b42622b} 
\index{Application@{Application}!consumeMessages@{consumeMessages}}
\index{consumeMessages@{consumeMessages}!Application@{Application}}
\doxysubsubsection{\texorpdfstring{consumeMessages()}{consumeMessages()}\hspace{0.1cm}{\footnotesize\ttfamily [2/3]}}
{\footnotesize\ttfamily static void Application.\+consume\+Messages (\begin{DoxyParamCaption}\item[{String}]{topic,  }\item[{Consumer$<$ String, \mbox{\hyperlink{classTransaction}{Transaction}} $>$}]{kafka\+Consumer }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Subscription and processing loop for Kafka messages. 

This method subscribes to the specified topic, polls Kafka for new records, processes them by calling approve\+Transaction, and manually commits offsets to ensure data consistency.


\begin{DoxyParams}{Parameters}
{\em topic} & The name of the topic to subscribe to. \\
\hline
{\em kafka\+Consumer} & The initialized Kafka consumer instance. \\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
Manual offset management\+: We commit offsets only after the batch has been successfully processed to prevent data loss.
\end{DoxyNote}
\Hypertarget{classApplication_a6c5cb69f6356037259e4536f4b42622b}\label{classApplication_a6c5cb69f6356037259e4536f4b42622b} 
\index{Application@{Application}!consumeMessages@{consumeMessages}}
\index{consumeMessages@{consumeMessages}!Application@{Application}}
\doxysubsubsection{\texorpdfstring{consumeMessages()}{consumeMessages()}\hspace{0.1cm}{\footnotesize\ttfamily [3/3]}}
{\footnotesize\ttfamily static void Application.\+consume\+Messages (\begin{DoxyParamCaption}\item[{String}]{topic,  }\item[{Consumer$<$ String, \mbox{\hyperlink{classTransaction}{Transaction}} $>$}]{kafka\+Consumer }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Main processing loop for incoming suspicious transactions. 

Continuously polls the Kafka topic and triggers user notifications for every received transaction.


\begin{DoxyParams}{Parameters}
{\em topic} & The name of the suspicious transactions topic. \\
\hline
{\em kafka\+Consumer} & The initialized Kafka consumer instance. \\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
Null check ensures the application doesn\textquotesingle{}t crash if a malformed message fails to deserialize.
\end{DoxyNote}
\Hypertarget{classApplication_ac70adb9fd8fc7a0e37b30444e4bc9c08}\label{classApplication_ac70adb9fd8fc7a0e37b30444e4bc9c08} 
\index{Application@{Application}!createKafkaConsumer@{createKafkaConsumer}}
\index{createKafkaConsumer@{createKafkaConsumer}!Application@{Application}}
\doxysubsubsection{\texorpdfstring{createKafkaConsumer()}{createKafkaConsumer()}\hspace{0.1cm}{\footnotesize\ttfamily [1/3]}}
{\footnotesize\ttfamily static Consumer$<$ String, \mbox{\hyperlink{classTransaction}{Transaction}} $>$ Application.\+create\+Kafka\+Consumer (\begin{DoxyParamCaption}\item[{String}]{bootstrap\+Servers,  }\item[{String}]{consumer\+Group }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Configures and initializes a Kafka Consumer. 

Sets up deserializers for \doxylink{classTransaction}{Transaction} objects and disables auto-\/commit to allow for manual offset management.


\begin{DoxyParams}{Parameters}
{\em bootstrap\+Servers} & The list of Kafka brokers. \\
\hline
{\em consumer\+Group} & The ID of the consumer group this instance belongs to. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Consumer$<$\+String, Transaction$>$ A configured Kafka consumer instance. 
\end{DoxyReturn}
Manual offset management is enabled by setting auto-\/commit to false. \textquotesingle{}earliest\textquotesingle{} ensures the consumer reads from the start of the topic if no offset exists.\Hypertarget{classApplication_ac70adb9fd8fc7a0e37b30444e4bc9c08}\label{classApplication_ac70adb9fd8fc7a0e37b30444e4bc9c08} 
\index{Application@{Application}!createKafkaConsumer@{createKafkaConsumer}}
\index{createKafkaConsumer@{createKafkaConsumer}!Application@{Application}}
\doxysubsubsection{\texorpdfstring{createKafkaConsumer()}{createKafkaConsumer()}\hspace{0.1cm}{\footnotesize\ttfamily [2/3]}}
{\footnotesize\ttfamily static Consumer$<$ String, \mbox{\hyperlink{classTransaction}{Transaction}} $>$ Application.\+create\+Kafka\+Consumer (\begin{DoxyParamCaption}\item[{String}]{bootstrap\+Servers,  }\item[{String}]{consumer\+Group }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Configures a Kafka Consumer with shared reporting settings. 

Enables auto-\/commit for reporting purposes, assuming a "{}best-\/effort"{} logging requirement where slight data loss on crash is acceptable for higher throughput.


\begin{DoxyParams}{Parameters}
{\em bootstrap\+Servers} & The Kafka cluster addresses. \\
\hline
{\em consumer\+Group} & The reporting service group ID. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Consumer$<$\+String, Transaction$>$ A configured Kafka consumer. 
\end{DoxyReturn}
\Hypertarget{classApplication_ac70adb9fd8fc7a0e37b30444e4bc9c08}\label{classApplication_ac70adb9fd8fc7a0e37b30444e4bc9c08} 
\index{Application@{Application}!createKafkaConsumer@{createKafkaConsumer}}
\index{createKafkaConsumer@{createKafkaConsumer}!Application@{Application}}
\doxysubsubsection{\texorpdfstring{createKafkaConsumer()}{createKafkaConsumer()}\hspace{0.1cm}{\footnotesize\ttfamily [3/3]}}
{\footnotesize\ttfamily static Consumer$<$ String, \mbox{\hyperlink{classTransaction}{Transaction}} $>$ Application.\+create\+Kafka\+Consumer (\begin{DoxyParamCaption}\item[{String}]{bootstrap\+Servers,  }\item[{String}]{consumer\+Group }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Configures and initializes a Kafka Consumer for notifications. 

Sets the group ID and uses automatic offset committing for high throughput.


\begin{DoxyParams}{Parameters}
{\em bootstrap\+Servers} & The list of Kafka brokers. \\
\hline
{\em consumer\+Group} & The ID for the notification service group. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Consumer$<$\+String, Transaction$>$ A configured Kafka consumer instance. 
\end{DoxyReturn}
Auto-\/commit is enabled here for simple "{}at-\/most-\/once"{} delivery semantics.\Hypertarget{classApplication_a0dd0f12a03b8d6390f412e5e7f166e7f}\label{classApplication_a0dd0f12a03b8d6390f412e5e7f166e7f} 
\index{Application@{Application}!createKafkaProducer@{createKafkaProducer}}
\index{createKafkaProducer@{createKafkaProducer}!Application@{Application}}
\doxysubsubsection{\texorpdfstring{createKafkaProducer()}{createKafkaProducer()}}
{\footnotesize\ttfamily static Producer$<$ String, \mbox{\hyperlink{classTransaction}{Transaction}} $>$ Application.\+create\+Kafka\+Producer (\begin{DoxyParamCaption}\item[{String}]{bootstrap\+Servers }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Configures and initializes a high-\/reliability Kafka Producer. 

Applies settings for Exactly-\/\+Once Semantics (EOS) to prevent double-\/charging or duplicate records in the event of network retries.


\begin{DoxyParams}{Parameters}
{\em bootstrap\+Servers} & The addresses of the Kafka cluster. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Producer$<$\+String, Transaction$>$ A configured Kafka producer instance. 
\end{DoxyReturn}
Exactly-\/\+Once Semantics (EOS)\+:
\begin{DoxyItemize}
\item Idempotence\+: Assigns sequence numbers to prevent duplicates.
\item Acks=all\+: Ensures all replicas acknowledge the write.
\end{DoxyItemize}\Hypertarget{classApplication_a64d4bdb810895ffc94d6df6545333417}\label{classApplication_a64d4bdb810895ffc94d6df6545333417} 
\index{Application@{Application}!main@{main}}
\index{main@{main}!Application@{Application}}
\doxysubsubsection{\texorpdfstring{main()}{main()}\hspace{0.1cm}{\footnotesize\ttfamily [1/4]}}
{\footnotesize\ttfamily static void Application.\+main (\begin{DoxyParamCaption}\item[{String\mbox{[}$\,$\mbox{]}}]{args }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



\doxylink{classApplication}{Application} entry point. 

Initializes the consumer group and starts the infinite message consumption loop. 
\begin{DoxyParams}{Parameters}
{\em args} & Command line arguments (not used). \\
\hline
\end{DoxyParams}
\Hypertarget{classApplication_a64d4bdb810895ffc94d6df6545333417}\label{classApplication_a64d4bdb810895ffc94d6df6545333417} 
\index{Application@{Application}!main@{main}}
\index{main@{main}!Application@{Application}}
\doxysubsubsection{\texorpdfstring{main()}{main()}\hspace{0.1cm}{\footnotesize\ttfamily [2/4]}}
{\footnotesize\ttfamily static void Application.\+main (\begin{DoxyParamCaption}\item[{String\mbox{[}$\,$\mbox{]}}]{args }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Main method to start the Banking API Service. 

Initializes the Kafka producer and begins processing the transaction stream. Ensures the producer is flushed and closed gracefully on shutdown.


\begin{DoxyParams}{Parameters}
{\em args} & Command line arguments. \\
\hline
\end{DoxyParams}
\Hypertarget{classApplication_a64d4bdb810895ffc94d6df6545333417}\label{classApplication_a64d4bdb810895ffc94d6df6545333417} 
\index{Application@{Application}!main@{main}}
\index{main@{main}!Application@{Application}}
\doxysubsubsection{\texorpdfstring{main()}{main()}\hspace{0.1cm}{\footnotesize\ttfamily [3/4]}}
{\footnotesize\ttfamily static void Application.\+main (\begin{DoxyParamCaption}\item[{String\mbox{[}$\,$\mbox{]}}]{args }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



\doxylink{classApplication}{Application} entry point. 

Initializes the consumer and prepares an unmodifiable list of topics to subscribe to. 
\begin{DoxyParams}{Parameters}
{\em args} & Command line arguments. \\
\hline
\end{DoxyParams}
\Hypertarget{classApplication_a64d4bdb810895ffc94d6df6545333417}\label{classApplication_a64d4bdb810895ffc94d6df6545333417} 
\index{Application@{Application}!main@{main}}
\index{main@{main}!Application@{Application}}
\doxysubsubsection{\texorpdfstring{main()}{main()}\hspace{0.1cm}{\footnotesize\ttfamily [4/4]}}
{\footnotesize\ttfamily static void Application.\+main (\begin{DoxyParamCaption}\item[{String\mbox{[}$\,$\mbox{]}}]{args }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



\doxylink{classApplication}{Application} entry point. 

Sets up the consumer group and starts monitoring the suspicious transaction stream. 
\begin{DoxyParams}{Parameters}
{\em args} & Command line arguments. \\
\hline
\end{DoxyParams}
\Hypertarget{classApplication_a125cab15b7a5d17022e5af86a8773e8a}\label{classApplication_a125cab15b7a5d17022e5af86a8773e8a} 
\index{Application@{Application}!processTransactions@{processTransactions}}
\index{processTransactions@{processTransactions}!Application@{Application}}
\doxysubsubsection{\texorpdfstring{processTransactions()}{processTransactions()}}
{\footnotesize\ttfamily static void Application.\+process\+Transactions (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{classIncomingTransactionsReader}{Incoming\+Transactions\+Reader}}}]{reader,  }\item[{\mbox{\hyperlink{classUserResidenceDatabase}{User\+Residence\+Database}}}]{db,  }\item[{Producer$<$ String, \mbox{\hyperlink{classTransaction}{Transaction}} $>$}]{producer }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Orchestrates the flow from transaction ingestion to Kafka production. 

This method implements the core fraud detection logic\+:
\begin{DoxyEnumerate}
\item Retrieve the user\textquotesingle{}s home country from Redis.
\item Compare it to the transaction\textquotesingle{}s reported location.
\item Route the message to the appropriate topic using the user ID as the Kafka Key.

Robustness\+: If a user is missing from the database (e.\+g., \textquotesingle{}Sara\textquotesingle{}), the method catches the Runtime\+Exception, logs an error, and continues processing the next transaction to prevent service downtime.
\end{DoxyEnumerate}


\begin{DoxyParams}{Parameters}
{\em reader} & The source providing incoming transaction objects. \\
\hline
{\em db} & The Redis-\/based residence database for fraud checks. \\
\hline
{\em producer} & The Kafka producer used for message routing. \\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
Key-\/\+Based Routing\+: Passing transaction.\+get\+User() as the Key ensures all transactions for the same user land in the same Kafka partition, guaranteeing processing order.
\end{DoxyNote}


The documentation for this class was generated from the following files\+:\begin{DoxyCompactItemize}
\item 
account-\/manager/src/main/java/\mbox{\hyperlink{account-manager_2src_2main_2java_2Application_8java}{Application.\+java}}\item 
bank-\/api-\/service/src/main/java/\mbox{\hyperlink{bank-api-service_2src_2main_2java_2Application_8java}{Application.\+java}}\item 
reporting-\/service/src/main/java/\mbox{\hyperlink{reporting-service_2src_2main_2java_2Application_8java}{Application.\+java}}\item 
user-\/notification-\/service/src/main/java/\mbox{\hyperlink{user-notification-service_2src_2main_2java_2Application_8java}{Application.\+java}}\end{DoxyCompactItemize}
