Microsoft Orleans codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.
What is RealWorld
Realworld is a simple content management system similar to Medium.com or Wordpress but is much simpler. For live demo, please visit: https://demo.realworld.io/. Its basic features are:
- signup & sigin users
- CRUD articles
- articles tags, favorite, comments
Realworld is built using SPA, having Frontend Web app and Backend Web API. For further information, please visit RealWorld Github.
This Work-In-Progress codebase was created to demonstrate a fully fledged fullstack application built with Microsoft Orleans including CRUD operations, authentication, routing, pagination, and more.
We've gone to great lengths to adhere to the Microsoft Orleans community styleguides & best practices.
For more information on how to this works with other frontends/backends, head over to the RealWorld repo.
This Web app is combining ASP.NET Core Web API and Microsoft Orleans. ASP.NET Core is used as the Orleans Clients, so we need an Orleans Server and that is what /src/SiloHost is for.
For the ASP.NET Core Web API, some notable packages used (beside Orleans):
- Fluent validation
- Microsoft JWT Bearer
- Swashbuckle for ASP.NET Core
- Feature folder
- Npgsql for cluster client accessing cluster management table
- MediaTR for thin controllers
note that ASP.NET Core Web API don't use ngpsql to access database directly in the logic, its only used for accessing cluster management table.
For The Orleans implementation, some notes:
- Postgresql is used for both AdoNet clustering and grains persistent provider
- Related to grains persistent provider, the payloadjson column of orleansstorage table is changed from default TEXT to JSONB
- Npgsql for direct query to database
Picture below ilustrate the relations of ASP.NET Core Web API, represented by Conduit and Orleans implementation, represented by SiloHost :
In the code base, we also try to adopt practice from Golang language regarding method return value being Error is one of it. See https://golang.org/doc/tutorial/handle-errors. In C#, tuple is used to replicate similar practice. This might be changed in the future, like removed altogether, but currently we are still unsure to continue or stop. Leave it like this for the time being.
For more in-depth and complete example of Orleans sample, please look at OneBoxDeployment or road-to-orleans.
to have this up and running, steps are as follow:
- clone this repository
- prepare the database, as instructed in /scripts/README.md
- build the solution
- start the /src/Conduit
All works is done:
- Authentication
- Registration
- Get current user
- Update user. Implemented with limitation, that is user cannot change username. More explanation here
- Get profile
- Follow user
- Unfollow user
- List articles. With some caveat.
- all articles
- article by tag
- favorited. Tested only using run-api-tests.sh, untested the functionality
- by author. Tested only using run-api-tests.sh, untested the functionality
- Feed articles
- Get article
- Create article
- Update article
- Delete article
- Add comments to article
- Get comments from article
- Delete comment
- Favorit article
- Unfavorite article
- Get tags
Copy many codes from an awesome conduit implementation using ASP.NET Core. Please check that repository, many things done right and much to learn from it.