{"id":14986613,"url":"https://github.com/friflo/fliox.examples","last_synced_at":"2025-04-11T21:31:07.695Z","repository":{"id":53114822,"uuid":"514208529","full_name":"friflo/Fliox.Examples","owner":"friflo","description":"Client \u0026 Hub examples for JSON Fliox.    A .NET library with NoSQL, Messaging, Pub-Sub, ORM, Database Hub, Schema \u0026 ASP.NET Core support.","archived":false,"fork":false,"pushed_at":"2024-05-10T12:01:51.000Z","size":900,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T18:40:36.199Z","etag":null,"topics":["asp-net-core","authentication","authorization","database-hub","database-relations","database-schema","graphql","json-fliox","no-sql","open-api","orm","pub-sub","realtime-messaging","rest","rpc","swagger-ui","websocket"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/friflo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-15T09:19:54.000Z","updated_at":"2024-05-10T12:01:54.000Z","dependencies_parsed_at":"2023-01-27T18:46:27.381Z","dependency_job_id":"425b8e97-1ad8-4203-b88d-7c460b8d2e21","html_url":"https://github.com/friflo/Fliox.Examples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friflo%2FFliox.Examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friflo%2FFliox.Examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friflo%2FFliox.Examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friflo%2FFliox.Examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/friflo","download_url":"https://codeload.github.com/friflo/Fliox.Examples/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248482915,"owners_count":21111400,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asp-net-core","authentication","authorization","database-hub","database-relations","database-schema","graphql","json-fliox","no-sql","open-api","orm","pub-sub","realtime-messaging","rest","rpc","swagger-ui","websocket"],"created_at":"2024-09-24T14:13:13.830Z","updated_at":"2025-04-11T21:31:07.291Z","avatar_url":"https://github.com/friflo.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\r\n\r\n# [![Examples](.docs/images/Json-Fliox.svg)](https://github.com/friflo/Fliox.Examples)    **Fliox Examples**  ![SPLASH](.docs/images/paint-splatter.svg)\r\n\r\n[![CI](https://github.com/friflo/Fliox.Examples/workflows/CI/badge.svg)](https://github.com/friflo/Fliox.Examples/actions)\r\n\r\n\u003cbr/\u003e\r\n\r\n\r\n\r\nThis project contains two **ready to run** examples showing how to create and use\r\n[**JSON Fliox**](https://github.com/friflo/Friflo.Json.Fliox/blob/main/README.md) **Clients** \u0026 **Hubs**.  \r\n\r\n*In short*  \r\n**JSON Fliox** is .NET library supporting simple and efficient access to NoSQL databases via C# or Web clients.\r\n\r\nThis repo on GitHub: [friflo/Fliox.Examples](https://github.com/friflo/Fliox.Examples)\r\n\r\nPublished project on GitHub 2022-08\r\n\r\n\u003cbr/\u003e\r\n\r\n# 🚩 Content\r\n\r\n- [Examples](#-examples)\r\n    - [Demo](#demo)\r\n    - [Todo](#todo)\r\n    - [SchemaValidation](#schemavalidation)\r\n- [Build](#-build)\r\n- [Walkthrough](#-walkthrough)\r\n- [Credits](#-credits)\r\n\r\n\u003cbr/\u003e\u003cbr/\u003e\r\n\r\n\r\n# 🚀 Examples\r\n\r\nThis project contains two examples with a different set of features. Their differences are listed at [🎨 Features](.docs/features.md).  \r\nThe intention is to guide how to add a new or remove an existing features in an application.\r\n\r\n- [**Demo**](#demo)    *common* example  - LOC: 500\r\n- [**Todo**](#todo)    *minimal* example - LOC:  60\r\n\r\nEach example contains three folders / C# projects\r\n\r\n| folder     | project type      | description               | run command                                           |\r\n|------------|-------------------|---------------------------|-------------------------------------------------------|\r\n| **Client** | .NET library      | database client / schema  |                                                       |\r\n| **Hub**    | .NET HTTP server  | bootstrapping a Hub       | `dotnet run`                                          |\r\n| **Test**   | NUnit tests       | client examples \u0026 test DB | `dotnet test` \u003cbr/\u003e `dotnet run [http, file, memory]` |\r\n\r\nThe **API**'s used by the examples are available at [**fliox-docs API Reference**](https://github.com/friflo/fliox-docs)\r\n\r\nBuild, Test and Run instructions described at [🔧 Build](#-build)\r\n\r\n\u003cbr/\u003e\u003cbr/\u003e\r\n\r\n\r\n## **Demo**\r\n📄   [README.md](Demo)\r\n\r\nThe Demo example contains a *common* **Client**, a *common* **Hub** and **unit tests**.  \r\n\r\n**Hub** features:  \r\nAll **Todo/Hub** features + **ASP.NET** integration, **GraphQL** API, monitoring, user authorization, **Pub-Sub**, container **relations** and custom **commands**.  \r\nIt utilize [Bogus](https://github.com/bchavez/Bogus) to generate fake records in various containers.\r\n\r\nUse the Hub Explorer http://localhost:5000/fliox/ to check the features.  \r\nTry out the online example [**DemoHub on AWS**](http://ec2-18-215-176-108.compute-1.amazonaws.com/) - *EC2: t2-micro*, *us-east-1*  \r\n\r\n|              | Client                       | Hub                                                                    |\r\n|--------------|------------------------------|------------------------------------------------------------------------|\r\n| C#           | 2 files - LOC 140            | 4 files - LOC Program 40, ASP.NET 35, domain logic 280            |\r\n| dependencies | **JSON Fliox** 4 dlls 850 KB | **JSON Fliox** 7 dlls 900 KB  **GraphQLParser** 300kb  **Bogus** 2.4MB |\r\n\r\n\u003cbr/\u003e\u003cbr/\u003e\r\n\r\n\r\n## **Todo**\r\n📄   [README.md](Todo)\r\n\r\nThe Todo example contains a *minimal* **Client**, a *minimal* **Hub** and **unit tests**.  \r\n\r\n**Hub** features:  \r\n[**Hub Explorer**](https://github.com/friflo/Friflo.Json.Fliox/blob/main/Json/Fliox.Hub.Explorer/README.md),\r\nHttpListener hosting, **REST / OpenAPI**, **Batch API** \u0026 **database schema**.  \r\n\r\nUse the Hub Explorer http://localhost:5000/fliox/ to check the features.  \r\n\r\n|              | Client                       | Hub                          |\r\n|--------------|------------------------------|------------------------------|\r\n| C#           | 1 file - LOC 35              | 1 file - LOC 25              |\r\n| dependencies | **JSON Fliox** 4 dlls 850 KB | **JSON Fliox** 5 dlls 855 KB |\r\n\r\n\u003cbr/\u003e\u003cbr/\u003e\r\n\r\n\r\n## **SchemaValidation**\r\n📁   [C# Project](./SchemaValidation/)\r\n\r\n### *JSON Schema validation*\r\n\r\nThe example shows how to validate a **JSON** string with a given **schema**.  \r\nThe input for `JsonValidator.Validate()` is the JSON string and the Type defining the schema - `Person` in the example below.  \r\nRequires nuget package [Friflo.Json.Fliox ](https://www.nuget.org/packages/Friflo.Json.Fliox/).\r\n\r\n```csharp\r\n    class Person\r\n    {\r\n                    public  int     age;\r\n        [Required]  public  string  name;\r\n    }\r\n    \r\n    public static class SchemaValidation\r\n    {\r\n        /// Validate JSON with a Schema\r\n        [Test]\r\n        public static void Run() {\r\n            var json = \"{\\\"age\\\":42,\\\"name\\\":\\\"Peter\\\"}\";\r\n            var success = JsonValidator.Validate(json, typeof(Person), out var error);\r\n            Assert.IsTrue(success);\r\n\r\n            json = \"{\\\"age\\\":42}\";\r\n            success = JsonValidator.Validate(json, typeof(Person), out error);\r\n            Assert.IsFalse(success);\r\n            Assert.AreEqual(\"Missing required fields: [name] at Person \u003e (root), pos: 10\", error);\r\n        }\r\n    }\r\n```\r\n\r\n### *Code generation*\r\nThe input for code generation is the type defining the schema - `Person` in the example below.  \r\n\r\n```csharp\r\n    /// Generate: C#, GraphQL, HTML, JSON Schema, Kotlin, Markdown and Typescript in folder: ./schema\r\n    public static void GenerateSchemaModels() {\r\n        var schemaModels = SchemaModel.GenerateSchemaModels(typeof(Person));\r\n        foreach (var schemaModel in schemaModels) {\r\n            var folder = $\"./schema/{schemaModel.type}\";\r\n            schemaModel.WriteFiles(folder);\r\n        }\r\n    }\r\n```\r\n\r\n\u003cbr/\u003e\u003cbr/\u003e\r\n\r\n\r\n# 🔧 Build\r\n\r\nThe solution and its projects can be build, tested and executed on **Windows**, **Linux**, and **macOS**.  \r\nIt can be used with following IDE's:\r\n[Visual Studio Code](https://code.visualstudio.com/),\r\n[Rider](https://www.jetbrains.com/rider/) \u0026\r\n[Visual Studio 2022](https://visualstudio.microsoft.com/vs/).\r\n\r\n*Note*: In order to build and run the examples the [**.NET 8.0 SDK**](https://dotnet.microsoft.com/en-us/download) is required.\r\n\r\n\r\nOr use **Gitpod** to build and run the server using VSCode in the browser without installing anything.  \r\nWorkspace available in 30 sec. Open  \u003ca href=\"https://gitpod.io/#https://github.com/friflo/Fliox.Examples\" target=\"_blank\"\u003e\r\n  \u003cimg src=\"https://img.shields.io/badge/Build%20with-Gitpod-908a85?logo=gitpod\" alt=\"Build with Gitpod\" align = \"center\"/\u003e\r\n\u003c/a\u003e  in new tab. When Finished open Terminal panel.\r\n\r\n\u003cbr/\u003e\r\n\r\nclone repository and open its directory - leave out this step when using Gitpod.\r\n```cmd\r\ngit clone https://github.com/friflo/Fliox.Examples.git\r\ncd Fliox.Examples\r\n```\r\n\r\nbuild all examples\r\n```cmd\r\ndotnet build\r\n⏩\r\nBuild succeeded.\r\n    0 Warning(s)\r\n    0 Error(s)\r\n```\r\n\r\nrun unit tests of all examples\r\n```cmd\r\ndotnet test\r\n⏩\r\nPassed! - Failed: 0, Passed: 7, Skipped: 0, Total: 7, Duration: 421 ms - TodoTest.dll (net6.0)\r\nPassed! - Failed: 0, Passed: 6, Skipped: 0, Total: 6, Duration: 712 ms - DemoTest.dll (net6.0)\r\n```\r\n\r\nrun a Hub as an HTTP server from its folder - e.g.\r\n```cmd\r\ncd ./Todo/Hub\r\ndotnet run\r\n```\r\nthe server will start with logs like\r\n\r\n![server logs](.docs/images/server-log.svg)\r\n\r\n\r\nwhen using Gitpod:\r\n- Click **Make Public**  \r\n- Click **`http://localhost:5000/fliox/`**  in Terminal  \r\n\u003cimg src=\".docs/images/gitpod-make-public.png\" width=\"490\" height=\"91\" align=\"top\"/\u003e\r\n\r\n\u003cbr/\u003e\r\n\r\nOtherwise open the **Hub Explorer** in your browser: http://localhost:5000/fliox/\r\n\r\n\u003cbr/\u003e\r\n\r\nrun the .NET Test client accessing the Hub from its folder - e.g.\r\n```cmd\r\ncd ./Todo/Test\r\ndotnet run\r\n⏩\r\n--- jobs:\r\nid: 1, title: buy milk, completed: False\r\nid: 2, title: buy cheese, completed: True\r\n\r\n wait for events ... (exit with: CTRL + C)\r\n note: generate events by clicking 'Save' on a record in the Hub Explorer\r\n```\r\nIt will execute the client methods used in `Trial.Main()`\r\n\r\n\u003cbr/\u003e\u003cbr/\u003e\r\n\r\n# 🐾 Walkthrough\r\n\r\nStart with the simple **Todo** example as it contains only 70 LOC.  \r\nTherefore execute the steps listed in [🔧 Build](./README.md#-build) section.\r\n\r\nAfter starting the TodoHub server open the Hub Explorer at http://localhost:5000/fliox/ in the browser.  \r\n\r\n\u003cbr/\u003e\r\n\r\n![Hub Explorer](.docs/images/TodoHub-Explorer.svg)\r\n\r\nNow you can try the actions below in any order.\r\n- Click on the **Project Name** to open the website describing the project\r\n- Click on the **Schema** link to open a single page documentation\r\n- Click on the **(CD) Class Diagram** link to open the database schema as a class diagram\r\n- Click on the **(OAS) OpenAPI** link to open the Swagger UI\r\n- Click on **Typescript, C#, Kotlin, JSON Schema / OpenAPI** link to export types for other languages\r\n- Select a database command - e.g. **std.Echo** - and execute it with **Send**\r\n- Select container **jobs** to view and edit its entities aka records  \r\n  When selecting a container the UI will change shown in the screenshot below\r\n\r\n\u003cbr/\u003e\r\n\r\n![Hub Explorer](.docs/images/TodoHub-Explorer-container.svg)\r\n\r\nUse the container view to show, edit and query entities.\r\n- Click on a **REST link** to show its response in a new browser tab\r\n- Select an entity in the container (e.g. id: 1) to view its value in **JSON Editor**\r\n- Make changes in the **JSON Editor** an **Save** them\r\n- **Delete** selected entity / entities\r\n- Create an new entity with the **JSON Editor** by\r\n    - selecting an exiting one\r\n    - change its id\r\n    - click **Save**\r\n- Execute a container query using a **LINQ filter expression**    `o =\u003e o.completed != false`  \r\n  and clicking **Apply filter**\r\n- Remove the query filter by clicking on the red ❌ on the top left in the Explorer\r\n- **Select All / None** entities in the container to edit them as JSON\r\n\r\n\u003cbr/\u003e\r\n\r\n**C# Tests**\r\n\r\nThe functionality shown in the Walkthrough above is also available via the C# API.  \r\nHow to use the API is demonstrated as unit tests in [TodoTests.cs](Todo/Test/TodoTests.cs) and [DemoTests](Demo/Test/DemoTests.cs).  \r\nUse the **Test Explorer** of your **IDE** to execute and debug these tests.\r\n\r\n\u003cbr/\u003e\u003cbr/\u003e\r\n\r\n\r\n\r\n# 🙏 Credits\r\n\r\n|                                                             |             |                                                                |\r\n| ----------------------------------------------------------- | ----------- | -------------------------------------------------------------- |\r\n| [NUnit](https://nunit.org/)                                 | C#          | used for unit testing of the Examples                          |\r\n| [Bogus](https://github.com/bchavez/Bogus)                   | C#          | to create Fake data by the DemoHub                             |\r\n| [.NET platform](https://dotnet.microsoft.com/en-us/)        | C# .NET     | the platform providing compiler, runtime, IDE's \u0026 ASP.NET      |\r\n| [Swagger](https://swagger.io/)                              | static JS   | a REST / OpenAPI UI linked  by the Hub Explorer                |\r\n| [GraphiQL](https://github.com/graphql/graphiql)             | static JS   | a GraphQL UI linked by the Hub Explorer                        |\r\n| [Mermaid](https://github.com/mermaid-js/mermaid)            | static JS   | class diagram for database schema linked by the Hub Explorer   |\r\n| [Monaco Editor](https://github.com/microsoft/monaco-editor) | static JS   | used as JSON Editor integrated in the Hub Explorer             |\r\n| [Inscape](https://gitlab.com/inkscape/inkscape)             | Application | to create SVG's for this project                               |\r\n\r\n\r\n\u003cbr/\u003e\r\n\r\n💖 *Like this project?*  \r\n*Leave a* ⭐ at  [friflo/Fliox.Examples](https://github.com/friflo/Fliox.Examples)\r\n\r\nHappy coding!  \r\n\r\n\u003cbr/\u003e\r\n\r\n## License\r\n\r\nThis demo project is licensed under MIT.  \r\nPublished project on GitHub 2022-08  \r\nCopyright © 2022   Ullrich Praetz\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriflo%2Ffliox.examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffriflo%2Ffliox.examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriflo%2Ffliox.examples/lists"}