223 lines
9.2 KiB
HTML
223 lines
9.2 KiB
HTML
<!doctype html>
|
|
<html class="no-js" lang="">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
|
<title>hometask documentation</title>
|
|
<meta name="description" content="">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
<link rel="icon" type="image/x-icon" href="./images/favicon.ico">
|
|
<link rel="stylesheet" href="./styles/style.css">
|
|
<link rel="stylesheet" href="./styles/dark.css">
|
|
<link rel="stylesheet" href="./styles/readthedocs.css">
|
|
</head>
|
|
<body>
|
|
|
|
<div class="navbar navbar-default navbar-fixed-top visible-xs">
|
|
<a href="./" class="navbar-brand">hometask documentation</a>
|
|
<button type="button" class="btn btn-default btn-menu ion-ios-menu" id="btn-menu"></button>
|
|
</div>
|
|
|
|
<div class="xs-menu menu" id="mobile-menu">
|
|
<div id="book-search-input" role="search"><input type="text" placeholder="Type to search"></div> <compodoc-menu></compodoc-menu>
|
|
</div>
|
|
|
|
<div class="container-fluid main">
|
|
<div class="row main">
|
|
<div class="hidden-xs menu">
|
|
<compodoc-menu mode="normal"></compodoc-menu>
|
|
</div>
|
|
<!-- START CONTENT -->
|
|
<div class="content getting-started">
|
|
<div class="content-data">
|
|
|
|
<h1 id="hexagonal-architecture">Hexagonal architecture</h1>
|
|
<h1 id="table-of-contents">Table of Contents</h1>
|
|
<ul>
|
|
<li><p><a href="#overview">Overview</a></p>
|
|
</li>
|
|
<li><p><a href="#code-architecture">Code architecture</a></p>
|
|
</li>
|
|
<li><p><a href="#source-code">source code</a></p>
|
|
</li>
|
|
<li><p><a href="#service-build-information">Service build information</a></p>
|
|
</li>
|
|
<li><p><a href="#regular-user">Regular user</a></p>
|
|
</li>
|
|
<li><p><a href="#advanced-user">Advanced user</a></p>
|
|
</li>
|
|
<li><p><a href="#deployment">Deployment</a></p>
|
|
</li>
|
|
<li><p><a href="#helm">Helm</a></p>
|
|
</li>
|
|
<li><p><a href="#kubernetes-manifests">Kubernetes manifests</a></p>
|
|
</li>
|
|
<li><p><a href="#monitoring-and-alerting">Monitoring and alerting</a></p>
|
|
</li>
|
|
<li><p><a href="#health-check">Health check</a></p>
|
|
</li>
|
|
<li><p><a href="#openapi">OpenApi</a></p>
|
|
</li>
|
|
<li><p><a href="#documentation">Documentation</a></p>
|
|
</li>
|
|
<li><p><a href="#todo-list">ToDo list</a></p>
|
|
</li>
|
|
</ul>
|
|
<h2 id="overview">Overview</h2>
|
|
<p>The <strong>hexagonal architecture</strong>, or <strong>ports and adapters architecture</strong>, is an architectural pattern used in <a href="https://en.wikipedia.org/wiki/Software_design" title="Software design">software design</a>. It aims at creating <a href="https://en.wikipedia.org/wiki/Loose_coupling" title="Loose coupling">loosely coupled</a> application components that can be easily connected to their software environment by means of ports and <a href="https://en.wikipedia.org/wiki/Adapter_pattern" title="Adapter pattern">adapters</a>. This makes components exchangeable at any level and facilitates test automation.</p>
|
|
<hr>
|
|
<h2 id="code-architecture">Code architecture</h2>
|
|
<p><img src="/images/structure.svg" alt="Group 4 1svg" class="img-responsive"></p>
|
|
<hr>
|
|
<h2 id="source-code">source code</h2>
|
|
<div><pre class="line-numbers"><code class="language-bash">git clone https://github.com/MoeidHeidari/nestjs-boilerplate
|
|
cd monetary-transaction</code></pre></div><h2 id="service-build-information">Service build information</h2>
|
|
<p>There are different stages of building the application for this service. Based on the environment you want to deploy we have different ways to build the application. following information may help with building the service.</p>
|
|
<h3 id="regular-user">Regular user</h3>
|
|
<div><pre class="line-numbers"><code class="language-bash">npm install
|
|
|
|
npm run build
|
|
|
|
npm run test:ci
|
|
|
|
npm start:{dev || debug || prod}</code></pre></div><h3 id="advanced-user">Advanced user</h3>
|
|
<div><pre class="line-numbers"><code class="language-bash">cd scripts
|
|
|
|
bash run.sh -h
|
|
|
|
2022.05.30.14.43
|
|
|
|
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-buildDocker] [-runDocker] [-runApp] [-runDoc] [-packageHelm]
|
|
|
|
This script helps you to run the application in different forms. below you can get the full list of available options.
|
|
|
|
Available options:
|
|
|
|
-h, --help Print this help and exit
|
|
|
|
-buildDocker Build the docker image called "imageName:latest"
|
|
|
|
-runDocker Build the docker image and run on local machine
|
|
|
|
-runApp Run application with npm in usual way for development
|
|
|
|
-runDoc Generate the code documentation
|
|
|
|
-packageHelm makes a helm package from the helm chart.</code></pre></div><h2 id="deployment">Deployment</h2>
|
|
<h4 id="helm">Helm</h4>
|
|
<p>with the following instruction you can install the helm chart on an up and running kubernetes cluster.</p>
|
|
<div><pre class="line-numbers"><code class="language-bash">cd k8s
|
|
|
|
helm install {sample-app} {app-0.1.0.tgz} --set service.type=NodePort</code></pre></div><h4 id="kubernetes-manifests">Kubernetes manifests</h4>
|
|
<p>Alternativelly you can deploy the application on an up an running kubernetes cluster using provided config files.</p>
|
|
<div><pre class="line-numbers"><code class="language-bash">cd k8s/configFiles
|
|
kubectl apply -f app-namespace.yaml, app-configmap.yaml, app-deployment.yaml, app-service.yaml</code></pre></div><p>it should give you following output</p>
|
|
<div><pre class="line-numbers"><code class="language-bash">namespace/app created
|
|
configmap/app-config created
|
|
deployment.apps/app created
|
|
service/app created</code></pre></div><h2 id="monitoring-and-alerting">Monitoring and alerting</h2>
|
|
<h3 id="health-check">Health check</h3>
|
|
<p>by calling the following endpoint you can make sure that the application is running and listening to your desired port</p>
|
|
<p><code>http://localhost:{port_number}/health</code></p>
|
|
<p>most probably you will get a result back as follow</p>
|
|
<blockquote>
|
|
<p><strong>Example</strong></p>
|
|
</blockquote>
|
|
<blockquote>
|
|
<p>{"status":"ok","info":{"alive":{"status":"up"}},"error":{},"details":{"alive":{"status":"up"}}}</p>
|
|
</blockquote>
|
|
<p>mertics</p>
|
|
<p>to get the default metrics of the application you can use the following endpoint</p>
|
|
<p><code>http://localhost:{port_number}/metrics</code></p>
|
|
<h2 id="openapi">OpenApi</h2>
|
|
<p>by calling the following endpoint you can see the Swagger OpenApi documentation and explore all the available apis and schemas.</p>
|
|
<p><code>http://localhost:{port_number}/api</code></p>
|
|
<h2 id="documentation">Documentation</h2>
|
|
<p>By running following comman you can generate the full code documentation (Compodoc) and get access to it through port <code>7000</code></p>
|
|
<div><pre class="line-numbers"><code class="language-bash">npm run doc</code></pre></div><p><a href="http://localhost:7000">http://localhost:7000</a></p>
|
|
<h2 id="todo-list">ToDo list</h2>
|
|
<ul>
|
|
<li><input disabled="" type="checkbox"> add terraform infrastructure</li>
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div><div class="search-results">
|
|
<div class="has-results">
|
|
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
|
<ul class="search-results-list"></ul>
|
|
</div>
|
|
<div class="no-results">
|
|
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- END CONTENT -->
|
|
</div>
|
|
</div>
|
|
|
|
<label class="dark-mode-switch">
|
|
<input type="checkbox">
|
|
<span class="slider">
|
|
<svg class="slider-icon" viewBox="0 0 24 24" fill="none" height="20" stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" width="20" xmlns="http://www.w3.org/2000/svg">
|
|
<path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"></path>
|
|
</svg>
|
|
</span>
|
|
</label>
|
|
|
|
<script>
|
|
var COMPODOC_CURRENT_PAGE_DEPTH = 0;
|
|
var COMPODOC_CURRENT_PAGE_CONTEXT = 'getting-started';
|
|
var COMPODOC_CURRENT_PAGE_URL = 'index.html';
|
|
var MAX_SEARCH_RESULTS = 15;
|
|
</script>
|
|
|
|
<script src="./js/libs/custom-elements.min.js"></script>
|
|
<script src="./js/libs/lit-html.js"></script>
|
|
|
|
<script src="./js/menu-wc.js" defer></script>
|
|
<script nomodule src="./js/menu-wc_es5.js" defer></script>
|
|
|
|
<script src="./js/libs/bootstrap-native.js"></script>
|
|
|
|
<script src="./js/libs/es6-shim.min.js"></script>
|
|
<script src="./js/libs/EventDispatcher.js"></script>
|
|
<script src="./js/libs/promise.min.js"></script>
|
|
<script src="./js/libs/zepto.min.js"></script>
|
|
|
|
<script src="./js/compodoc.js"></script>
|
|
|
|
<script src="./js/tabs.js"></script>
|
|
<script src="./js/menu.js"></script>
|
|
<script src="./js/libs/clipboard.min.js"></script>
|
|
<script src="./js/libs/prism.js"></script>
|
|
<script src="./js/sourceCode.js"></script>
|
|
<script src="./js/search/search.js"></script>
|
|
<script src="./js/search/lunr.min.js"></script>
|
|
<script src="./js/search/search-lunr.js"></script>
|
|
<script src="./js/search/search_index.js"></script>
|
|
<script src="./js/lazy-load-graphs.js"></script>
|
|
|
|
|
|
</body>
|
|
</html>
|