How pinzi/getui-pushapi-netcoresdk-v2 works
Main Components
• Client Applications & Sample Code: Represented by the “Sample” projects (e.g., Core.Sample.Net6, Core.Sample.Net7) that demonstrate how to consume the SDK.
• API Layer: The GeTuiPushApiV2.NetCoreSDK.Core.Api project contains the REST API call wrappers (e.g., Auth, Push, Report, User). These components essentially form the gateway to the external GeTui REST service.
• Core Business Logic: The GeTuiPushApiV2.NetCoreSDK.Core project handles common DTOs, utility functions (SHA256Helper, HTTP helper) and encapsulates push service logic.
• Service Layer: Within the Core project you have the “Service” subdirectories (Auth, Push, Report, User) that implement the business logic for authenticating, pushing messages, and handling user-related operations.
• Storage & Caching: Separate modules (MemoryCache, Redis and Storage) abstract caching and persistent storage of tokens, user identifiers, etc.
• Dependency Injection (IOC): The GeTuiPushApiV2.NetCoreSDK.Core.IOC project and associated ServiceCollectionExtensions manage IOC registration and plug in custom implementations (like alternate Redis clients).
• Utility Library: Contains helper methods for common operations (e.g., HTTP requests and cryptographic operations).
Relationships and Data Flow
• The client (which might call through one of the three calling mechanisms) first uses the API layer to perform authentication by invoking the “Auth” API. This response is then cached using either Redis or MemoryCache (via the Storage component).
• Once a token is obtained and cached, the client calls one of the Push or User-related API methods (such as single push, list push or alias binding).
• The Service layer leverages these APIs, coordinating the proper sequence of calls (e.g., token retrieval, then message pushing) and routing requests, based on conditions (is it a “direct API” call or an IOC-managed push call).
• Dependency injection is used to wire together implementations of IStorage, IRedis, and concrete services (for example, GeTuiPushService).
Design Patterns & Architectural Strategies
• Abstraction and Encapsulation: The SDK wraps the raw HTTP calls in higher-level API methods; internal classes hide details such as caching and token refresh.
• Separation of Concerns: Distinct projects for API communication, business logic (core), service orchestration, storage/caching, and IOC registration.
• Pluggable Storage Mechanism: Multiple implementations of IStorage (via Redis or in-memory cache) are available and can be configured through StorageType.
• IOC/DI Pattern: The SDK supports both direct service instantiation and IOC registration for integration with developer applications.
Relevant Technologies and Frameworks
• .NET Core 6/7: Underlying runtime specification.
• StackExchange.Redis: Default Redis client for caching.
• HTTP Clients: For communication with GeTui REST API endpoints.
• Common NuGet Tools: Including utility packages for cryptography (SHA256) and JSON handling (Newtonsoft.Json).
Elements
• Nodes for each major component:
• "Client / Sample Applications"
• "Authentication API" (Auth layer under Core.Api)
• "Push APIs" (different methods under API / Service)
• "User Management APIs"
• "Core Business Logic & DTOs"
• "Storage/Caching Layer" (MemoryCache, Redis)
• "IOC / Dependency Injection Container"
• "External GeTui REST Service" (to show external dependency)
• Client calls the "Authentication API" to get a token.
• Token stored in the "Storage/Caching Layer".
• Push Service retrieves token and then calls "Push APIs".
• Similar patterns for User APIs where alias binding or tag management occurs.
Detail and Clarity
• Keep labels descriptive (e.g., “GeTuiPushV2Api – API Wrapper”, “GeTuiPushService – Message Orchestration”, “IStorage (Redis/MemoryCache) – Caching Storage”).
• Every dependency and interaction is clearly drawn.
• On the fact that there are multiple entry points (direct HTTP calls versus IOC-managed services), and include notes or sub-components that show these alternate flows.