We will not add load balancing features in this initial release to control complexity.
- Rust
- Rocket
- Rust (We recommend using rustup installer)
To install the gateway you need to run the following command in your terminal to build project:
cargo buildRun tests:
cargo testThen run the server:
cargo runTo trigger certain helpful actions when you update the code (like auto-restarting the server), install cargo-watch
cargo install cargo-watchThen run the following command to start a server that re-runs with every code change
cargo watch -x runYou can also re-run tests with every code change
cargo watch -x testBuild containers
docker compose -f docker-compose.dev.yml buildRun the builder to build the project
docker compose -f docker-compose.dev.yml run --rm builderRun the server
docker compose -f docker-compose.dev.yml run --rm runnerThe
serverauto-reloads if you run thebuilderand a new debug executable was created.
In this document, I will assume a basic level of Software Engineering and basic knowledge about the Software as a Service (SaaS) model.
UWS Software as a Service (SaaS) API Gateway is a system that does the following:
- Receives web requests from consumers.
- Authenticates and routes the requests to destination services.
- Charges customers according to their pricing plans.
We will not add load balancing features in this initial release to control complexity.
The system is comprised of the following structures:
- Server: authenticates & processes incoming requests.
- Data Layer: accesses, queries and persists data.
- Router: routes requests to their correct destination inside a private network using a configurable map.
- Authenticator: controls access of request consumers based on their credentials.
- Biller: Handles quota operations & subscriptions.
- Logger: collects traffic data and stores it in either files or databases.
- Scheduler: controls the flow of inbound and outbound requests.
The gateway will do its job successfully if the following conditions are met:
- The system functions well without errors according to spec.
- The system fulfills quality attributes.
The following quality attributes should be always taken into consideration while building the system:
- Performance: Speed is critical because the gateway will intercept each and every request passing through the system.
- Interoperability: Provided services should be discoverable and easy to communicate with.
- Maintainability: The code base should be clean, agile and well-tested. The system should be able to self-diagnose and handle common errors.
- Security: Stored customer data should be secured well. The system should always follow the basics of security.
Considering quality attributes is essential to deliver the desired customer and business value.
The request is the main artifact. A successful incoming request lifecycle is as follows:
- Server intercepts incoming request.
- Authenticator checks request for consumer login credentials & logs it.
- Biller checks subscriber quota.
- Router sends request to relevant service & responds to consumer.
- Biller adds transaction to the subscriber account.
In the case of internal errors or malformed responses from the service, information will be logged and quota will not be deducted.
The subscriber is representation of a customer or a partner business. A subscriber can have many Consumers. Consumers have access to the APIs and can consumer them once authenticated.
Subscribers can choose between different monthly or annual subscription packages, each package contains a monthly quota of tokens. Consuming services depletes this token quota.
Example: As a subscriber you have 10 token in your quota. Service A costs 2 tokens per request. Once you successfully hit Service A your quota will decrease to 8 token.
Consumers are the Subscribers' servers or machines. Usually operated by developers consumers will communicate with gateway using HTTP/HTTPS.
All requests from consumers should contain credentials that allows the system to detect and authenticate them.
Consumer history and activity are logged intensively in order to:
- Resolve conflicts
- Debug errors
- Finding patterns to help us improve the system.
The product is an abstract group of services. A product's role in the system is to add structure. In later versions this abstraction will contribute in the functionality of load balancing.
A service is a program hosted on an instance somewhere in our private network. Consumer can access this service using a URL.
Requests to certain services cost a different amount of tokens. AI processes for example cost more than simple graph API calls.
The gateway uses an updated map of all the services and how to reach them to process requests and respond to Consumers accordingly.
Each service has a version. Users can access different version of services using the following url scheme:
protocol://[product.slug].uws.io/[service.slug]/[service.version]/*

