applyze_ecommerce
Applyze E-Commerce
Table of Contents
Summary
Directories | Description |
---|---|
Contexts | Database contexts are here. Currently MongoDB Context is here. |
Controllers | Default folder of MVC for Controllers. Controller Versions are seperated by folders like V1, V2 etc. |
Extensions | Includes Classes with Extension Methods. |
Exceptions | Includes Custom Exceptions to allow throwing exceptions handled situations in anywhere in app. |
Helpers | Includes helper class to make things easier. |
Middleware | Includes stuffs which handles and works for all requests. Like Auth., Exceptions etc. |
Models | Default folder of MVC for Models. Includes database models and service models. |
Repositories | Includes queries of database. It's an access layer to database. |
Services | Includes connections of services. It's an access layer to other services. Like Payment, Tenant etc. |
Middleware
Authorization
All requests to this API must have api-Key and app-key in header. These are handled in Middleware.Authenticator.
And it's configured on startup with app.UseAuthenticator();
in Configure()
method.
All Authorization parameters must be sent in Header!
Authentication
Authentication is provided by Applyze Tenant Microservice. Communication between services are providing by HTTP.
Services.Abstraction.ITenantService is called to connect Tenenat Service and this interface implemented to Services.Concrate.TenantService.
All proccess are handled in Middleware.Authenticator. After authentication, App
data added to HttpContext.Items, it can be used from anywhere until request finishes.
You need api-Key
and app-Key
to use service endpoints. Your credentials will be auhorized from Tenant Service.
While using this service all requests authenticated by app-Key and api-Key from header. All endpoints works for auhenticated app's data.
For Server;
[Authenticate] // < --- This endpoint requires authentication
public async Task<IActionResul> MyMethod()
{
//do something...
}
or
[Authenticate] // < --- Endpoints in this controller require authentication
public class MyController : BaseController
{
[AllowAnonymous] // < --- But this endpoint doesn't require any authentication
public async Task<IActionResul> MyMethod()
{
//do something...
}
}
From Client;
public async void MyMethod()
{
using(ver client = new HttpClient())
{
client.DefaultRequestHeaders.Add("api-Key","/QcOg8MuI4TZNT/eAIpLbicVqpGxkxz1YeqAilOOj4s=");
client.DefaultRequestHeaders.Add("app-Key","EzdOH/P7ASW0o7sf+KsNYFvh+3A=");
var response = await client.GetAsync();
//do your stuff...
}
}
Api Responses
Api responses all request with same sheme. You can see sheme with following block:
Message : Message about response.
IsUserFriendlyMessage : The message comes from resource or not
Key : key of Warning / Error.
Data : Result of request
Meta : Metadatat about Data. (Ex.: PaginationData for lists etc.)
Errors : Handled errors during request.
Services
Here includes communication layers to other Services.
Tenant Service
Tenant Service communication provided by TenantService via using ITenantService.
All requests are authorized by tenant service. All authorization required requests must contain api-Key
and app-Key
in header.
Payment Service
Payment service communication provided by PaymentService via using IPaymentService.
Repositories
Here includes access layers to database. There are 3 folders in here.
- Base
- Includes
Generic
BaseRepository and IBaseRepository which provides main CRUD process independent of model. Just inherit from this and CRUD process are ready to use.
- Includes
- Abstraction
- Here is for
Interfaces
of repositories. Interfaces are extracted to here from repositories.
- Here is for
- Concrete
- Includes concrete Repository
classes
.
- Includes concrete Repository