<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Angular Architecture and Design Guidelines - TheCodeBuzz</title>
	<atom:link href="https://thecodebuzz.com/tag/angular-architecture-and-design-guidelines/feed/" rel="self" type="application/rss+xml" />
	<link>https://thecodebuzz.com</link>
	<description>Best Practices for Software Development</description>
	<lastBuildDate>Sat, 08 Apr 2023 00:26:18 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://thecodebuzz.com/wp-content/uploads/2022/11/cropped-android-chrome-512x512-1-1-51x51.jpg</url>
	<title>Angular Architecture and Design Guidelines - TheCodeBuzz</title>
	<link>https://thecodebuzz.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Angular Architecture and Design Guidelines</title>
		<link>https://thecodebuzz.com/angular-architecture-and-design-guidelines/</link>
					<comments>https://thecodebuzz.com/angular-architecture-and-design-guidelines/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sun, 24 May 2020 12:30:00 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[angular architecture and best practices free download]]></category>
		<category><![CDATA[Angular Architecture and Design Guidelines]]></category>
		<category><![CDATA[angular architecture buildings]]></category>
		<category><![CDATA[angular architecture design]]></category>
		<category><![CDATA[angular architecture example]]></category>
		<category><![CDATA[angular architecture for large application]]></category>
		<category><![CDATA[angular architecture mvvm]]></category>
		<category><![CDATA[angular architecture patterns]]></category>
		<category><![CDATA[angular architecture patterns and best practices]]></category>
		<category><![CDATA[angular design patterns and best practices]]></category>
		<guid isPermaLink="false">https://thecodebuzz.com/?p=10606</guid>

					<description><![CDATA[<p>Angular Architecture and Design Guidelines Angular 9, the latest version of Angular is out now, and developers have sound reasons to be excited. Angular is a single-page application (SPA) development framework for well-structured, testable, and maintainable front-end applications. Today in this article, we shall cover below high-level architecture aspects of Angular Applications, High-level Application Architecture [&#8230;]</p>
<p>The post <a href="https://thecodebuzz.com/angular-architecture-and-design-guidelines/">Angular Architecture and Design Guidelines</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></description>
										<content:encoded><![CDATA[<h1 class="wp-block-heading">Angular Architecture and Design Guidelines</h1>



<p></p>



<p>Angular 9, the latest version of Angular is out now, and developers have sound reasons to be excited. Angular is a single-page application (<strong><em>SPA</em></strong>) development framework for well-structured, testable, and maintainable front-end applications. </p>



<p></p>



<p>Today in this article, we shall cover below high-level architecture aspects of Angular Applications,</p>



<p></p>



<ul class="wp-block-list"><li>High-level Application Architecture</li><li>Angular Modules &#8211; Entry Point and a domain</li><li>What is a Component?</li><li>Decorator design pattern</li><li>Inversion of Control- Dependency injection </li></ul>



<p></p>



<p>Angular is one of the most widely used application frameworks in the world. Angular’s popularity is due to its compatibility across platforms. Apps written with Angular can run on the web, natively on mobile and desktop platforms.</p>



<p></p>



<h2 class="wp-block-heading">Angular Application Architecture</h2>



<p></p>



<figure class="wp-block-image size-large is-resized"><img fetchpriority="high" decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2020/05/Angular-Application-Architecture-diagram.jpg" alt="Angular Architecture and Design Guidelines" class="wp-image-10669" width="551" height="544" srcset="https://thecodebuzz.com/wp-content/uploads/2020/05/Angular-Application-Architecture-diagram.jpg 872w, https://thecodebuzz.com/wp-content/uploads/2020/05/Angular-Application-Architecture-diagram-300x296.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2020/05/Angular-Application-Architecture-diagram-768x757.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2020/05/Angular-Application-Architecture-diagram-527x520.jpg 527w" sizes="(max-width: 551px) 100vw, 551px" /></figure>



<p></p>



<p></p>



<p>Let’s learn about Angular application architecture.</p>



<p>Fundamental <strong>building blocks </strong>in Angular applications:</p>



<ul class="wp-block-list"><li>Modules</li><li>Components</li><li>Services</li><li>Directives</li><li>Templates</li><li>Metadata</li><li>DI</li><li>Data Binding</li></ul>



<p></p>



<p>If you look at the app folder under src, you’ll notice it has a few files.</p>



<ul class="wp-block-list"><li><strong>App Component</strong><ul><li>app.component.ts</li><li>app.component.html</li><li>app.component.css</li><li>app.component.spec.ts</li></ul></li><li><strong>App Routing Module</strong><ul><li>app-routing.module.ts</li></ul></li><li><strong>App Module</strong><ul><li>app.module.ts</li></ul></li></ul>



<p></p>



<h2 class="wp-block-heading">Angular Modules &#8211; Startup/Entry Point </h2>



<p></p>



<p>When you launch the application in the browser the root module bootstrapped everything that is required for the application. You can call it an Entry point or Start-up of the application. </p>



<p>A NgModule declares a compilation context for a set of components that is dedicated to an application domain, a workflow, or a closely related set of capabilities.</p>



<p><strong><em>NgModules </em></strong>metadata declares a compilation context for a set of components and tells Angular how to compile and run module code. It encapsulates together entities like the module&#8217;s components, directives, templates, and pipes including the import of other modules.</p>



<p></p>



<p></p>



<h2 class="wp-block-heading">One Root Module &#8211; One Domain</h2>



<p></p>



<p>Ideally, your root module can represent one domain block addressing specific domain functionality as per UI interface using its backers like components, directives, pipes, etc. together.</p>



<p></p>



<p>One <strong><em>ngModule </em></strong>could serve your whole application.</p>



<p></p>



<p>This Angular module looks as below,</p>



<p></p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2020/05/Angular-Application-Architecture-Block-Diagram.jpg" alt="Angular Architecture and Design Guidelines" class="wp-image-10658" width="543" height="425" srcset="https://thecodebuzz.com/wp-content/uploads/2020/05/Angular-Application-Architecture-Block-Diagram.jpg 706w, https://thecodebuzz.com/wp-content/uploads/2020/05/Angular-Application-Architecture-Block-Diagram-300x235.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2020/05/Angular-Application-Architecture-Block-Diagram-664x520.jpg 664w" sizes="(max-width: 543px) 100vw, 543px" /></figure>



<p></p>



<p></p>



<h2 class="wp-block-heading">What is Component?</h2>



<p></p>



<p><strong><em>Components </em></strong>are the most basic UI building block. An Angular app consists of a tree of Angular components that bind together to perform certain UI functionality defining the view of your Angular application.</p>



<p>It provides flexibility to associate multiple screen elements according to your view requirements, program logic, and associated data.</p>



<p>As shown above each <em><strong>Component </strong></em>you add to the application should be registered with <em><strong>NgModule </strong></em>to be able to available for <em><strong>UI </strong></em>rendering.</p>



<p></p>



<p></p>



<h2 class="wp-block-heading">Decorator design pattern in Angular</h2>



<p></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>A Decorator is a design pattern to add additional behavior to Class or Object without affecting its existing functionality.  </p></blockquote>



<p>Angular leverages the Decorator pattern very nicely. Using Decorator how all its <em style="font-weight: bold;">Component</em>&#8216;s <em><strong>Metadata </strong></em>like HTML <strong><em>Template</em></strong>s, Stylesheets are glued together to create rich UI features easily.</p>



<p></p>



<p></p>



<p>This pattern is there for a decade and has been leveraged by all technologies like JAVA, C#, Python,<em><strong> </strong></em>and others.</p>



<p></p>



<p>Each building block in Angular has a decorator including NgModule.</p>



<p>Below diagram describes the <em><strong>Components Decorator</strong></em>,</p>



<p></p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="147" src="https://www.thecodebuzz.com/wp-content/uploads/2020/05/Understanding-Angular-Component-decorator-1024x147.jpg" alt="Angular Architecture and Design Guidelines" class="wp-image-10664" srcset="https://thecodebuzz.com/wp-content/uploads/2020/05/Understanding-Angular-Component-decorator-1024x147.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2020/05/Understanding-Angular-Component-decorator-300x43.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2020/05/Understanding-Angular-Component-decorator-768x110.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2020/05/Understanding-Angular-Component-decorator-1536x220.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2020/05/Understanding-Angular-Component-decorator-2048x294.jpg 2048w, https://thecodebuzz.com/wp-content/uploads/2020/05/Understanding-Angular-Component-decorator-785x113.jpg 785w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p></p>



<p><strong><em>Decorator </em></strong>declared with name <em>@Component </em>above provides the <em><strong>metadata </strong></em>that determines how the component should be processed and used in the runtime. </p>



<p></p>



<p><strong><em>selector </em></strong>&#8211; Directive selector helps to create an <strong>instance </strong>of the <em><strong>Component</strong></em>. This instance creation gets initiated from the HTML of the consuming side.</p>



<p></p>



<p><strong><em>templateurl</em></strong>&#8211; Defines the host view of the <em><strong>Components</strong></em>.</p>



<p></p>



<h2 class="wp-block-heading">Angular Component Interaction</h2>



<p></p>



<p>Angular Component Interaction heavily<strong><em> relies on decorators</em></strong> like <em><strong>@Input</strong> </em>and <strong><em>@OutPu</em></strong>t decorator for Child to Parent and Parent to child component interaction.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="681" height="601" src="https://www.thecodebuzz.com/wp-content/uploads/2020/06/Component-Interaction.jpg" alt="Angular Architecture and Design Guidelines" class="wp-image-11148" srcset="https://thecodebuzz.com/wp-content/uploads/2020/06/Component-Interaction.jpg 681w, https://thecodebuzz.com/wp-content/uploads/2020/06/Component-Interaction-300x265.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2020/06/Component-Interaction-589x520.jpg 589w" sizes="auto, (max-width: 681px) 100vw, 681px" /></figure>



<h2 class="wp-block-heading"> </h2>



<h2 class="wp-block-heading">Inversion of Control- Dependency Injection</h2>



<p></p>



<p>A great feature of the angular framework is to support for <strong><em>IOC</em></strong> Inversion of Control- Dependency injection (one of the <a href="https://www.thecodebuzz.com/solid-principles-with-examples-guidelines/" target="_blank" rel="noreferrer noopener"><strong><em>SOLID </em></strong></a>principles)</p>



<p>DI is a simple concept where you inject and use the services that you need, making your application highly efficient and lightweight.</p>



<p></p>



<h2 class="wp-block-heading">DI using Constructor Injection</h2>



<p></p>



<p>You can use DI in any part of the Angular Applications including Component definition.</p>



<p>This <strong>DI&nbsp;</strong>helps to address below for angular application,</p>



<ul class="wp-block-list"><li>Separation of responsibility and concern</li><li>Easily Testable units</li><li>Easy maintenance</li><li>High performance</li></ul>



<p></p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2020/05/Angular-Application-Architecture-Constructor-Injection.jpg" alt="Angular Architecture and Design Guidelines" class="wp-image-10699" width="523" height="165" srcset="https://thecodebuzz.com/wp-content/uploads/2020/05/Angular-Application-Architecture-Constructor-Injection.jpg 738w, https://thecodebuzz.com/wp-content/uploads/2020/05/Angular-Application-Architecture-Constructor-Injection-300x95.jpg 300w" sizes="auto, (max-width: 523px) 100vw, 523px" /></figure>



<p></p>



<p>(Above I have hidden the decorator intentionally to make the image less confusing)</p>



<p></p>



<h2 class="wp-block-heading">Injector as IoC Container </h2>



<p></p>



<p>The <strong><em>Injector </em></strong>is like an IoC container that helps you create dependencies. It further optimizes the DI instances usage by reusing injected services. These concepts resemble me as similar to Object Pooling ( Similar to Thread pool or Connection pool ?).</p>



<p></p>



<h2 class="wp-block-heading">Services Lifetime management in Angular</h2>



<p></p>



<p><strong><em>Injector</em></strong> lets you control the lifetime management of any instance or function injected via DI.</p>



<p></p>



<p><strong>Shared Services- Singleton</strong></p>



<p></p>



<p>When any services are declared with the provider as &#8216;root&#8217; then such instances are shared instances. This singleton instance will be called everywhere as and when the instance is needed to be used.</p>



<p></p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2020/05/Injectable-Single-shared-instance-per-Angular-application.jpg" alt="Angular Architecture and Design Guidelines" class="wp-image-10703" width="494" height="238" srcset="https://thecodebuzz.com/wp-content/uploads/2020/05/Injectable-Single-shared-instance-per-Angular-application.jpg 967w, https://thecodebuzz.com/wp-content/uploads/2020/05/Injectable-Single-shared-instance-per-Angular-application-300x145.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2020/05/Injectable-Single-shared-instance-per-Angular-application-768x371.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2020/05/Injectable-Single-shared-instance-per-Angular-application-785x379.jpg 785w" sizes="auto, (max-width: 494px) 100vw, 494px" /></figure>



<p></p>



<p>The above technique of the same service across all components can also be achieved by registering the service in <strong><em>NgModule </em></strong>as below,</p>



<p></p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2020/05/Injectable-Single-shared-instance-per-Angular-application-using-NgModule-1024x830.jpg" alt="Angular Architecture and Design Guidelines" class="wp-image-10705" width="396" height="321" srcset="https://thecodebuzz.com/wp-content/uploads/2020/05/Injectable-Single-shared-instance-per-Angular-application-using-NgModule-1024x830.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2020/05/Injectable-Single-shared-instance-per-Angular-application-using-NgModule-300x243.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2020/05/Injectable-Single-shared-instance-per-Angular-application-using-NgModule-768x622.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2020/05/Injectable-Single-shared-instance-per-Angular-application-using-NgModule-642x520.jpg 642w, https://thecodebuzz.com/wp-content/uploads/2020/05/Injectable-Single-shared-instance-per-Angular-application-using-NgModule.jpg 1085w" sizes="auto, (max-width: 396px) 100vw, 396px" /></figure>



<p></p>



<h2 class="wp-block-heading">Transient/New Service instance</h2>



<p></p>



<p>Above both techniques discussed lets, you create single and shared instance of any services and reuse as required. You may find a need to create something on demand.</p>



<p>Angular lets you create Services on demand per Component Instance basis using services within Components using <em><strong>providers </strong></em>as shown below.</p>



<p>For example, every time <em><strong>LoginCompoent </strong></em>instance gets created, a new instance of the logger service will also be created.</p>



<p> </p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2020/05/Injectable-new-Service-instance-per-Angular-component-1024x463.jpg" alt="Angular Architecture and Design Guidelines" class="wp-image-10710" width="474" height="214" srcset="https://thecodebuzz.com/wp-content/uploads/2020/05/Injectable-new-Service-instance-per-Angular-component-1024x463.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2020/05/Injectable-new-Service-instance-per-Angular-component-300x136.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2020/05/Injectable-new-Service-instance-per-Angular-component-768x347.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2020/05/Injectable-new-Service-instance-per-Angular-component-785x355.jpg 785w, https://thecodebuzz.com/wp-content/uploads/2020/05/Injectable-new-Service-instance-per-Angular-component.jpg 1389w" sizes="auto, (max-width: 474px) 100vw, 474px" /></figure>



<p></p>



<h2 class="wp-block-heading">2-Way Data Binding concept -Observable property</h2>



<p></p>



<p>Angular supports <em>two-way data binding</em>, a mechanism of connecting your View to other components layers. Angular lets you connect both sides easily.</p>



<p>Any changes in the View -DOM, such as user choices get reflected in your program data and vice versa easily. A UI element can bind the DOM with other model properties and subscribe to changes without hassle.</p>



<p></p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2020/05/Angular-Observable-pattern-ngmodel-and-property-2-way-binding-1024x662.jpg" alt="Angular Architecture and Design Guidelines" class="wp-image-10706" width="461" height="297" srcset="https://thecodebuzz.com/wp-content/uploads/2020/05/Angular-Observable-pattern-ngmodel-and-property-2-way-binding-1024x662.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2020/05/Angular-Observable-pattern-ngmodel-and-property-2-way-binding-300x194.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2020/05/Angular-Observable-pattern-ngmodel-and-property-2-way-binding-768x496.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2020/05/Angular-Observable-pattern-ngmodel-and-property-2-way-binding-1536x992.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2020/05/Angular-Observable-pattern-ngmodel-and-property-2-way-binding-785x507.jpg 785w, https://thecodebuzz.com/wp-content/uploads/2020/05/Angular-Observable-pattern-ngmodel-and-property-2-way-binding.jpg 1746w" sizes="auto, (max-width: 461px) 100vw, 461px" /></figure>



<p></p>



<p>That&#8217;s All! </p>



<p></p>



<p>This was very much basic on Angular Architecture.</p>



<p></p>



<p style="font-size:18px">Do you have any <strong>comments or ideas or any better </strong>suggestions to share?</p>



<p class="has-small-font-size"></p>



<p style="font-size:18px">Please sound off your comments below.</p>



<p class="has-medium-font-size"></p>



<p class="has-medium-font-size"><strong>Happy Coding </strong>!!</p>



<p></p>



<p></p>



<p><strong><em>References </em></strong>:</p>



<p></p>



<ul class="wp-block-list"><li><a href="https://www.thecodebuzz.com/data-binding-in-angular-forms/" title="Data Binding in Angular Forms" target="_blank" rel="noreferrer noopener"><strong><em>Data Binding in Angular Forms</em></strong></a></li><li><a href="https://www.thecodebuzz.com/angular-framework-migration-guidelines/" target="_blank" rel="noreferrer noopener" title="Angular 9/10 Framework Migration Guidelines"><strong><em>Angular 9/10 Framework Migration Guidelines</em></strong></a></li></ul>



<p></p>



<h2 class="wp-block-heading">Summary </h2>



<p></p>



<p>Today in this article, we covered basics angular architecture patterns detailing below,</p>



<p></p>



<ul class="wp-block-list"><li><em>High-level Application Architecture</em></li><li><em>Angular Modules</em></li><li><em>What is a Component?</em></li><li><em>Decorator design pattern</em></li><li><em>Inversion of Control- Dependency injection</em></li><li><em>Databinding concept</em></li></ul>



<p></p>



<p>With all this support of design patterns and goodies, you can think of developing lightweight to big enterprise Web applications using Angular. </p>



<p></p>



<hr>



<p class=""></p>



<p class="has-background" style="background-color:#b6d9ac;font-size:18px"><br>Please <strong><em>bookmark </em></strong>this page and <em><strong>share </strong></em>it with your friends.                                                    Please <a href="https://www.thecodebuzz.com/subscription/" target="_blank" rel="noreferrer noopener"><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"><strong>Subscribe</strong> </mark></em></a>to the blog to receive notifications on freshly published (2025) best practices and guidelines for software design and development.</p>




<br>



<hr>



<p class=""></p>



<p></p>



<p><br></p><p>The post <a href="https://thecodebuzz.com/angular-architecture-and-design-guidelines/">Angular Architecture and Design Guidelines</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://thecodebuzz.com/angular-architecture-and-design-guidelines/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
