|
| 1 | +# fx-expert Development Conventions |
| 2 | + |
| 3 | +## General |
| 4 | + |
| 5 | +- **Type Hints**: Use type hints wherever possible to improve code clarity and maintainability. |
| 6 | +- Code should be easy to read and understand. |
| 7 | +- Keep the code as simple as possible. Avoid unnecessary complexity. |
| 8 | +- Use meaningful names for variables, functions, etc. Names should reveal intent. |
| 9 | +- Function names should describe the action being performed. |
| 10 | +- Prefer fewer arguments in functions and methods. Ideally, aim for no more than two or three. |
| 11 | +- Only use comments when necessary, as they can become outdated. Instead, strive to make the code self-explanatory. |
| 12 | +- When commands are used, they should add useful information that is not readily apparent from the code itself. |
| 13 | +- Properly handle errors and exceptions to ensure the software's robustness. |
| 14 | +- Use exceptions rather than error codes for handling errors. |
| 15 | +- Consider security implications of the code. Implement security best practices to protect against vulnerabilities and attacks. |
| 16 | +- Use immutable types whenever possible. |
| 17 | +- When working with Pulumi, use Kubernetes and AWS. |
| 18 | +- When creating Kubernetes clusters, use AWS. |
| 19 | + |
| 20 | +## Package Information |
| 21 | + |
| 22 | +- [Marten Documentation](https://martendb.io/introduction.html) |
| 23 | +- [Wolverine](https://wolverinefx.net/guide/basics.html) |
| 24 | +- [Blazer](https://learn.microsoft.com/en-us/aspnet/core/?view=aspnetcore-9.0&WT.mc_id=dotnet-35129-website) |
| 25 | +- [MudBlazor](https://mudblazor.com/docs/overview) |
| 26 | +- [Google .Net Client Libraries](https://developers.google.com/api-client-library/dotnet) |
| 27 | +- [Stripe APIs](https://docs.stripe.com/api?lang=dotnet) |
| 28 | +- [Newtonsoft](https://www.newtonsoft.com/json/help/html/Introduction.htm) |
| 29 | + |
| 30 | +## Architecture |
| 31 | + |
| 32 | +This document presents the high-level architecture for the project, supporting a Partner-based system with additional features for **Users** and **Videoconferences**. The system manages **Partner profiles**, **User accounts**, and **Videoconference scheduling**, while leveraging **MartenDB** for event-sourcing and persistence and enabling deep integration with **CQRS**. A robust testing suite implemented in xUnit ensures system reliability. |
| 33 | + |
| 34 | +## Architectural Components |
| 35 | + |
| 36 | +### 1. EventServer |
| 37 | + |
| 38 | +- **Technology**: ASP.NET Core 9.0 |
| 39 | +- **Responsibility**: |
| 40 | + - Routes all incoming HTTP requests to their corresponding commands, queries, and business rules. |
| 41 | + - Events propagate to other components as necessary. |
| 42 | + - Offers RESTful Web APIs for interacting with Users, Partners, and Videoconferences. |
| 43 | + |
| 44 | +#### Key Responsibilities |
| 45 | + |
| 46 | +- Request validation via Middleware. |
| 47 | +- Publishing **Commands** (for state changes). |
| 48 | +- Executing **Queries** (for reading/viewing data). |
| 49 | +- Exposing endpoints for external applications: |
| 50 | + - `/api/partners` (Partners management). |
| 51 | + - `/api/users` (Users management). |
| 52 | + - `/api/videoconferences` (Videoconference scheduling). |
| 53 | + - `/api/payments` (payment processing) |
| 54 | + - `/api/calendar` (calendar management) |
| 55 | + |
| 56 | +#### Critical Modules |
| 57 | + |
| 58 | +- **Controllers**: For Partners, Users, and Videoconferences. |
| 59 | +- **Request Handlers**: Handle commands (`ICommand`) and queries (`IQuery`). |
| 60 | +- **Dependency Injection (DI)**: Binds service and repository dependencies. |
| 61 | + |
| 62 | +#### Key Aggregates |
| 63 | + |
| 64 | +- **Partner**: |
| 65 | + |
| 66 | + - Entity representing a partner in the system. |
| 67 | + - Attributes: `Bio`, `Skills`, `WorkHistory`, etc. |
| 68 | + - Supports commands such as `CreatePartner`, `UpdatePartner`, and `AddSkill`. |
| 69 | + |
| 70 | +- **User**: |
| 71 | + |
| 72 | + - Represents a participant in the system. |
| 73 | + - Attributes: `Email`, `Role` (e.g., Admin/Viewer), `Settings` (e.g., notification preferences). |
| 74 | + - Commands: `RegisterUser`, `AuthenticateUser`, and `UpdateUserSettings`. |
| 75 | + |
| 76 | +- **Videoconference**: |
| 77 | + |
| 78 | + - Handles **scheduling** between partners and/or users. |
| 79 | + - Attributes: `MeetingId`, `Participants`, `Time` (Start/End), `Details`. |
| 80 | + - Commands: `CreateVideoconference`, `CancelVideoconference`, `UpdateVideoconference`. |
| 81 | + |
| 82 | +- Payments: |
| 83 | + |
| 84 | + - Handles the authorization of payments via Stripe. |
| 85 | + - Handles the collection of payments via Stripe. |
| 86 | + - Handles cancelling a previously authorized payment (in case of cancellation of a videoconference). |
| 87 | + |
| 88 | +- Calendar: |
| 89 | + - Handles creating calendar events. |
| 90 | + - Handles getting calendar events. |
| 91 | + |
| 92 | +### Key Concepts |
| 93 | + |
| 94 | +- **Commands**: Represent the intent to **change system state**. |
| 95 | +- **Events**: Triggered as a result of commands, representing something that has happened in the system. |
| 96 | + |
| 97 | +### 2. Shared Types |
| 98 | + |
| 99 | +- **Technology**: C# (Domain-Driven Design and Event Sourcing principles applied) |
| 100 | +- **Responsibility**: |
| 101 | +- Houses the **Commands**, **Events**, and domain **Aggregates** (e.g., `Partner`, `User`, `Videoconference`) along with their business logic. |
| 102 | + |
| 103 | +### 3. fx-expert |
| 104 | + |
| 105 | +This is the UI and supporting services. The UI is implemented using Blazer, |
| 106 | +a framework for building web applications in .NET. |
| 107 | +The UI uses the **MudBlazor** component library for building user interfaces. |
| 108 | + |
| 109 | +#### Oauth |
| 110 | + |
| 111 | +Because the UI is using blazor WASM fx-expert utilizes the BFF (Backend for frontend) |
| 112 | +pattern for authentication. Basically the blazer frontend utilizes an exposed endpoint to |
| 113 | +get the access token from the BFF. The BFF then uses that token to validate the user. |
0 commit comments