{"id":7486,"date":"2026-08-17T18:28:13","date_gmt":"2026-08-17T10:28:13","guid":{"rendered":"https:\/\/guides.visual-paradigm.com\/gallery\/c4-plantuml-component-diagram-account-service-asp-net\/"},"modified":"2026-10-09T04:22:55","modified_gmt":"2026-10-09T04:22:55","slug":"c4-plantuml-component-diagram-account-service-asp-net","status":"publish","type":"gallery","link":"https:\/\/www.learn-vp.com\/vn\/gallery\/c4-plantuml-component-diagram-account-service-asp-net\/","title":{"rendered":"C4: PlantUML Component Diagram Account Service ASP.NET"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/www.ai-diagrams.com\/wp-content\/uploads\/2026\/08\/img_6a82e1166edd6.png\" \/><\/p>\n<h2>Introduction to Diagram-as-Code<\/h2>\n<p>In modern software development, documentation often falls behind implementation. However, tools like VPasCode by Visual Paradigm bridge this gap by allowing developers to write diagrams directly in code. This approach, known as &#8220;Diagram-as-Code,&#8221; ensures that your architectural visualizations stay perfectly synchronized with your actual system logic.<\/p>\n<p>Today, we will walk through a practical example of modeling a robust backend service for an application built on <strong>.NET 8<\/strong>. By looking at the specific components and their interactions, we can understand how to structure a clean, maintainable architecture.<\/p>\n<h2>The Entry Point: API Gateway<\/h2>\n<p>Every request in a distributed system typically begins at a central point. In our diagram, we see the <strong>API Gateway<\/strong>, implemented here using Kong. This component acts as the traffic cop for our entire service.<\/p>\n<ul>\n<li><strong>Role:<\/strong> It is responsible for routing incoming traffic.<\/li>\n<li><strong>Relationship:<\/strong> Notice the arrow labeled &#8220;Passes request.&#8221; The gateway does not process the business logic itself; it simply directs the flow toward the next layer, ensuring only valid requests enter the internal network.<\/li>\n<\/ul>\n<h2>The Security Layer: Auth Middleware<\/h2>\n<p>Before any data reaches the core application, security must be established. This is handled by the <strong>Auth Middleware<\/strong>.<\/p>\n<p>In a .NET environment, middleware runs in a pipeline. Here, its specific job is twofold:<\/p>\n<ol>\n<li><strong>Validates JWT (JSON Web Tokens):<\/strong> It checks if the user sending the request is who they claim to be.<\/li>\n<li><strong>Extracts User Context:<\/strong> Once validated, it pulls out essential user information (like IDs or roles) to attach to the request object.<\/li>\n<\/ol>\n<p>If the token is invalid, the request stops here. If successful, the middleware forwards the authenticated request down the line.<\/p>\n<h2>The Controller: REST Endpoints<\/h2>\n<p>Once the request is secure, it lands in the <strong>AccountController<\/strong>. This component represents the ASP.NET API surface of our application.<\/p>\n<p>This is where the public-facing logic lives. It defines the REST endpoints\u2014for instance, routes that handle operations related to &#8220;\/accounts&#8221;. The controller&#8217;s primary responsibility is to interpret these HTTP requests and translate them into calls to the underlying business logic. It acts as a thin wrapper, keeping the complex rules away from the web interface.<\/p>\n<h2>The Core Logic: AccountDomainService<\/h2>\n<p>The heart of any well-architected application lies in its domain layer. In our diagram, this is represented by the <strong>AccountDomainService<\/strong>.<\/p>\n<p>This component encapsulates the critical business rules. Looking at the description within the box, we see tasks such as &#8220;Balance calc&#8221; and &#8220;transfer rules.&#8221; This separation is vital because:<\/p>\n<ul>\n<li><strong>Independence:<\/strong> The domain logic shouldn&#8217;t care if it&#8217;s being called via a web API, a background job, or a command-line tool.<\/li>\n<li><strong>Maintainability:<\/strong> By isolating transfer rules and balance calculations here, you ensure that changing a rule doesn&#8217;t require rewriting the API endpoints.<\/li>\n<\/ul>\n<h2>Beyond the View: Data and Events<\/h2>\n<p>While the main vertical flow handles the request\/response cycle, the code snippet on the left reveals additional layers of complexity managed by the architecture:<\/p>\n<ul>\n<li><strong>Data Access:<\/strong> The <code>AccountRepository<\/code> interacts with Entity Framework Core (EF Core) to execute SQL queries, handling persistence without cluttering the domain service.<\/li>\n<li><strong>Event Publishing:<\/strong> Using MassTransit, the system publishes events like <code>TransactionCompleted<\/code> to a RabbitMQ queue. This decouples services, allowing other parts of the system to react to account changes asynchronously.<\/li>\n<\/ul>\n<h2>Summary<\/h2>\n<p>By utilizing VPasCode to visualize this .NET 8 architecture, we gain immediate clarity on how responsibilities are separated. We moved logically from the <strong>API Gateway<\/strong> (routing) to the <strong>Auth Middleware<\/strong> (security), then to the <strong>Controller<\/strong> (interface), and finally to the <strong>Domain Service<\/strong> (business logic).<\/p>\n<p>This layered approach ensures scalability and testability. Whether you are drawing this manually or generating it from code, understanding these distinct roles is fundamental to building reliable enterprise-grade applications.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>C4: The screenshot displays a PlantUML component diagram titled &#8220;Account Service (.NET 8)&#8221; within a VPasCode editor, illustrating a request flow from an API Gateway through an Auth Middleware and AccountController down to the AccountDomainService. The left panel shows the underlying code generating this architecture, while the right panel renders the corresponding graphical representation with components connected by directional arrows indicating data passage and logic invocation.<\/p>\n","protected":false},"author":1,"featured_media":7772,"template":"","meta":{"_yoast_wpseo_title":"Architecting Microservices with PlantUML and .NET 8","_yoast_wpseo_metadesc":"Explore how to model a modern .NET 8 microservice architecture using VPasCode. Learn the flow from API Gateway to Domain Services through diagram-as-code.","inline_featured_image":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"source_url":"https:\/\/www.ai-diagrams.com\/stop-dragging-boxes-generating-c4-diagrams-via-vpascode-and-ai-chatbots\/","source_h1_title":"Stop Dragging Boxes: Generating C4 Diagrams via VPasCode and AI Chatbots","fifu_image_url":"","fifu_image_alt":"","_fifu_image_alt":"","fifu_alt":"","_fifu_alt":"","fifu_image_title":"","_fifu_image_title":"","fifu_input_alt":"","vp_image_hash":""},"asset-category":[17],"class_list":["post-7486","gallery","type-gallery","status-publish","has-post-thumbnail","hentry","asset-category-c4"],"source_url":"https:\/\/www.ai-diagrams.com\/stop-dragging-boxes-generating-c4-diagrams-via-vpascode-and-ai-chatbots\/","source_h1_title":"Stop Dragging Boxes: Generating C4 Diagrams via VPasCode and AI Chatbots","fifu_image_url":"","fifu_image_alt":"","vp_image_hash":"","yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Architecting Microservices with PlantUML and .NET 8<\/title>\n<meta name=\"description\" content=\"Explore how to model a modern .NET 8 microservice architecture using VPasCode. Learn the flow from API Gateway to Domain Services through diagram-as-code.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.learn-vp.com\/vn\/gallery\/c4-plantuml-component-diagram-account-service-asp-net\/\" \/>\n<meta property=\"og:locale\" content=\"vi_VN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Architecting Microservices with PlantUML and .NET 8\" \/>\n<meta property=\"og:description\" content=\"Explore how to model a modern .NET 8 microservice architecture using VPasCode. Learn the flow from API Gateway to Domain Services through diagram-as-code.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.learn-vp.com\/vn\/gallery\/c4-plantuml-component-diagram-account-service-asp-net\/\" \/>\n<meta property=\"og:site_name\" content=\"Learn VP\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-09T04:22:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.ai-diagrams.com\/wp-content\/uploads\/2026\/08\/img_6a82e1166edd6.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"1024\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 ph\u00fat\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.learn-vp.com\\\/vn\\\/gallery\\\/c4-plantuml-component-diagram-account-service-asp-net\\\/\",\"url\":\"https:\\\/\\\/www.learn-vp.com\\\/vn\\\/gallery\\\/c4-plantuml-component-diagram-account-service-asp-net\\\/\",\"name\":\"Architecting Microservices with PlantUML and .NET 8\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.learn-vp.com\\\/vn\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.learn-vp.com\\\/vn\\\/gallery\\\/c4-plantuml-component-diagram-account-service-asp-net\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.learn-vp.com\\\/vn\\\/gallery\\\/c4-plantuml-component-diagram-account-service-asp-net\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.ai-diagrams.com\\\/wp-content\\\/uploads\\\/2026\\\/08\\\/img_6a82e1166edd6.png\",\"datePublished\":\"2026-08-17T10:28:13+00:00\",\"dateModified\":\"2026-10-09T04:22:55+00:00\",\"description\":\"Explore how to model a modern .NET 8 microservice architecture using VPasCode. Learn the flow from API Gateway to Domain Services through diagram-as-code.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.learn-vp.com\\\/vn\\\/gallery\\\/c4-plantuml-component-diagram-account-service-asp-net\\\/#breadcrumb\"},\"inLanguage\":\"vi\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.learn-vp.com\\\/vn\\\/gallery\\\/c4-plantuml-component-diagram-account-service-asp-net\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"vi\",\"@id\":\"https:\\\/\\\/www.learn-vp.com\\\/vn\\\/gallery\\\/c4-plantuml-component-diagram-account-service-asp-net\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.ai-diagrams.com\\\/wp-content\\\/uploads\\\/2026\\\/08\\\/img_6a82e1166edd6.png\",\"contentUrl\":\"https:\\\/\\\/www.ai-diagrams.com\\\/wp-content\\\/uploads\\\/2026\\\/08\\\/img_6a82e1166edd6.png\",\"caption\":\"C4: PlantUML Component Diagram Account Service ASP.NET\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.learn-vp.com\\\/vn\\\/gallery\\\/c4-plantuml-component-diagram-account-service-asp-net\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.learn-vp.com\\\/vn\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C4: PlantUML Component Diagram Account Service ASP.NET\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.learn-vp.com\\\/vn\\\/#website\",\"url\":\"https:\\\/\\\/www.learn-vp.com\\\/vn\\\/\",\"name\":\"Learn VP\",\"description\":\"Learn VP\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.learn-vp.com\\\/vn\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.learn-vp.com\\\/vn\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"vi\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.learn-vp.com\\\/vn\\\/#organization\",\"name\":\"Learn VP\",\"url\":\"https:\\\/\\\/www.learn-vp.com\\\/vn\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"vi\",\"@id\":\"https:\\\/\\\/www.learn-vp.com\\\/vn\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.learn-vp.com\\\/vn\\\/wp-content\\\/uploads\\\/sites\\\/13\\\/2026\\\/08\\\/cropped-Gemini_Generated_Image_n6bgztn6bgztn6bg-clean-e1787131920742.png\",\"contentUrl\":\"https:\\\/\\\/www.learn-vp.com\\\/vn\\\/wp-content\\\/uploads\\\/sites\\\/13\\\/2026\\\/08\\\/cropped-Gemini_Generated_Image_n6bgztn6bgztn6bg-clean-e1787131920742.png\",\"width\":463,\"height\":404,\"caption\":\"Learn VP\"},\"image\":{\"@id\":\"https:\\\/\\\/www.learn-vp.com\\\/vn\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Architecting Microservices with PlantUML and .NET 8","description":"Explore how to model a modern .NET 8 microservice architecture using VPasCode. Learn the flow from API Gateway to Domain Services through diagram-as-code.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.learn-vp.com\/vn\/gallery\/c4-plantuml-component-diagram-account-service-asp-net\/","og_locale":"vi_VN","og_type":"article","og_title":"Architecting Microservices with PlantUML and .NET 8","og_description":"Explore how to model a modern .NET 8 microservice architecture using VPasCode. Learn the flow from API Gateway to Domain Services through diagram-as-code.","og_url":"https:\/\/www.learn-vp.com\/vn\/gallery\/c4-plantuml-component-diagram-account-service-asp-net\/","og_site_name":"Learn VP","article_modified_time":"2026-10-09T04:22:55+00:00","og_image":[{"url":"https:\/\/www.ai-diagrams.com\/wp-content\/uploads\/2026\/08\/img_6a82e1166edd6.png","width":1024,"height":1024,"type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_misc":{"\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc":"1 ph\u00fat"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.learn-vp.com\/vn\/gallery\/c4-plantuml-component-diagram-account-service-asp-net\/","url":"https:\/\/www.learn-vp.com\/vn\/gallery\/c4-plantuml-component-diagram-account-service-asp-net\/","name":"Architecting Microservices with PlantUML and .NET 8","isPartOf":{"@id":"https:\/\/www.learn-vp.com\/vn\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.learn-vp.com\/vn\/gallery\/c4-plantuml-component-diagram-account-service-asp-net\/#primaryimage"},"image":{"@id":"https:\/\/www.learn-vp.com\/vn\/gallery\/c4-plantuml-component-diagram-account-service-asp-net\/#primaryimage"},"thumbnailUrl":"https:\/\/www.ai-diagrams.com\/wp-content\/uploads\/2026\/08\/img_6a82e1166edd6.png","datePublished":"2026-08-17T10:28:13+00:00","dateModified":"2026-10-09T04:22:55+00:00","description":"Explore how to model a modern .NET 8 microservice architecture using VPasCode. Learn the flow from API Gateway to Domain Services through diagram-as-code.","breadcrumb":{"@id":"https:\/\/www.learn-vp.com\/vn\/gallery\/c4-plantuml-component-diagram-account-service-asp-net\/#breadcrumb"},"inLanguage":"vi","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.learn-vp.com\/vn\/gallery\/c4-plantuml-component-diagram-account-service-asp-net\/"]}]},{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/www.learn-vp.com\/vn\/gallery\/c4-plantuml-component-diagram-account-service-asp-net\/#primaryimage","url":"https:\/\/www.ai-diagrams.com\/wp-content\/uploads\/2026\/08\/img_6a82e1166edd6.png","contentUrl":"https:\/\/www.ai-diagrams.com\/wp-content\/uploads\/2026\/08\/img_6a82e1166edd6.png","caption":"C4: PlantUML Component Diagram Account Service ASP.NET"},{"@type":"BreadcrumbList","@id":"https:\/\/www.learn-vp.com\/vn\/gallery\/c4-plantuml-component-diagram-account-service-asp-net\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.learn-vp.com\/vn\/"},{"@type":"ListItem","position":2,"name":"C4: PlantUML Component Diagram Account Service ASP.NET"}]},{"@type":"WebSite","@id":"https:\/\/www.learn-vp.com\/vn\/#website","url":"https:\/\/www.learn-vp.com\/vn\/","name":"Learn VP","description":"Learn VP","publisher":{"@id":"https:\/\/www.learn-vp.com\/vn\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.learn-vp.com\/vn\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"vi"},{"@type":"Organization","@id":"https:\/\/www.learn-vp.com\/vn\/#organization","name":"Learn VP","url":"https:\/\/www.learn-vp.com\/vn\/","logo":{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/www.learn-vp.com\/vn\/#\/schema\/logo\/image\/","url":"https:\/\/www.learn-vp.com\/vn\/wp-content\/uploads\/sites\/13\/2026\/08\/cropped-Gemini_Generated_Image_n6bgztn6bgztn6bg-clean-e1787131920742.png","contentUrl":"https:\/\/www.learn-vp.com\/vn\/wp-content\/uploads\/sites\/13\/2026\/08\/cropped-Gemini_Generated_Image_n6bgztn6bgztn6bg-clean-e1787131920742.png","width":463,"height":404,"caption":"Learn VP"},"image":{"@id":"https:\/\/www.learn-vp.com\/vn\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.learn-vp.com\/vn\/wp-json\/wp\/v2\/gallery\/7486","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.learn-vp.com\/vn\/wp-json\/wp\/v2\/gallery"}],"about":[{"href":"https:\/\/www.learn-vp.com\/vn\/wp-json\/wp\/v2\/types\/gallery"}],"author":[{"embeddable":true,"href":"https:\/\/www.learn-vp.com\/vn\/wp-json\/wp\/v2\/users\/1"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.learn-vp.com\/vn\/wp-json\/wp\/v2\/media\/7772"}],"wp:attachment":[{"href":"https:\/\/www.learn-vp.com\/vn\/wp-json\/wp\/v2\/media?parent=7486"}],"wp:term":[{"taxonomy":"asset-category","embeddable":true,"href":"https:\/\/www.learn-vp.com\/vn\/wp-json\/wp\/v2\/asset-category?post=7486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}