npm package: @fathomtech/lingualist-dynamo-utils
Description: This project contains the DynamoDB arterfacts used by Fathom lingualist
Author: John Mc Quillan
Latest version: 0.1.5

# Lingualist Dynamo DB Artefacts

This project contains a library to access the DynamoDB database used by Fathom's
Translations Manager, Lingualist. The project also contains infrastructure as code
(terraform) to create various AWS `dynanmodb` artefacts used in the project.
The principles of `Single Table Design` are used in this project.

## Features Outline

This section outlines the initial product outline and features.

- Project - The product works with the concept of projects. The initial implementation will allow all users to have full access to all projects.
Projects often correspond to a particular product and each project is entirely distinct.
    - Settings - The project settings will support the following features:-
        - Selection of the langages to be used in this project
        - Selection of a primary language - other languages will be translations of the primary for machine translation purposes
        - Creation of translation groups

- Group - Groups are used to make it easier to manage translations and to make it easier to re-use a translation in multiple places in a product.
Translations can be included in multiple groups (e.g. "Client App", "Admin App").

- Translation - A translation will consist of a translation key and Unicode translations for each language enabled for the project.
    - Machine translation will be supported as an option - clicking an auto-translate button will result in a cloud service (e.g. AWS) being called to provide a machine translation from the `primary` language to the chosen language.
    - Manual translations can overwrite the machine translation
    - overwriting manual translations with auto-translations will ask for confirmation

- Translation File Generation - The product store for the translations will be in the cloud. Translation files for use by product will be generated on request. The generated files will be in JSON format, suitable for use with products like `i18n`. There will be one file created project`group` and they will be zipped for download.

## Table Design

AWS's DynamoDB service is used as the data store for this project. The principles of `Single Table Design` are used.

### Entity Relationships
```mermaid
erDiagram
    Users ||--o{ Projects : owns
    Projects ||--o{ Groups : contains
    Groups ||--|{ Translations : contains
    Translations }|..|{ Language : uses
```

### Entity Chart

| Entity           | PK                          | SK
| ---------------- | --------------------------- | ----------------------------
| User             | USER#\<UserId>              | USER#\<UserId>
| Project          | USER#\<UserId>              | PROJ#\<ProjName>
| Group            | N/A
| Translation      | PROJ#\<UserId>#\<ProjId>    | TRKEY#\<TranslationKey>
| Language         |

NB - Groups will be represented as attribute (List) in both Project and Translation.
Project will include all possible group names for that project. Translation will include
the group names that use that particular translation.

### Additional Attributes

| Entity      | Type    | DefaultProject | DefaultProjectId 
| ----------- | ------- | -------------- | ----------------
| User        | user    | \<ProjName>     | \<ProjId>             

| Entity      | Type    | ProjectId      |
| ----------- | ------- | -------------- |
| Project     | proj    | \<ProjId>       |

| Entity      | Type    | trkey            | \<langId>   | ..... | \<langId>   |
| ----------- | ------- | ---------------- | ---------- | ----- | ---------- |
| Translation | trans   | \<TranslationKey> | \<Lang Str> |       | \<Lang Str> |

### Access Patterns
#### User Basics
- Get / Create User
- Edit User Settings

#### Project Basics
- Get / Create Project
- Edit Project Settings

#### Translation Basics
- Create Translation
- Get Project Translations (Will include project meta data at start)