% Required:
% \usetikzlibrary{positioning,calc,shadows}

\begin{center}

  \begin{tikzpicture}[
    box/.style={
      draw,
      fill=white,
      drop shadow={shadow xshift=0.08cm, shadow yshift=-0.08cm},
      align=center,
      rounded corners,
    },
    smallmsg/.style={
      draw,
      fill=white,
      font=\scriptsize,
      align=left,
      text width=3cm,
      rounded corners=4pt,
      minimum height=0.5cm,
    },
    memitem/.style={
      draw,
      fill=white,
      font=\scriptsize,
      align=left,
      minimum height=0.5cm,
      text width=3.8cm,
      rounded corners
    },
    retrievedmem/.style={
      memitem,
      fill=blue!10,
      draw=blue!55
    },
    newmem/.style={
      memitem,
      fill=red!8,
      draw=red!55!black
    },
    usedmem/.style={
      smallmsg,
      fill=blue!10,
      draw=blue!55
    },
    opseg/.style={
      draw,
      fill=white,
      font=\scriptsize\bfseries,
      align=center,
      minimum height=0.6cm,
      text width=1.3cm,
      rounded corners,
    },
    arrow/.style={
      ->,
      thick
    },
    retrarrow/.style={
      ->,
      thick,
      blue!55!black
    },
    updatearrow/.style={
      ->,
      thick,
      red!65!black
    }
    ]

      \node[box, minimum width=5.6cm, minimum height=6.8cm] (conv) at (0,0) {};
      \node[font=\scriptsize\bfseries, rotate=90,anchor=north east] at (conv.north east) {Conversation};

      \path
      ([yshift=-0.3cm]conv.north west) node [anchor=north west,text width=0.4cm] (historyicon) {\faIcon{history}}
      (historyicon.north east) node[smallmsg, anchor=north west,text width=] (histmsg) {\textbf{[History Messages]}};

      \path
      ([yshift=-0.3cm]histmsg.south-|conv.east) node [anchor=north east,text width=0.4cm,align=right] (usericon) {\faIcon{user}}
      (usericon.north west) node[smallmsg, anchor=north east] (usermsg) {Plan a trip to Kyoto next week.};

      \path
      ([yshift=-0.3cm]usermsg.south-|conv.west) node [anchor=north west,text width=0.4cm] (roboticon) {\faIcon{robot}}
      (roboticon.north east) node[smallmsg, anchor=north west] (robotmsg0) {I will check your travel preferences and past choices.};

      \path
      ([yshift=-0.3cm]robotmsg0.south-|conv.east) node [anchor=north east,text width=0.4cm,align=right] (infoicon) {\faIcon{info-circle}}
      (infoicon.north west) node[usedmem, anchor=north east] (infomsg)
      {$\bullet$ prefers window seat\\ $\bullet$ vegetarian meals\\ $\bullet$ budget hotel};

      \path
      ([yshift=-0.25cm]infomsg.south-|conv.east) node [anchor=north east,text width=0.4cm,align=right] (usericon2) {\faIcon{user}}
      (usericon2.north west) node[smallmsg, anchor=north east,fill=red!8,draw=red!55!black] (newmsg)
      {I also prefer a quiet\\ ryokan near Kyoto\\ Station.};

      \path
      ([yshift=-0.25cm]newmsg.south-|conv.west) node [anchor=north west,text width=0.4cm] (roboticon2) {\faIcon{robot}}
      (roboticon2.north east) node[smallmsg, anchor=north west] (robotmsg) {$\cdots \cdots$};

      \node[box, minimum width=5cm, minimum height=5.8cm] (memory) at ([xshift=8cm]conv) {};
      \node[font=\small\bfseries] at ($(memory.north)+(0,-0.35)$) {Memory Bank};

      \node[retrievedmem, anchor=north,align=center] (m1) at ([yshift=-0.9cm]memory.north) {\textbf{Memory 1}\\ prefers vegetarian meals};
      \node[retrievedmem, anchor=north,align=center] (m2) at ([yshift=-0.2cm]m1.south) {\textbf{Memory 2}\\ prefers window seat};
      \node[retrievedmem, anchor=north,align=center] (m3) at ([yshift=-0.2cm]m2.south) {\textbf{Memory 3}\\ usually books budget hotels};
      \node[newmem, anchor=north,align=center] (m4) at ([yshift=-0.2cm]m3.south) {\textbf{Memory 4}\\ prefers quiet ryokans\\ near Kyoto Station};
      \node[memitem, anchor=north,align=center] (m5) at ([yshift=-0.2cm]m4.south) {$\cdots$};
      

      \draw[retrarrow] (conv.east|-robotmsg0.east) -- node[above, font=\scriptsize,align=center,text=blue!55!black] {retrieving \\ relevant memories} (memory.west|-robotmsg0.east);
      \draw[retrarrow] (memory.west|-infomsg.east) -- node[above, font=\scriptsize,align=center,text=blue!55!black] {useful memories} (conv.east|-infomsg.east);

      \scriptsize
      \node[box, text width=4.5cm, minimum height=2cm,anchor=north west,align=left] (memext) at ([yshift=-.5cm]conv.south west)
      {\centering\textbf{\small Extract Memories}\\[.2cm]
      \raggedright
      \textbf{New memory:}\\
      user prefers quiet ryokans\\
      user prefers the Kyoto Station area};

      \node[box, text width=7.5cm, minimum height=2cm,anchor=north east,align=center] (llmupdatemem) at ([yshift=-.5cm]conv.south-|memory.south east)
      {\textbf{\small Memory Manager} \vspace{1.cm}};

      \node[opseg,anchor=south west] (add) at ([xshift=.4cm,yshift=.3cm]llmupdatemem.south west) {ADD};
      \node[opseg, right=.3cm of add] (update) {UPDATE};
      \node[opseg, right=.3cm of update] (delete) {DELETE};
      \node[opseg, right=.3cm of delete] (noop) {NOOP};

      \draw[] ([xshift=-.1cm,yshift=.1cm]add.north west) rectangle ([xshift=.1cm,yshift=-.1cm]noop.south east);

      \draw[updatearrow] (memext.north|-conv.south) -- node[right, font=\scriptsize,text=red!65!black] {new memories} (memext.north);
      \draw[updatearrow] (memext) -- (llmupdatemem);
      \draw[updatearrow] (memory.south|-llmupdatemem.north) -- node[right,font=\scriptsize,text=red!65!black] {ADD} (memory.south);

  \end{tikzpicture}

\end{center}
