Skip to content

Commit

Permalink
docs: adrs decisions (#22)
Browse files Browse the repository at this point in the history
* feat(adrs): decisions meeting 001

* chore: added bullet points

* chore(001): updated context text

* chore(001): updated name text

* feat(002): added adr for meeting 002

* feat: adr meeting 003 usage and billing

* feat: adr meeting 003 usage and billing

* feat: adr meeting 003 usage and billing

* feat: adr meeting 004 users

* chore: updated context meeting 001

* Update adrs/001-organization-payments.md

Co-authored-by: Felipe Gonzalez <[email protected]>

* Update adrs/001-organization-payments.md

Co-authored-by: Felipe Gonzalez <[email protected]>

* Update adrs/003-usage-billing.md

Co-authored-by: Felipe Gonzalez <[email protected]>

* Update adrs/003-usage-billing.md

Co-authored-by: Felipe Gonzalez <[email protected]>

---------

Co-authored-by: Felipe Gonzalez <[email protected]>
  • Loading branch information
paulobressan and gonzalezzfelipe authored Jul 10, 2024
1 parent 6c0328d commit 1a3a80d
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 0 deletions.
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 deprecated but the fabric will have support for it in legacy driven just for compatibility.

- Payments

Stripe 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 stripe will be linked to the project. In fabric, the Stripe integration will be into the payment driven where in the future new payment methods can be offered.
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 usage metrics of each user. Then, the main cluster will aggregate the data and make the invoice, integrating it with the payment gateway.

## 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
This 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.

- 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

0 comments on commit 1a3a80d

Please sign in to comment.