I am trying to design a multi-layered architecture for my thesis but struggling a lot. Please advise for one layer and I ll try for the rest. The expected figure is attached below and the code I have written so far is as follows

I asked questions earlier as well but couldn't progress much. Following code is from my earlier [question](https://tex.stackexchange.com/questions/435865/node-placements-in-tikz) 

```
\documentclass{elsarticle}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{epstopdf}
\usepackage[ruled,vlined,linesnumbered]{algorithm2e}
\usepackage{algpseudocode}
\usepackage{tikz,pgfplots,pgfplotstable}
\usepackage{tikz-qtree}
\usepackage{forest}
\usepackage{lettrine}
\usepackage{mathtools}
\usepackage{lscape}
\usepackage{pgf-pie}

\usetikzlibrary{positioning,shapes,arrows,shadows,patterns,intersections,calc,fit}

\tikzset{
myRectangle/.style={
    rectangle,
    draw,
    node distance=0.65 cm,
    text width=7 em,
    text centered,
    rounded corners,
    minimum height=4 em,
    minimum width=3 cm,
    thick
},
redRectangle/.style={
    myRectangle,
    fill=red!20,
},
container/.style={
    rectangle,
    draw,
    inner sep=0.5 cm,
    rounded corners 
},
line/.style={
    draw,
    -latex',
    thick
}
}
\begin{document}
\begin{figure*}
\centering
\begin{tikzpicture}[transform shape]
\node [](origin){};
\node [redRectangle, right=of origin] (aa) {aa};
\node [redRectangle, left=of origin] (bb) {bb};
\node [redRectangle, below=of bb] (cc) {cc};
\node [redRectangle, below=of aa] (dd) {dd};
\path [line] (bb) -- (aa);
\path [line] (bb) -- (cc);
\path [line] (aa) -- (dd);

\node [redRectangle, right=15mm of aa] (pp) {pp}; % question 1
\node [redRectangle, right=of pp] (rr) {rr};
\node [redRectangle] (qq) at ($(pp)!.5!(rr) + (0,-2)$) {qq}; % question 2

\node [container, fit=(aa)(origin)(bb)(cc)(dd)] (container1) {};
\node [container, fit=(pp)(rr)(qq)] (container2) {};    

\node [redRectangle] (xx) at ($(aa)!.5!(pp) + (0,3)$) {xx};
\node [container, fit=(xx)] (container3) {};    

\node [container, fit=(container1)(container2)(container3)] (containerAll) {};
\end{tikzpicture}
\end{figure*}
\end{document}

```

[![Expected Figure](https://i.stack.imgur.com/5P5Zq.png)](https://i.stack.imgur.com/5P5Zq.png)