Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adrs: all meeting decisions #22

Merged
merged 15 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions adrs/001-organization-payments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Organization and Payments

## Context

In the current Demeter platform, it is necessary to create an organization to link projects and users.

## Decision

- Organization

The organization will be degraded but the fabric will have support for it in legacy driven just for compatibility.
paulobressan marked this conversation as resolved.
Show resolved Hide resolved

- Payments

Strip integration will happen just when the user wants to upgrade the plan(tier), so the user will be redirected to a screen to set the payment and the strip will be linked to the project. In fabric, the Strip integration will be into the payment driven where in the future new payment methods can be offered.
paulobressan marked this conversation as resolved.
Show resolved Hide resolved
49 changes: 49 additions & 0 deletions adrs/002-stripe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Stripe

## Context

The way that the user can configure the payment method.

## Decision

- Payment Setup

Payment is associated to a project. One payment method per project. Stripe Intent will be defined in the user interface

- Flows

Sequence diagrams need to be created for each flow.

```
ACCOUNT
- A new project will be created by default
* account creation

PROJECT
- A default Stripe customer is created when the user create a project by default
* project creation
* project deletion
* project API key creation
* project API key deletion

PORT
* port creation
* port deletion
* port usage and details

TIERS
* tiers upgrade
* tiers downgrade

PAYMENTS
- Payment is associated to a project
- One payment method per project
- Stripe Intent will be defined in the user interface
* payment method updating
* payment method deletion
* payment transactions Webhook (stripe/ada)

USERS
* users invitation to a project
* users deletion from a project
```
29 changes: 29 additions & 0 deletions adrs/003-usage-billing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Usage and billing

## Context

Each cluster needs to send the metrics of usage of each user. Then, the main cluster will aggregate the data and make the invoice, integrating it with the payment gateway.
paulobressan marked this conversation as resolved.
Show resolved Hide resolved

## Decision

Each cluster will be running a usage driver to collect the usage data and send them as an event to the main cluster through the queue. In the main cluster, an event driver will be running and it will capture the event and persist in the cache db. The invoice will be triggered by another driver(billing) and it will be executed once a month, the payment gateway needs to be called to generate the invoice.

- Usage
That needs to be executed in each cluster and triggered once an hour, integrating with Prometheus to collect metrics of data usage and send an event to the queue.
paulobressan marked this conversation as resolved.
Show resolved Hide resolved

- Billing
The billing will be executed once a month in the main cluster, getting user usage in the cache of all clusters, and integrating with a payment gateway to make the invoice.

## Rules

- Usage driver(daemon)
- each cluster will run this driver and send report usage on Kafka periodically
- the cache driver will receive the event and persist the usage by cluster

- Billing driver(management/cron)
- it will execute one time per month to send an invoice
- it will use the usage in the cache to calculate the amount to billing
- Fetch all projects
- Fetch all ports of a project
- Fetch usage by port
- Integrate with payment gateway(send invoice)
30 changes: 30 additions & 0 deletions adrs/004-users.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Users

## Context

A new user needs to access demeter platform.

## Decision

The oauth platform will handle the authentication.

- Creation
The user needs to log in using the oauth. The oauth token will be sent to the user creation RPC and the user domain will validate the user data, integrating with oauth to get the user profile data and send an event to the queue creating the account.

- Invite
When a user invites another user to a `project`, a temporary token is created and sent to the new user's email. The new user will click on the link and if there's not an account, the user domain will create the account following the user creation flow. Then, an event is sent to link the new user to that project.

## Rules

- Users creation
- Users invitation to a project
- Invitation needs to be accepted
- Generation random token
- Integrate with AWS to send the email(Email driven)
- Send an invitation event
- Event driver will save the cache invitation event
- Users accept invite
- Validate the token getting from the cache
- Validate if the user exists
- Send an event to link the user to the project
- Users deletion from a project
Loading