initial commit
This commit is contained in:
parent
488c55e06d
commit
cecabe625c
8
.idea/.gitignore
vendored
Normal file
8
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
12
.idea/astro-cqrs-framework-doc.iml
Normal file
12
.idea/astro-cqrs-framework-doc.iml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/astro-cqrs-framework-doc.iml" filepath="$PROJECT_DIR$/.idea/astro-cqrs-framework-doc.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -4,24 +4,60 @@ import starlight from '@astrojs/starlight';
|
||||
|
||||
// https://astro.build/config
|
||||
export default defineConfig({
|
||||
/*redirects: {
|
||||
'/': '/en/'
|
||||
},*/
|
||||
trailingSlash: 'always',
|
||||
integrations: [
|
||||
starlight({
|
||||
title: 'My Docs',
|
||||
social: {
|
||||
github: 'https://github.com/withastro/starlight',
|
||||
title: 'Open Harbor',
|
||||
logo: {
|
||||
replacesTitle: true,
|
||||
light: './src/assets/logo.png',
|
||||
dark: './src/assets/dark-logo.png',
|
||||
},
|
||||
defaultLocale: 'en',
|
||||
locales: {
|
||||
en: {
|
||||
label: 'English'
|
||||
},
|
||||
fr: {
|
||||
label: 'Français'
|
||||
}
|
||||
},
|
||||
social: { // todo: implement gitea social
|
||||
github: 'https://git.openharbor.io/Open-Harbor/dotnet-cqrs',
|
||||
},
|
||||
customCss: [
|
||||
'./src/styles/global.css'
|
||||
],
|
||||
sidebar: [
|
||||
{
|
||||
label: 'Guides',
|
||||
items: [
|
||||
// Each item here is one entry in the navigation menu.
|
||||
{ label: 'Example Guide', slug: 'guides/example' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Reference',
|
||||
autogenerate: { directory: 'reference' },
|
||||
},
|
||||
label: '.NET',
|
||||
items: [
|
||||
{
|
||||
label: 'Guides',
|
||||
items: [
|
||||
{ label: 'Concept', slug: 'dotnet/guides/concept' },
|
||||
{ label: 'Getting Started', slug: 'dotnet/guides/getting-started' },
|
||||
{ label: 'Adding your first command', slug: 'dotnet/guides/first-command' },
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'References',
|
||||
items: [
|
||||
'dotnet/references/example'
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Resources',
|
||||
items: [
|
||||
'dotnet/resources/nugets',
|
||||
{ label: 'Git', link: 'https://git.openharbor.io/Open-Harbor/dotnet-cqrs' }
|
||||
]
|
||||
}
|
||||
],
|
||||
}
|
||||
],
|
||||
}),
|
||||
],
|
||||
|
@ -13,5 +13,6 @@
|
||||
"@astrojs/starlight": "^0.30.3",
|
||||
"astro": "^5.0.2",
|
||||
"sharp": "^0.32.5"
|
||||
}
|
||||
}
|
||||
},
|
||||
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
|
||||
}
|
||||
|
@ -1 +1,91 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128"><path fill-rule="evenodd" d="M81 36 64 0 47 36l-1 2-9-10a6 6 0 0 0-9 9l10 10h-2L0 64l36 17h2L28 91a6 6 0 1 0 9 9l9-10 1 2 17 36 17-36v-2l9 10a6 6 0 1 0 9-9l-9-9 2-1 36-17-36-17-2-1 9-9a6 6 0 1 0-9-9l-9 10v-2Zm-17 2-2 5c-4 8-11 15-19 19l-5 2 5 2c8 4 15 11 19 19l2 5 2-5c4-8 11-15 19-19l5-2-5-2c-8-4-15-11-19-19l-2-5Z" clip-rule="evenodd"/><path d="M118 19a6 6 0 0 0-9-9l-3 3a6 6 0 1 0 9 9l3-3Zm-96 4c-2 2-6 2-9 0l-3-3a6 6 0 1 1 9-9l3 3c3 2 3 6 0 9Zm0 82c-2-2-6-2-9 0l-3 3a6 6 0 1 0 9 9l3-3c3-2 3-6 0-9Zm96 4a6 6 0 0 1-9 9l-3-3a6 6 0 1 1 9-9l3 3Z"/><style>path{fill:#000}@media (prefers-color-scheme:dark){path{fill:#fff}}</style></svg>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 28.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 219.55 219.55" style="enable-background:new 0 0 219.55 219.55;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:none;stroke:#1A3A60;stroke-width:6;stroke-miterlimit:10;}
|
||||
.st1{fill:#D36F28;}
|
||||
.st2{fill:#1A3A60;}
|
||||
.st3{fill:#CE8EBE;}
|
||||
.st4{fill:#66BD4B;}
|
||||
.st5{fill:#0C0D0D;}
|
||||
.st6{fill:#EDEEEF;}
|
||||
.st7{fill:none;stroke:#1A3A60;stroke-miterlimit:10;}
|
||||
.st8{clip-path:url(#SVGID_00000077296076702709476720000014956021410777520533_);}
|
||||
.st9{fill:#24B2B1;}
|
||||
.st10{fill:#25B34B;}
|
||||
.st11{fill:#89B23F;}
|
||||
.st12{fill:none;stroke:#000000;stroke-miterlimit:10;}
|
||||
</style>
|
||||
<g>
|
||||
<g>
|
||||
<path class="st2" d="M100.48,149.8c0.47-0.29,0.95-0.59,1.47-0.88c0.16-0.09,0.37,0.03,0.37,0.22v5.32c0,0.09-0.04,0.17-0.12,0.21
|
||||
c-1.99,1.19-4.41,2.33-8.53,2.33c-4.79,0-7.29-1.54-9.48-2.91c-1.94-1.2-3.46-2.15-6.82-2.15c-3.35,0-4.88,0.95-6.82,2.15
|
||||
c-2.2,1.36-4.68,2.91-9.48,2.91c-0.78,0-1.49-0.04-2.16-0.12c-0.06-0.01-0.12-0.04-0.16-0.08c-2.33-2.53-4.46-5.25-6.38-8.11
|
||||
c0.67,0.36,1.28,0.73,1.87,1.1c1.94,1.2,3.46,2.15,6.82,2.15c3.35,0,4.88-0.94,6.82-2.15c2.2-1.36,4.68-2.91,9.48-2.91
|
||||
c4.79,0,7.29,1.54,9.49,2.91c1.93,1.2,3.46,2.15,6.82,2.15C97.01,151.95,98.54,151,100.48,149.8z"/>
|
||||
<path class="st2" d="M165.68,149.8c0.51-0.32,1.04-0.65,1.62-0.96c-1.9,2.81-4.01,5.48-6.3,7.98c-0.04,0.05-0.1,0.08-0.16,0.08
|
||||
c-0.61,0.07-1.26,0.1-1.97,0.1c-4.79,0-7.29-1.54-9.49-2.91c-1.93-1.2-3.46-2.15-6.82-2.15c-3.35,0-4.88,0.95-6.82,2.15
|
||||
c-2.2,1.36-4.68,2.91-9.49,2.91c-4.26,0-6.7-1.22-8.73-2.45c-0.07-0.05-0.12-0.13-0.12-0.21v-5.31c0-0.19,0.21-0.31,0.37-0.22
|
||||
c0.59,0.32,1.13,0.66,1.66,0.99c1.94,1.2,3.46,2.15,6.82,2.15c3.36,0,4.89-0.94,6.82-2.15c2.19-1.36,4.68-2.91,9.48-2.91
|
||||
c4.79,0,7.29,1.54,9.49,2.91c1.93,1.2,3.46,2.15,6.82,2.15C162.21,151.95,163.74,151,165.68,149.8z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st2" d="M100.41,161.05c0.47-0.29,0.95-0.59,1.46-0.88c0.17-0.09,0.38,0.03,0.38,0.22v5.31
|
||||
c0,0.09-0.05,0.17-0.12,0.22c-1.99,1.19-4.41,2.33-8.53,2.33c-4.79,0-7.29-1.54-9.48-2.91c-1.94-1.2-3.46-2.15-6.82-2.15
|
||||
c-3.35,0-4.88,0.95-6.82,2.15c-0.38,0.24-0.78,0.48-1.18,0.72c-0.09,0.05-0.2,0.05-0.28-0.01c-1.37-0.99-2.69-2.04-3.98-3.13
|
||||
c-0.15-0.12-0.1-0.36,0.08-0.42c0.97-0.38,1.79-0.88,2.7-1.45c2.2-1.36,4.68-2.91,9.48-2.91c4.79,0,7.29,1.54,9.49,2.91
|
||||
c1.93,1.2,3.46,2.15,6.82,2.15C96.95,163.2,98.47,162.26,100.41,161.05z"/>
|
||||
<path class="st2" d="M151.98,161.05c0.87,0.54,1.66,1.04,2.58,1.41c0.18,0.07,0.23,0.31,0.08,0.43c-1.28,1.09-2.59,2.13-3.94,3.11
|
||||
c-0.08,0.06-0.2,0.07-0.28,0.01c-0.38-0.22-0.74-0.44-1.1-0.67c-1.93-1.2-3.46-2.15-6.82-2.15c-3.35,0-4.88,0.95-6.82,2.15
|
||||
c-2.2,1.36-4.68,2.91-9.49,2.91c-4.25,0-6.69-1.21-8.72-2.44c-0.08-0.05-0.12-0.13-0.12-0.22v-5.3c0-0.19,0.21-0.32,0.38-0.22
|
||||
c0.58,0.32,1.13,0.66,1.65,0.98c1.94,1.2,3.46,2.15,6.82,2.15c3.36,0,4.89-0.94,6.82-2.15c2.19-1.36,4.68-2.91,9.48-2.91
|
||||
C147.28,158.15,149.78,159.69,151.98,161.05z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st2" d="M100.41,172.31c0.47-0.29,0.94-0.59,1.46-0.87c0.17-0.09,0.38,0.03,0.38,0.22v5.3c0,0.09-0.05,0.17-0.12,0.22
|
||||
c-0.84,0.51-1.76,1-2.85,1.4c0,0,0,0-0.01,0c-8.97-1.37-17.38-4.48-24.88-8.96c0.87-0.14,1.83-0.22,2.91-0.22
|
||||
c4.79,0,7.29,1.54,9.49,2.91c1.93,1.2,3.46,2.15,6.82,2.15C96.95,174.46,98.47,173.51,100.41,172.31z"/>
|
||||
<path class="st2" d="M142.5,169.4c1.03,0,1.95,0.07,2.78,0.2c-7.47,4.47-15.86,7.57-24.79,8.96c-0.01,0-0.01,0-0.01,0
|
||||
c-1.15-0.44-2.12-0.96-3.01-1.5c-0.07-0.04-0.12-0.12-0.12-0.21v-5.32c0-0.19,0.21-0.31,0.37-0.22c0.59,0.33,1.14,0.66,1.66,0.99
|
||||
c1.94,1.2,3.46,2.15,6.82,2.15c3.36,0,4.89-0.95,6.82-2.15C135.21,170.94,137.7,169.4,142.5,169.4z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st1" d="M105.23,29.9c-41.58,2.31-74.7,36.78-75.45,78.42c-0.09,5,0.28,9.9,1.08,14.66c0.03,0.17,0.15,0.32,0.31,0.39
|
||||
l5.52,2.22c0.37,0.15,0.75-0.17,0.67-0.57c-1.05-4.92-1.59-10.01-1.59-15.24c0-41.39,34.17-74.96,75.78-73.98
|
||||
c38.74,0.91,70.54,32.11,72.15,70.83c0.26,6.17-0.24,12.19-1.43,17.96c-0.08,0.39,0.3,0.71,0.67,0.56l5.5-2.22
|
||||
c0.16-0.07,0.28-0.21,0.31-0.39c0.68-4.15,1.02-8.41,1.02-12.77C189.77,64.16,151.4,27.34,105.23,29.9z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st2" d="M180.11,132.77l-6.94,2.8l-0.45,0.18l-0.84,0.34l-2.18,0.88c-0.26,0.1-0.38,0.39-0.28,0.65l1.31,3.25
|
||||
l0.56,1.39c0.1,0.26,0.39,0.38,0.65,0.27l3.98-1.61c0.42-0.17,0.84,0.27,0.64,0.67c-0.45,0.93-0.91,1.85-1.4,2.76
|
||||
c-1.04,1.96-2.16,3.87-3.37,5.72c-1.28,1.96-2.66,3.86-4.12,5.69c-3.31,4.17-7.06,7.97-11.2,11.34c-1.51,1.24-3.08,2.42-4.69,3.53
|
||||
c-1.76,1.22-3.57,2.36-5.43,3.41c-8.31,4.76-17.64,7.94-27.56,9.16c-1.81,0.23-3.64,0.38-5.48,0.46c-0.28,0.01-0.52-0.22-0.52-0.5
|
||||
V96.81c0-0.24,0.18-0.44,0.41-0.48c1.99-0.34,3.86-1,5.59-1.9c6.25-3.25,10.54-9.8,10.54-17.33c0-11.11-9.33-20.09-20.58-19.5
|
||||
c-10.2,0.53-18.42,9.14-18.49,19.36c-0.06,7.58,4.23,14.2,10.52,17.47c1.73,0.91,3.61,1.56,5.59,1.9
|
||||
c0.24,0.04,0.41,0.24,0.41,0.48v86.37c0,0.29-0.24,0.52-0.52,0.5c-1.84-0.08-3.67-0.23-5.48-0.46c-9.92-1.2-19.26-4.39-27.58-9.16
|
||||
c-1.86-1.05-3.67-2.19-5.43-3.42c-1.61-1.1-3.18-2.28-4.69-3.52c-4.13-3.36-7.88-7.16-11.2-11.34c-1.46-1.83-2.84-3.73-4.12-5.69
|
||||
c-1.21-1.85-2.33-3.76-3.37-5.72c-0.42-0.78-0.82-1.56-1.2-2.35c-0.2-0.41,0.22-0.85,0.64-0.68l3.05,1.23
|
||||
c0.26,0.1,0.55-0.02,0.65-0.28l0.89-2.21l0.98-2.43c0.1-0.26-0.02-0.55-0.28-0.65l-1.35-0.54l-1.23-0.5l-6.98-2.82l-6.19-2.49
|
||||
c-0.38-0.15-0.78,0.2-0.67,0.6c0.61,2.19,1.31,4.34,2.11,6.45c1.17,3.15,2.54,6.2,4.09,9.16c0.93,1.78,1.94,3.53,3.01,5.23
|
||||
c0.71,1.14,1.45,2.26,2.22,3.36c1.37,1.98,2.84,3.9,4.4,5.74c2.41,2.88,5.03,5.58,7.84,8.1c3.38,3.04,7.03,5.8,10.91,8.23
|
||||
c12.32,7.75,26.89,12.25,42.49,12.25c15.6,0,30.18-4.49,42.49-12.24c3.87-2.44,7.52-5.2,10.91-8.24c2.81-2.52,5.43-5.22,7.84-8.1
|
||||
c1.56-1.84,3.03-3.76,4.4-5.74c0.77-1.1,1.51-2.22,2.22-3.36c1.07-1.7,2.08-3.45,3.01-5.23c1.61-3.07,3.03-6.25,4.24-9.54v-0.01
|
||||
c0.87-2.37,1.63-4.79,2.28-7.26c0.01-0.05,0.03-0.1,0.04-0.14L180.11,132.77z M106.78,90.29c-1.55-0.35-3-0.97-4.29-1.81
|
||||
c-3.74-2.4-6.23-6.61-6.23-11.39c0-7.99,6.96-14.38,15.12-13.44c6.18,0.71,11.18,5.73,11.86,11.92
|
||||
c0.89,8.14-5.49,15.05-13.45,15.05C108.75,90.63,107.74,90.51,106.78,90.29z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st2" d="M72.08,102.29h28.2c0.27,0,0.5,0.22,0.5,0.5v5.01c0,0.27-0.22,0.5-0.5,0.5h-28.2c-0.27,0-0.5-0.22-0.5-0.5
|
||||
v-5.01C71.59,102.51,71.81,102.29,72.08,102.29z"/>
|
||||
<path class="st2" d="M146.62,102.79v5c0,0.28-0.22,0.5-0.5,0.5h-26.83c-0.28,0-0.5-0.22-0.5-0.5v-5c0-0.28,0.22-0.5,0.5-0.5h26.83
|
||||
C146.4,102.29,146.62,102.51,146.62,102.79z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st2" d="M82.09,113.95h18.2c0.27,0,0.5,0.22,0.5,0.5v5.01c0,0.27-0.22,0.5-0.5,0.5h-18.2c-0.27,0-0.5-0.22-0.5-0.5
|
||||
v-5.01C81.59,114.17,81.81,113.95,82.09,113.95z"/>
|
||||
<path class="st2" d="M136.62,114.45v5c0,0.28-0.22,0.5-0.5,0.5h-16.83c-0.28,0-0.5-0.22-0.5-0.5v-5c0-0.28,0.22-0.5,0.5-0.5h16.83
|
||||
C136.39,113.95,136.62,114.18,136.62,114.45z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 696 B After Width: | Height: | Size: 6.9 KiB |
BIN
src/assets/dark-logo.png
Normal file
BIN
src/assets/dark-logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.7 KiB |
Binary file not shown.
Before Width: | Height: | Size: 96 KiB |
BIN
src/assets/logo.png
Normal file
BIN
src/assets/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.8 KiB |
@ -1,7 +1,15 @@
|
||||
import { defineCollection } from 'astro:content';
|
||||
import { docsLoader } from '@astrojs/starlight/loaders';
|
||||
import { docsSchema } from '@astrojs/starlight/schema';
|
||||
import {docsLoader, i18nLoader} from '@astrojs/starlight/loaders';
|
||||
import {docsSchema, i18nSchema} from '@astrojs/starlight/schema';
|
||||
|
||||
export const collections = {
|
||||
docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }),
|
||||
docs: defineCollection({
|
||||
loader: docsLoader(),
|
||||
schema: docsSchema(),
|
||||
}),
|
||||
|
||||
/*i18n: defineCollection({
|
||||
loader: i18nLoader(),
|
||||
schema: i18nSchema(),
|
||||
}),*/
|
||||
};
|
||||
|
74
src/content/docs/en/dotnet/guides/concept.mdx
Normal file
74
src/content/docs/en/dotnet/guides/concept.mdx
Normal file
@ -0,0 +1,74 @@
|
||||
---
|
||||
title: CQRS Patterns
|
||||
description: A beginner-friendly explanation of Command Query Responsibility Segregation (CQRS).
|
||||
---
|
||||
|
||||
import { Aside } from '@astrojs/starlight/components';
|
||||
|
||||
# Understanding CQRS Patterns
|
||||
|
||||
Command Query Responsibility Segregation (CQRS) is a software design pattern that separates the concerns of reading and writing data into distinct models. This pattern helps improve scalability, performance, and maintainability, especially in systems with complex business logic.
|
||||
|
||||
---
|
||||
|
||||
## Why Use CQRS?
|
||||
|
||||
In a traditional CRUD (Create, Read, Update, Delete) architecture, the same model is often used for both reading and writing data. While this works for simple applications, it can become a bottleneck as the application grows.
|
||||
|
||||
CQRS addresses these challenges by introducing two distinct models:
|
||||
- **Command Model**: Handles write operations (e.g., creating, updating, or deleting data).
|
||||
- **Query Model**: Handles read operations (e.g., fetching data for display).
|
||||
|
||||
By separating these concerns, CQRS allows for better optimization and customization of each model to meet specific requirements.
|
||||
|
||||
---
|
||||
|
||||
## How Does CQRS Work?
|
||||
|
||||
The CQRS pattern divides your application into the following responsibilities:
|
||||
|
||||
### Commands
|
||||
Commands represent actions or tasks that change the state of your application. Examples include:
|
||||
- Creating a new user
|
||||
- Updating an order
|
||||
- Deleting a record
|
||||
|
||||
Commands are processed through a **command handler**, which ensures that business rules and validations are enforced.
|
||||
|
||||
### Queries
|
||||
Queries are used to retrieve data from your system. They do not modify the application's state and are designed to be fast and efficient. Examples include:
|
||||
- Fetching a list of users
|
||||
- Getting order details
|
||||
|
||||
Queries are often optimized for read performance, using dedicated data models or projections.
|
||||
|
||||
---
|
||||
|
||||
## Benefits of CQRS
|
||||
|
||||
1. **Scalability**: Separating reads and writes allows you to independently scale the read and write sides of your application.
|
||||
2. **Performance**: Optimize read operations for speed while maintaining robust write logic.
|
||||
3. **Flexibility**: Use different technologies or data models for reads and writes.
|
||||
4. **Maintainability**: Clear separation of concerns makes the system easier to understand and maintain.
|
||||
|
||||
---
|
||||
|
||||
## When to Use CQRS?
|
||||
|
||||
CQRS is particularly beneficial in the following scenarios:
|
||||
- Applications with complex business rules.
|
||||
- Systems that require high read or write throughput.
|
||||
- Scenarios where read and write operations have vastly different performance or structure requirements.
|
||||
- Event-driven architectures or systems utilizing Event Sourcing.
|
||||
|
||||
---
|
||||
|
||||
## Conclusion
|
||||
|
||||
CQRS is a powerful pattern that enables better scalability, performance, and maintainability by separating the responsibilities of reading and writing data. By leveraging this pattern, developers can design systems that are easier to scale, optimize, and evolve over time.
|
||||
|
||||
Ready to dive deeper? Check out our [Getting Started Guide](/en/dotnet/guides/getting-started/) to see how the CQRS pattern can be implemented in practice!
|
||||
|
||||
---
|
||||
|
||||
<Aside type="note">Key Takeaway: CQRS separates read and write responsibilities, providing a robust foundation for scalable and maintainable applications.</Aside>
|
4
src/content/docs/en/dotnet/guides/first-command.mdx
Normal file
4
src/content/docs/en/dotnet/guides/first-command.mdx
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
title: Adding a command to your project
|
||||
description: Adding a command to your project
|
||||
---
|
50
src/content/docs/en/dotnet/guides/getting-started.mdx
Normal file
50
src/content/docs/en/dotnet/guides/getting-started.mdx
Normal file
@ -0,0 +1,50 @@
|
||||
---
|
||||
title: Getting started with .NET Core
|
||||
description: Getting started with .NET Core
|
||||
---
|
||||
|
||||
import { Code } from '@astrojs/starlight/components';
|
||||
import { Aside } from '@astrojs/starlight/components';
|
||||
|
||||
import installCode from 'install.sh?raw';
|
||||
import healthQueryCode from 'health-query.cs?raw';
|
||||
import programCode from 'program.cs?raw';
|
||||
|
||||
export const highlights = ['OpenHarbor.CQRS', 'OpenHarbor.CQRS.AspNetCore.Mvc', 'AddDefaultCommandDiscovery', 'AddDefaultQueryDiscovery', 'AddOpenHarborCommands', 'AddOpenHarborQueries', 'AddQuery', 'IQueryHandler'];
|
||||
|
||||
In this tutorial, we will create a simple health query within a brand-new .NET 8 Web API project using the Open Harbor CQRS framework.
|
||||
|
||||
### Setup
|
||||
|
||||
Let's get started by creating a brand-new project!
|
||||
<Code code='dotnet new webapi -o OpenHarbor.Guide' lang='sh' title='.net cli' />
|
||||
|
||||
### Install the .NET package
|
||||
Run the following commands to install the required packages:
|
||||
<Code code={installCode} lang="sh" title='.net cli' />
|
||||
|
||||
### Creating our first query
|
||||
We will create a simple health check endpoint to verify that our API is running:
|
||||
<Code code={healthQueryCode} lang="csharp" title='Query/HealthQuery.cs' mark={highlights} />
|
||||
|
||||
<Aside type="caution">The current version of the framework requires registering at least one query for .NET MVC to function properly. This limitation will be resolved in a future update.</Aside>
|
||||
|
||||
### Preparing our program using MVC to bind our queries and commands
|
||||
|
||||
<Code code={programCode} lang="csharp" title='Program.cs' mark={highlights} />
|
||||
|
||||
`AddDefaultCommandDiscovery` and `AddDefaultQueryDiscovery` are the default implementations in the CQRS framework for discovering the commands and queries defined in your application. To learn more about how they work, you can check out their functionality <a href="https://git.openharbor.io/Open-Harbor/dotnet-cqrs/src/branch/main/OpenHarbor.CQRS/Discovery" target="_blank" rel="noopener noreferrer">here</a>.
|
||||
|
||||
`AddQuery` is used to register your query, allowing the framework to expose it automatically.
|
||||
|
||||
`AddOpenHarborCommands` and `AddOpenHarborQueries` dynamically generate controllers for your application, leveraging the MVC features of .NET
|
||||
|
||||
<Aside type="note">A future update will include support for Minimal APIs in .NET, providing an alternative to the current MVC-based implementation.</Aside>
|
||||
|
||||
### Reaping the rewards of our work!
|
||||
|
||||
Run the project and navigate to `/api/query/health` in your browser to see the result.
|
||||
|
||||
### What's next?
|
||||
|
||||
🎉 Congratulations! You've successfully created your first CQRS Web API with a simple health check query. In the next guide, we’ll explore adding a command and a query that interact with each other, showcasing the endless possibilities you can unlock with our CQRS framework. Let your imagination run wild!
|
11
src/content/docs/en/dotnet/guides/health-query.cs
Normal file
11
src/content/docs/en/dotnet/guides/health-query.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using OpenHarbor.CQRS.Abstractions;
|
||||
|
||||
namespace OpenHarbor.Guide.Query;
|
||||
|
||||
public class HealthQuery { }
|
||||
|
||||
public class HealthQueryHandler : IQueryHandler<HealthQuery, bool>
|
||||
{
|
||||
public Task<bool> HandleAsync(HealthQuery query, CancellationToken cancellationToken = new CancellationToken())
|
||||
=> Task.FromResult(true);
|
||||
}
|
2
src/content/docs/en/dotnet/guides/install.sh
Normal file
2
src/content/docs/en/dotnet/guides/install.sh
Normal file
@ -0,0 +1,2 @@
|
||||
dotnet add package OpenHarbor.CQRS
|
||||
dotnet add package OpenHarbor.CQRS.AspNetCore
|
25
src/content/docs/en/dotnet/guides/program.cs
Normal file
25
src/content/docs/en/dotnet/guides/program.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using OpenHarbor.CQRS;
|
||||
using OpenHarbor.CQRS.AspNetCore.Mvc;
|
||||
using OpenHarbor.Guide.Query;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddDefaultCommandDiscovery();
|
||||
builder.Services.AddDefaultQueryDiscovery();
|
||||
|
||||
builder.Services.AddQuery<HealthQuery, bool, HealthQueryHandler>();
|
||||
|
||||
var mvcBuilder = builder.Services
|
||||
.AddControllers();
|
||||
|
||||
mvcBuilder
|
||||
.AddOpenHarborCommands();
|
||||
|
||||
mvcBuilder
|
||||
.AddOpenHarborQueries();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Example Reference
|
||||
description: A reference page in my new Starlight docs site.
|
||||
description: A references page in my new Starlight docs site.
|
||||
---
|
||||
|
||||
Reference pages are ideal for outlining how things work in terse and clear terms.
|
24
src/content/docs/en/dotnet/resources/nugets.mdx
Normal file
24
src/content/docs/en/dotnet/resources/nugets.mdx
Normal file
@ -0,0 +1,24 @@
|
||||
---
|
||||
title: Nugets
|
||||
description: A references page in my new Starlight docs site.
|
||||
---
|
||||
|
||||
|
||||
|
||||
## Implementations Packages
|
||||
|
||||
| Name | NuGet |
|
||||
|-----------------------------------------| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|
||||
| OpenHarbor.CQRS | [![NuGet](https://img.shields.io/nuget/v/OpenHarbor.CQRS.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/OpenHarbor.CQRS/) |
|
||||
| OpenHarbor.CQRS.AspNetCore | [![NuGet](https://img.shields.io/nuget/v/OpenHarbor.CQRS.AspNetCore.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/OpenHarbor.CQRS.AspNetCore/) |
|
||||
| OpenHarbor.CQRS.FluentValidation | [![NuGet](https://img.shields.io/nuget/v/OpenHarbor.CQRS.FluentValidation.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/OpenHarbor.CQRS.FluentValidation/) |
|
||||
| OpenHarbor.CQRS.DynamicQuery | [![NuGet](https://img.shields.io/nuget/v/OpenHarbor.CQRS.DynamicQuery.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/OpenHarbor.CQRS.DynamicQuery/) |
|
||||
| OpenHarbor.CQRS.DynamicQuery.AspNetCore | [![NuGet](https://img.shields.io/nuget/v/OpenHarbor.CQRS.DynamicQuery.AspNetCore.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/OpenHarbor.CQRS.DynamicQuery.AspNetCore/) |
|
||||
|
||||
## Abstractions Packages
|
||||
|
||||
| Name | NuGet |
|
||||
|-------------------------------------------| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|
||||
| OpenHarbor.CQRS.Abstractions | [![NuGet](https://img.shields.io/nuget/v/OpenHarbor.CQRS.Abstractions.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/OpenHarbor.CQRS.Abstractions/) |
|
||||
| OpenHarbor.CQRS.AspNetCore.Abstractions | [![NuGet](https://img.shields.io/nuget/v/OpenHarbor.CQRS.AspNetCore.Abstractions.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/OpenHarbor.CQRS.AspNetCore.Abstractions/) |
|
||||
| OpenHarbor.CQRS.DynamicQuery.Abstractions | [![NuGet](https://img.shields.io/nuget/v/OpenHarbor.CQRS.DynamicQuery.Abstractions.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/OpenHarbor.CQRS.DynamicQuery.Abstractions/) |
|
30
src/content/docs/en/index.mdx
Normal file
30
src/content/docs/en/index.mdx
Normal file
@ -0,0 +1,30 @@
|
||||
---
|
||||
title: Welcome Open Harbor CQRS Framework Documentation
|
||||
description: Open Harbor CQRS Framework
|
||||
template: splash
|
||||
hero:
|
||||
tagline: Get started building your apis in .net with our CQRS framework
|
||||
image:
|
||||
file: ../../../assets/logo.png
|
||||
actions:
|
||||
- text: Get Started
|
||||
link: dotnet/guides/getting-started
|
||||
icon: right-arrow
|
||||
---
|
||||
|
||||
import { Card, CardGrid } from '@astrojs/starlight/components';
|
||||
|
||||
<CardGrid stagger>
|
||||
<Card title="Modularity" icon="puzzle">
|
||||
Modular architecture designed for extensibility.
|
||||
</Card>
|
||||
<Card title="CQRS Patterns" icon="open-book">
|
||||
Separate your reads and writes with just a few lines of code.
|
||||
</Card>
|
||||
<Card title="Commands and Queries" icon="comment">
|
||||
Let your code do the talking and simplify the complexity.
|
||||
</Card>
|
||||
<Card title="Open Source" icon="github">
|
||||
Learn more from the [documentations](dotnet/guides/getting-started).
|
||||
</Card>
|
||||
</CardGrid>
|
@ -1,19 +1,15 @@
|
||||
---
|
||||
title: Welcome to Starlight
|
||||
description: Get started building your docs site with Starlight.
|
||||
title: Welcome Open Harbor CQRS Framework Documentation
|
||||
description: Open Harbor CQRS Framework
|
||||
template: splash
|
||||
hero:
|
||||
tagline: Congrats on setting up a new Starlight project!
|
||||
tagline: Get started building your apis in .net with our CQRS framework
|
||||
image:
|
||||
file: ../../assets/houston.webp
|
||||
file: ../../../assets/logo.png
|
||||
actions:
|
||||
- text: Example Guide
|
||||
link: /guides/example/
|
||||
- text: Get Started
|
||||
link: fr/guides/example/
|
||||
icon: right-arrow
|
||||
- text: Read the Starlight docs
|
||||
link: https://starlight.astro.build
|
||||
icon: external
|
||||
variant: minimal
|
||||
---
|
||||
|
||||
import { Card, CardGrid } from '@astrojs/starlight/components';
|
@ -1,11 +0,0 @@
|
||||
---
|
||||
title: Example Guide
|
||||
description: A guide in my new Starlight docs site.
|
||||
---
|
||||
|
||||
Guides lead a user through a specific task they want to accomplish, often with a sequence of steps.
|
||||
Writing a good guide requires thinking about what your users are trying to do.
|
||||
|
||||
## Further reading
|
||||
|
||||
- Read [about how-to guides](https://diataxis.fr/how-to-guides/) in the Diátaxis framework
|
0
src/styles/global.css
Normal file
0
src/styles/global.css
Normal file
Loading…
Reference in New Issue
Block a user