Skip to content

Commit

Permalink
feat: update project diagrams
Browse files Browse the repository at this point in the history
Signed-off-by: Mateusz Urbanek <mateusz.urbanek.98@gmail.com>
  • Loading branch information
shanduur committed Apr 5, 2024
1 parent ac89389 commit e45f8b5
Showing 1 changed file with 75 additions and 3 deletions.
78 changes: 75 additions & 3 deletions docs/projects/s3gw/s3gw.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# S3 Gateway

## Getting data from storage
The S3 Gateway is a service designed to interact with a storage system (likely an S3-compatible storage) and a PostgreSQL database. It facilitates operations such as retrieving data from storage and managing API keys for accessing the system.

## Flow

### Getting data from storage

This sequence diagram illustrates the process of a client requesting data from storage via the S3 Gateway. It involves the gateway checking if the provided API key is authorized to access the requested bucket, querying PostgreSQL for authorization, and retrieving the requested data from storage.

```mermaid
sequenceDiagram
Expand All @@ -17,7 +23,9 @@ sequenceDiagram
S3 Gateway-->>-Client: returns <data>
```

## Creating new API Key
### Creating new API Key

This sequence diagram demonstrates the process of a client requesting to create a new API key via the S3 Gateway. It involves the gateway generating and saving a new API token in the PostgreSQL database and returning the generated token to the client.

```mermaid
sequenceDiagram
Expand All @@ -29,4 +37,68 @@ sequenceDiagram
S3 Gateway->>+PostgreSQL: generate and save <API TOKEN>
PostgreSQL-->>-S3 Gateway: returns <API TOKEN>
S3 Gateway-->>-Client: returns <API TOKEN>
```
```

## Data

### Relations

This class diagram represents the database schema of the project. It includes the following entities:
- **Users**: Represents users of the system with attributes such as `user_id`, `username`, `password_hash`, and `created_at`.
- **API_Keys**: Represents API keys associated with users, including attributes such as `api_key_id`, `user_id`, `api_key_hash`, and `created_at`.
- **Buckets**: Represents storage buckets with attributes such as `bucket_id`, `bucket_name`, and `created_at`.
- **Objects**: Represents objects stored within buckets with attributes such as `object_id`, `bucket_id`, `object_version`, `object_key`, `object_data`, `object_data_checksum`, and `created_at`.
- **Authorisations**: Represents authorizations for accessing buckets with attributes such as `auth_id`, `api_key_id`, `bucket_id`, and `created_at`.

The relationships between these entities are depicted as follows:
- Users can have multiple API keys (`One [User] to Many [API_Keys]`).
- Users can be associated with multiple buckets, and buckets can be associated with multiple users (`Many [Users] to Many [Buckets]`).
- Each bucket can contain multiple objects (`One [Bucket] to Many [Objects]`).
- Each API key can have multiple authorizations (`One [API_Key] to Many [Authorizations]`).
- Many authorizations can be associated with one bucket (`Many [Authorizations] to One [Bucket]`).

```mermaid
classDiagram
class Users {
+uuid user_id: primary_key, autogenerated, unique
+string username: unique
+string password_hash
+timestamp created_at: autogenerated
}
class API_Keys {
+int api_key_id: primary_key, autogenerated, unique
+uuid user_id: foreign_key[Users]
+string api_key_hash: unique
+timestamp created_at: autogenerated
}
class Buckets {
+int bucket_id: primary_key, autogenerated, unique
+string bucket_name: unique
+timestamp created_at: autogenerated
}
class Objects {
+int object_id: primary_key, autogenerated, unique
+int bucket_id: foreign_key[Buckets]
+int object_version
+string object_key
+bytes object_data
+sha256 object_data_checksum
+timestamp created_at: autogenerated
}
class Authorisations {
+int auth_id: primary_key, autogenerated, unique
+int api_key_id: foreign_key[API_Keys]
+int bucket_id: foreign_key[Buckets]
+timestamp created_at: autogenerated
}
Users "1" <--> "N" API_Keys : "One [User] to Many [API_Keys]"
Users "N" <--> "N" Buckets : "Many [Users] to Many [Buckets]"
Buckets "1" <--> "N" Objects : "One [Bucket] to Many [Objects]"
API_Keys "1" <--> "N" Authorisations : "One [API_Key] to Many [Authorizations]"
Authorisations "N" <--> "1" Buckets : "Many [Authorization] to One [Bucket]"
```

0 comments on commit e45f8b5

Please sign in to comment.