HealthHub connects patients with doctors, enabling online consultations, appointment scheduling, and access to medical records. Features include medication reminders, health monitoring, health tips and much much more.
This particular repository holds the backend code used to provide services to the client. It is written in C#
and makes use of ASP.NET
. The code segregation used for this project is MVCS
(Model-View-Controller-Service). This will be discussed more on the Folder Organization section. Understanding these things will help you navigate through the project with ease.
The set of technologies we utilized in this project:
- Programming Language:
- Backend Framework:
- Authentication & Authorization:
- Object Relational Mapping:
- Database Engine:
- Logging:
- Testing Framework:
- API Testing:
- API Documentation:
- Templating:
└── 📁Migrations
└── 📁Requests
└── 📁Source
└── 📁Attributes
└── 📁Config
└── 📁Controllers
└── 📁Data
└── 📁Filters
└── 📁Helpers
└── 📁Defaults
└── 📁Extensions
└── 📁Hubs
└── 📁Middlewares
└── 📁Models
└── 📁Dtos
└── 📁Entities
└── 📁Enums
└── 📁Interfaces
└── 📁Responses
└── 📁ViewModels
└── 📁Services
└── 📁Validation
└── 📁Views
└── 📁Tests
Program.cs
└── 📁Migrations
> This folder automatically stores the database model migrations when you run the `dotnet ef migrations add` command.
└── 📁Requests
> Contains REST client HTTP API tests for the completed endpoints.
└── 📁Source
└── 📁Attributes
> Contains custom attributes used to validate incoming request payloads.
└── 📁Config
> Stores application configuration settings, like app settings and environment variables.
└── 📁Controllers
> Contains API controllers that map client requests to the appropriate services.
└── 📁Data
> Contains data-related code, such as the `DbContext`, which manages database connections and operations.
└── 📁Filters
> Stores Action Filters that help intercept and modify requests/responses before they reach the controller or after processing.
└── 📁Helpers
└── 📁Defaults
> Contains default values and constants used across the application.
└── 📁Extensions
> Stores extension methods for common functionality, such as mapping between DTOs and database models.
└── 📁Hubs
> Contains SignalR hubs that handle WebSocket requests. For example, hubs for chat, notifications, etc.
└── 📁Middlewares
> Contains middlewares that intercept the request/response life cycle to modify or handle data as needed.
└── 📁Models
└── 📁Dtos
> Stores Data Transfer Objects (DTOs) that represent only the necessary fields for request/response payloads.
└── 📁Entities
> Contains database models, such as User, Doctor, and Patient.
└── 📁Enums
> Stores Enums used throughout the application.
└── 📁Interfaces
> Contains interface definitions for core services like Payment and Chat.
└── 📁Responses
> Stores response models, typically used as return types from controllers to ensure consistent response formats.
└── 📁ViewModels
> Contains view models that bind data to views. This may also be used for email templates or payment pages, as this is a backend-focused project.
└── 📁Services
> This is the core of the project. It contains service classes that handle business logic, interact with the database, and enforce rules.
└── 📁Validation
> Stores Fluent Validation classes for validating request payloads with fine-grained control.
└── 📁Views
> Stores view templates, if needed, though this is more backend-focused, so views may be limited to things like emails or invoices.
Application related configurations are found in Source/Config
folder. One such configuration is AppConfig.cs
- which is responsible for making environment variables easily accessible throughout our codebase.
Dont Forget to add appropriate mapping from your .env
file to this configuration class.
Example:
- Lets say you have such environment variable. Inside
.env
:
DB_CONNECTION=SOME_CONNECTION_STRING_GOES_HERE
- To use this
DB_CONNECTION
you should add the following toAppConfig.cs
:
public class AppConfig(IConfiguration configuration){
// Add it here
public string? DatabaseConnection { get; set; } = configuration["DB_CONNECTION"];
}
- You can make use of this
AppConfig
from other services through DI.
public class SomeService(AppConfig appconfig){
public void DoSomething(){
var dbConn = appConfig.DatabaseConnection; // You have access here!
}
}
- Create a Chapa account
- Goto Profile > Settings > Webhooks:
- Enter the following input fields
Webhook Url = YOUR_WEBHOOK_URL
Secret Hash = YOUR_SECRET_HASH
- Then enable the checkboxes for Receive Webhook and Receive Webhook for failed Payments.
Side Note: Make sure you have configured the
WEBHOOK_SECRET
in the environment variables and its the same as the one you entered above for the field Secret Hash. Make sure your secret hash is at least 32 characters for security reasons. You can use this free tool here.
- Goto your chapa dashboard and on the Profile > Settings > Account Settings. Enter the input fields for Callback Url and Success Url
Callback Url = API_ORIGIN/api/payments/chapa/callback
Success Url = API_ORIGIN/api/payments/chapa/success
Side Note:
API_ORIGIN
is configured inside the.env
file. Make sure you set it up in the project!
If you intend to change the endpoints shown above please make sure to edit the PaymentController.cs
to match your preferred endpoint.
- Head to Auth0 and Create an application.
- Click on the newly created app and navigate to Settings tab
- Under the basic information section copy the Client ID and Client Secret and paste it into the
.env
file accordingly - Under Application URIs Section add the urls you want to allow. One such url you must add is
API_ORIGIN/api/auth/callback
, API_ORIGIN being the host url found inenv
as we've discussed before. - Under Cross-Origin Authentication enable Allow Cross-Origin Authentication
- Navigate to Connections tab and enable Username-Password-Authentication and google-oauth2
- Clone the repo
git clone https://github.com/yordanos-bogale5/HealthHub-Backend.git
- Install all dependencies
dotnet restore
- Copy contents from
.env.example
to.env
and configure accordingly.
.env.example > .env
- Start the ASP Server (Development)
dotnet watch run
We welcome contributions to this project! To get started, please follow these guidelines:
- Fork the repository: Click the "Fork" button at the top right of this page to create your own copy of the repository.
- Clone your fork: Clone the forked repository to your local machine.
git clone https://github.com/your-username/your-repository.git
- Create a new branch: Create a new branch for your feature or bugfix.
git checkout -b feature/your-feature
- Make your changes: Implement your feature or fix the bug. Ensure your code adheres to the project's coding standards and style.
- Commit your changes: Commit your changes with a descriptive message.
git add . git commit -m 'Add new feature or fix bug'
- Push your branch: Push your branch to your forked repository.
git push origin feature/your-feature
- Create a Pull Request: Go to the repository on GitHub, switch to your branch, and click the
New Pull Request
button. Provide a detailed description of your changes and submit the pull request.
-
Bug Reports: If you find a bug, please open an issue in the repository with details about the problem.
-
Feature Requests: If you have ideas for new features, feel free to open an issue or submit a pull request.
This project is licensed under the MIT License
The MIT License is a permissive free software license originating at the Massachusetts Institute of Technology (MIT). It is a simple and easy-to-understand license that places very few restrictions on reuse, making it a popular choice for open source projects.
By using this project, you agree to include the original copyright notice and permission notice in any copies or substantial portions of the software.