Skip to content

Ghufran496/SGJ-CONSENT-DOTNET-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SGJ Consent Management API

Overview

The SGJ Consent Management API is a comprehensive .NET-based solution designed for Sagicor Group Jamaica Limited to manage various types of client consents, including data sharing consents, marketing consents, and data controller enrollments. This API provides a robust framework for tracking, managing, and validating consent operations in compliance with data privacy regulations.

Technology Stack

  • Framework: .NET 8.0
  • Architecture: Clean Architecture with CQRS pattern (Command Query Responsibility Segregation)
  • API Design: RESTful API with OpenAPI/Swagger documentation
  • Database: Microsoft SQL Server with Entity Framework Core
  • Authentication/Authorization: JWT-based authentication
  • Messaging Pattern: Mediator pattern using MediatR
  • Service Discovery: Consul integration
  • Monitoring: Application Insights, Grafana, InfluxDB, Telegraf
  • Containerization: Docker support with multi-stage builds
  • Testing: xUnit for unit and integration tests
  • Code Quality: SonarQube integration
  • Deployment: Kubernetes (AKS) support

Core Features

  • Data Sharing Consent Management: Create, retrieve, update, and withdraw data sharing consents between entities
  • Marketing Consent Management: Manage marketing preferences and consent for clients
  • Data Controller Enrollment: Register and manage data controllers
  • Entity Management: Track and manage entities involved in consent operations
  • Client Management: Client registration and identification
  • Audit Trail: Comprehensive tracking of all consent-related operations
  • API Versioning: Support for API versioning to maintain backward compatibility

Project Structure

The project follows Clean Architecture principles with the following layers:

  • Api: API controllers, middleware, and configuration
  • Api.Application: Application services, commands, queries, and handlers (CQRS implementation)
  • Api.Domain: Domain entities, repositories interfaces, and domain services
  • Api.Infrastructure: Database context, repository implementations, migrations, and external service integrations
  • Api.Crosscutting: Shared components, enums, constants, and error handling
  • Api.Dto: Data transfer objects for API requests and responses
  • Api.Test: Unit and integration tests

Getting Started

Development Environment Setup

To start the application in development mode:

dotnet run --verbosity normal --project ./src/Api/Api.csproj

Database Migrations

After creating a new entity, add a DbSet<E> entry in ApplicationDatabaseContext for migrations to work.

Create the initial migration:

dotnet ef migrations add InitialCreate --project src/Api.Infrastructure/Api.Infrastructure.csproj --startup-project src/Api/Api.csproj

Add a new migration:

dotnet ef migrations add NameOfNewMigrationHere --project src/Api.Infrastructure/Api.Infrastructure.csproj --startup-project src/Api/Api.csproj

Apply database migrations:

dotnet ef database update --project src/Api.Infrastructure/Api.Infrastructure.csproj --startup-project src/Api/Api.csproj

Generate migration scripts:

dotnet ef migrations script --project src/Api.Infrastructure/Api.Infrastructure.csproj --startup-project src/Api/Api.csproj -o 0000-migration.sql

Building for Production

To build the artifacts and optimize the application for production:

cd ./src/Api
rm -rf ./src/Api/wwwroot
dotnet publish --verbosity normal -c Release -o ./app/out ./Api.csproj

The ./src/Api/app/out directory will contain your application DLL and its dependencies.

Docker Support

Build a Docker image:

docker build -f ./Dockerfile -t consent-api .

Run the Docker container:

docker run -p 8080:8080 consent-api

Or use Docker Compose:

docker compose -f ./docker/app.yml build
docker compose -f ./docker/app.yml up

Testing

Run tests:

dotnet test --verbosity normal

Code Quality

Code Formatting

Format the .NET code:

dotnet format

SonarQube Analysis

Run SonarQube in a container:

docker compose -f ./docker/sonar.yml up -d

Then run the analysis script:

./SonarAnalysis.ps1

Visit http://localhost:9001 to view the results.

Monitoring

Set up monitoring:

docker compose -f ./docker/monitoring.yml up -d

Access Grafana at http://localhost:3000

Kubernetes Deployment

The project includes Kubernetes deployment configurations in the aks-deployment directory for deploying to Azure Kubernetes Service (AKS).

API Documentation

The API is documented using OpenAPI/Swagger. When running the application, access the Swagger UI at /swagger endpoint to explore and test the API endpoints.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages