Blockchain, a distributed and digital ledger technology, has the potential to transform several industries from cryptocurrencies to supply chains. However, the complexity of understanding the technology can be a challenge for most people, especially for newcomers. This study paper aims to provide an indepth analysis and review of the different layers including the data, network, consensus, smart contract, and application layers. In this paper, we performed an in-depth analysis and review of the components of each layer. We also tried to simulate different consensus algorithms so a reader can understand which blockchain consensus algorithm can be chosen for a specific application. By reading this paper, a reader can understand the blockchain architecture and choose the right algorithms, languages and protocols for building their own blockchain network. The paper also addresses the challenges and difficulties of building a sustainable and secure blockchain. We believe that the choice of consensus algorithm is the most important thing for sustainability in a blockchain network. We show that some consensus algorithms use much more energy than others, and we suggest that developers choose consensus algorithms that use less energy. This paper is a great resource for anyone who wants to learn more about blockchain architecture and consensus algorithms. It gives a complete review of the subject and talks about the difficulties of making a blockchain that will be secure and sustainable. Researchers, developers, and anyone else interested in the future of blockchain technology will be interested in this study.