Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New docs #582

Merged
merged 56 commits into from
Jan 5, 2024
Merged

New docs #582

merged 56 commits into from
Jan 5, 2024

Conversation

wojtek2288
Copy link
Contributor

@wojtek2288 wojtek2288 commented Oct 9, 2023

  • New documentation. If you want to check out how does it look visit: https://leancode-corelibrary--582.org.readthedocs.build/ (I would recommend reading it there).
  • This also uses old General section from README.md as new github README.md (with some small overview addition).
  • Removed Check links step from markdown lint check as it exceeded nuget rate limits and failed.

@wojtek2288 wojtek2288 marked this pull request as draft October 9, 2023 06:35
@github-actions
Copy link

github-actions bot commented Oct 9, 2023

Test Results

 35 files  ±0  119 suites  ±0   1m 2s ⏱️ -7s
649 tests ±0  636 ✅ ±0  13 💤 ±0  0 ❌ ±0 
665 runs  ±0  645 ✅ ±0  20 💤 ±0  0 ❌ ±0 

Results for commit 79e9960. ± Comparison against base commit 4c29726.

♻️ This comment has been updated with latest results.

@codecov
Copy link

codecov bot commented Oct 9, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4c29726) 63.00% compared to head (79e9960) 63.00%.

Additional details and impacted files
@@              Coverage Diff              @@
##           v8.0-preview     #582   +/-   ##
=============================================
  Coverage         63.00%   63.00%           
=============================================
  Files               244      244           
  Lines              5636     5636           
  Branches            369      369           
=============================================
  Hits               3551     3551           
  Misses             1978     1978           
  Partials            107      107           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wojtek2288 wojtek2288 force-pushed the new-docs branch 7 times, most recently from 1c9f8c1 to 9291581 Compare October 11, 2023 06:53
@@ -0,0 +1,64 @@
# Authorization

