diff --git a/adrs/001-organization-payments.md b/adrs/001-organization-payments.md new file mode 100644 index 0000000..df3a50a --- /dev/null +++ b/adrs/001-organization-payments.md @@ -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. diff --git a/adrs/002-stripe.md b/adrs/002-stripe.md new file mode 100644 index 0000000..8b70624 --- /dev/null +++ b/adrs/002-stripe.md @@ -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 +``` diff --git a/adrs/003-usage-billing.md b/adrs/003-usage-billing.md new file mode 100644 index 0000000..10fc33b --- /dev/null +++ b/adrs/003-usage-billing.md @@ -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) diff --git a/adrs/004-users.md b/adrs/004-users.md new file mode 100644 index 0000000..9b461b6 --- /dev/null +++ b/adrs/004-users.md @@ -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