GraphQlDemoPostgreSQL
This project demonstrates how to build GraphQL endpoints using .NET Core with PostgreSQL as the database. It is organized into several class libraries, each serving a distinct purpose within the application architecture. Below is an overview of each folder and its corresponding class library:
Folder Structure and Class Libraries
- Abstractions/GraphQlDemoPostgresQl.Abstractions
This class library defines the core interfaces and contracts used throughout the application. By centralizing these abstractions, the project promotes loose coupling and enhances testability.
๐น Key Components:
Interfaces: Define contracts for services, repositories, and other components.
DTOs (Data Transfer Objects): Represent data structures for communication between different layers.
- ApiModels/GraphQlDemoPostgresQl.ApiModels
This library contains models that represent the data structures exposed by the GraphQL API. These models are tailored for client interactions and may differ from the internal database models.
๐น Key Components:
GraphQL Types: Define the GraphQL object types, queries, mutations, and subscriptions.
Input Models: Represent the structure of inputs for GraphQL mutations.
- Common/GraphQlDemoPostgresQl.Common
This library provides common utilities, helpers, and constants used across the application. It ensures consistency and reduces redundancy. This also have a class which is created for RabbitMq.
๐น Key Components:
Extensions: Methods that extend existing classes with additional functionality.
Constants: Define application-wide constant values.
Helpers: Utility classes and methods for common tasks (e.g., logging, error handling).
- Core/GraphQlDemoPostgresQl.Core
This library encapsulates the business logic of the application. It implements the interfaces defined in the Abstractions project and contains the core functionalities.
๐น Key Components:
Services: Implement business operations and coordinate between repositories and API models.
Managers: Handle complex business rules and workflows.
- Database/GraphQlDemoPostgresQl.Database
This library is responsible for database interactions, including the Entity Framework Core (EF Core) DbContext and migrations.
๐น Key Components:
DbContext: Manages the database connection and is responsible for querying and saving data.
Migrations: Handle schema changes and versioning of the database.
- DatabaseModels/GraphQlDemoPostgresQl.DatabaseModels
This library contains the entity models that map directly to the database tables. These models are used by the DbContext to perform CRUD operations.
๐น Key Components:
Entities: Classes that represent the database tables and their relationships.
Configurations: Fluent API configurations for entity properties and relationships.
- This library contains a console application that consumes messages from RabbitMQ. It is designed to run parallel with GraphQlDemoPostgresQl.
๐น Key Components: RabbitMQ Consumer โ Listens for messages from the queue and processes them.
- GraphQlDemoPostgresQl (Main Application)
This is the main entry point of the application. It sets up the ASP.NET Core host, configures services, and defines the middleware pipeline.
๐น Key Components:
Startup.cs: Configures services and the application's request pipeline.
Program.cs: Contains the Main method, which is the entry point of the application.
Configuration Files: e.g., appsettings.json for application configuration settings.
By organizing the project into these distinct class libraries, the application achieves a modular structure that promotes maintainability, scalability, and clear separation of concerns.