Each command and query has to be authorized or must explicitly opt-out of authorization (it's enforced using Roslyn analyzers). You can specify which authorizer to use using the `AuthorizeWhen` attribute and custom `ICustomAuthorizer`. Opting-out is done using the `AllowUnauthorized` attribute. There is a predefined authorizer that uses role- and permission-based authorization. You can specify which permissions to enforce using `AuthorizeWhenHasAnyOf` and configure the role-to-permission relationship using `IRoleRegistrations`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

command, query and operation?
I wonder do we have a clear term for all three concepts. Sometimes commands and queries are jointly called CQRS operations, but this would be misleading in our case. 🤔

If we pick one, it should be used consistently in all contexts. I would prefer a separate term instead of enumerating "comands, queries and operations". Unfortunately, I don't have an idea, maybe someone else would fill in. 😄

Copy link
Contributor

@Dragemil Dragemil Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could adapt a bit the CQRS objects terminology. Maybe go back to the roots calling them RCQRS objects (Remote), however we have abandoned this terminology I'm afraid. Otherwise, we can get a little bit silly and call them CQRS+ objects, where + would mean the operation.

docs/cqrs/authorization/index.md Outdated Show resolved Hide resolved
docs/cqrs/authorization/index.md Outdated Show resolved Hide resolved
docs/cqrs/command/index.md Outdated Show resolved Hide resolved
docs/cqrs/command/index.md Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like starting with potential use cases!

```csharp
public class PayForAccessOH : IOperationHandler<PayForAccess, PaymentTokenDTO>
{
private readonly IPaymentsService payments;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ending service names with Service might be another topic for our freak fight weekly. 🤡

docs/cqrs/query/index.md Outdated Show resolved Hide resolved
docs/cqrs/query/index.md Outdated Show resolved Hide resolved
docs/cqrs/query/index.md Outdated Show resolved Hide resolved
@wojtek2288 wojtek2288 force-pushed the new-docs branch 2 times, most recently from 7219048 to 55c5858 Compare October 19, 2023 09:33
@wojtek2288 wojtek2288 force-pushed the new-docs branch 2 times, most recently from 8379cf2 to 3820958 Compare November 13, 2023 11:59
docs/cqrs/query/index.md Outdated Show resolved Hide resolved
docs/cqrs/validation/index.md Outdated Show resolved Hide resolved

> **Tip:** More on ids can be found [here](../../domain/id/index.md).

If you need complex validation logic that needs to access external state, use `MustAsync`/`CustomAsync` validators. For `CustomAsync` validators, you can use `AddValidationError` helper to specify the error code.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to add an example of async validation (checking for existence with dbContext should suffice).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was there above this, moved this text above async validator to make it more clear.

docs/domain/domain_event/index.md Show resolved Hide resolved
@wojtek2288 wojtek2288 force-pushed the new-docs branch 2 times, most recently from acdf7fe to a262605 Compare November 29, 2023 10:03
@wojtek2288 wojtek2288 marked this pull request as ready for review November 30, 2023 11:40
docs/domain/domain_event/index.md Show resolved Hide resolved
@@ -0,0 +1,64 @@
# Authorization

Each command and query has to be authorized or must explicitly opt-out of authorization (it's enforced using Roslyn analyzers). You can specify which authorizer to use using the `AuthorizeWhen` attribute and custom `ICustomAuthorizer`. Opting-out is done using the `AllowUnauthorized` attribute. There is a predefined authorizer that uses role- and permission-based authorization. You can specify which permissions to enforce using `AuthorizeWhenHasAnyOf` and configure the role-to-permission relationship using `IRoleRegistrations`.
Copy link
Contributor

@Dragemil Dragemil Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could adapt a bit the CQRS objects terminology. Maybe go back to the roots calling them RCQRS objects (Remote), however we have abandoned this terminology I'm afraid. Otherwise, we can get a little bit silly and call them CQRS+ objects, where + would mean the operation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to also mention the features not present in this repo? Like LeanPipe, app rating and probably something else. We could have a list somewhere with just one sentence long descriptions and links to the docs (LeanPipe e.g. has some docs in its repo)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we could do it, but I can see that only app rating has public repo, leanpipe and notification center are private and I don't think that we should mention features that might not be available to user outside leancode.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put that in the backlog - these repo will be open rather soon.

</Project>
```

[/Directory.Build.props]: https://github.com/leancodepl/corelibrary/blob/v8.0-preview/Directory.Build.props
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be broken very soon. I wonder if we can make it a link to a default branch no matter what it is.

Copy link
Contributor Author

@wojtek2288 wojtek2288 Dec 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could point to the HEAD but we probably do not want docs just to point to newest commit. When v8 is released some other link also need to be updated. Will probably update it then.

@@ -0,0 +1,213 @@
# Authorization

Each command and query has to be authorized or must explicitly opt-out of authorization (it's enforced using Roslyn analyzers). You can specify which authorizer to use using the `AuthorizeWhen` attribute and custom `ICustomAuthorizer`. Opting-out is done using the `AllowUnauthorized` attribute. There is a predefined authorizer that uses role- and permission-based authorization. You can specify which permissions to enforce using `AuthorizeWhenHasAnyOf` and configure the role-to-permission relationship using `IRoleRegistrations`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(it's enforced using Roslyn analyzers)

Do we have any entry in the docs covering this topic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, I will add this to backlog and reword it

docs/cqrs/authorization/index.md Outdated Show resolved Hide resolved
docs/cqrs/authorization/index.md Outdated Show resolved Hide resolved
docs/cqrs/pipeline/index.md Outdated Show resolved Hide resolved
docs/cqrs/pipeline/adding_custom_middlewares.md Outdated Show resolved Hide resolved
docs/domain/aggregate/index.md Outdated Show resolved Hide resolved

// Assert that the `DateCreated` time matches
// the expected time in UTC.
Assert.Equal(expectedTime.UtcDateTime, project.DateCreated);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: FluentAssertions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm not sure about that, I think it should be as simple as possible and using FluentAssertions in docs might add some unnecessary complication (as it is not as popular and recognized XUnit's Assert).

docs/quick_start/index.md Outdated Show resolved Hide resolved

Our aim is to provide an opinionated framework for .NET Core app development. As for now we have, more-or-less, standardized:
The LeanCode Core Library is a set of helper libraries developed at [our company](https://leancode.co/) that aids our day-to-day development. Not only does it serve as a facilitator in our day-to-day coding activities, but it also encapsulates comprehensive guidelines, gathers our collective knowledge on application architecture and development best practices.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not now probably, but for future - we need to re-word this and put more focus on "CoreLib being a enterprise-ready framework that structures how you create the applications".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sth like the second paragraph.

docs/quick_start/index.md Show resolved Hide resolved
docs/quick_start/index.md Outdated Show resolved Hide resolved
docs/quick_start/index.md Outdated Show resolved Hide resolved
docs/quick_start/index.md Show resolved Hide resolved
docs/quick_start/index.md Outdated Show resolved Hide resolved
docs/quick_start/index.md Outdated Show resolved Hide resolved

After successfully setting up the local cluster, your next step is to initiate your application. Begin by navigating to the `backend` directory. This directory is the heart of your application, containing various subdirectories and files, each serving a specific purpose:

```txt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will change soon, so let's remember to fix it after the fact.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


### Generating initial migrations

Let's start with generating initial migrations. Begin by navigating, to the `backend/src/Apps/ProjectName.Migrations` directory. Generate initial migrations using the `dotnet ef` tool (install it via `dotnet tool install --global dotnet-ef`):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I talked with Krzysiek about this one, this tool IMO should be put in the dotnet-tools.json. /cc: @Saancreed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will update this when it will be in dotnet-tools.json

Then you can run the migrations and the API using the following command:

```sh
tilt up migrations api
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will run API only, it will not start migrations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what we always had in README if I remember correctly it did start the migrations when I ran it. Anyway I separated those commands now.

docs/cqrs/index.md Outdated Show resolved Hide resolved
docs/cqrs/index.md Outdated Show resolved Hide resolved
docs/cqrs/index.md Outdated Show resolved Hide resolved

- **Separation of concerns:** CQRS enforces a clear separation of concerns between the write and read operations. This leads to a more maintainable and modular codebase, making it easier to understand, test, and develop.
- **Improved security:** Security measures can be applied more granularly. For instance, you might have different authorization mechanisms for read and write operations, providing an additional layer of control.
- **Validation on the write side:** With CQRS, the write side typically handles commands that change the state of the system. This is where validation of incoming data and business rules can be enforced. By centralizing validation logic on the write side, you ensure that all changes to the system go through a consistent validation process.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get the typically here - what does it refer to?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I don't get the point fully. Could you paraphrase it to me?

Copy link
Contributor Author

@wojtek2288 wojtek2288 Dec 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think typically is unnecessary here and can be removed/

The point is that we do not need to include validation on our read side. I will reword it to make it more clear.

docs/cqrs/index.md Outdated Show resolved Hide resolved
docs/cqrs/command/index.md Outdated Show resolved Hide resolved
docs/cqrs/command/index.md Show resolved Hide resolved

## Naming conventions

Commands in CQRS are responsible for modifying the state of the system, and therefore their names should reflect the action they trigger. A common convention is to use imperative verbs that clearly describe the intent, including the namespace as part of the contract, such as:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get the including the namespace as part of the contract. What did you have in mind here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was @tomaszlaskowskiLC suggestion somewhere above. Namespace might sometimes provide additional information about the contract, and I think it should be treated as a part of it so that we do not create some weird folder structure which might confuse the clients.

docs/cqrs/command/index.md Outdated Show resolved Hide resolved
docs/cqrs/command/index.md Outdated Show resolved Hide resolved
docs/cqrs/query/index.md Outdated Show resolved Hide resolved
docs/cqrs/query/index.md Outdated Show resolved Hide resolved
docs/cqrs/query/index.md Outdated Show resolved Hide resolved
@wojtek2288 wojtek2288 merged commit 0e9010c into v8.0-preview Jan 5, 2024
10 checks passed
@wojtek2288 wojtek2288 deleted the new-docs branch January 5, 2024 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants