This is the backend project for the Dressing Room
project.
backend
- The backend where the code lives.devops
- All relevent files for deployment and running the App on a server.docs
- Some documentation. (wip)resources
- Files that are relevant for documentation purpose and planning.
todo
todo
We've decided to use a Relational Database
(PostgreSQL). Why because it's fast, scalable and we are most comfortable with it.
- Store default
traits
(including Background, Fur, Mouth, Eyes, Hat, Clothes, Eyewear) withBear Number
(e.g. #7227) and correspondingpublic key
for each Bear (Primary key should bepublic key
) Public key
to fetch additional data from blockchain and keep attributes in sync (e.g. with cronjob)- Each Bear can have one TRAIT for each default CATEGORY
- Attributes consist of
image urls
(different sizes and formats for different use cases → download, frontend compositions), aunique id
(referenced in the image link), a name (e.g. yellow) and acategory id
(Primary key should beunique id
) - Each trait belongs to ONE category and can be assigned to x Bears
- Categories consist of a
name
, aweight
(to decide which category is added to the layer at what position) and aunique id
(Primary key should beuniqe id
)
In term of management, we’ll need a CMS that permits us to easily add/remove and edit Traits. Also do we want to have the option to approve from community members submitted traits before adding them to the Dressing Room.
v1
GitHub is a hosting service for software development and version control using Git. However, temporary, it can be 'misused' as Content Management System (CMS) for the first iteration of this (POC) backend. A central part of the GitHub are Pull Requests
and Issues
. Both of these functionalities come into play in the CMS.
Pull Requests
let you tell others about changes you've pushed to a branch in a repository on GitHub. This functionality can be used for the Trait image submission process. As soon as a user submits a new Trait, aPull Request
is opened by the backend (Github App) and an admin can check whether the suggested changes (the newly added image and chosen Category) are appropriate. If the Trait corresponds with the Guidelines, thePull Request
can be merged and the changes get applied by the backend. If the Trait doesn't fit, an admin can update/correct the provided changes or close thePull Request
. If thePull Request
is closed, the changes won't get applied.Issues
let you track your work on GitHub and can be seen as tasks. Issues are like Task Items a developer has to resolve. Thus, an Issue can be used to define tasks for the backend and not the developer has to resolve the task but the backend. For example, an admin creates a newIssue
with the Tagadd_category
and defines based on a predefined template the new Category. As soon as the Issue is submitted (e.g. via Tagapply
) the backend reads the specified information from the Issue and implements these changes.
By using Github we avoid implementing a custom authentication system as a Github Repository has integrated authentisation and admins can be granted the required managment rights. In the future we might design and build a custom CMS platform that purley serves the purpose of managing the Trait content.
The rate limit per hours is 5k
requests which is more than enough.
The Trait-Assets have to be accessable from the backend as well as from the frontend. The backend needs the capability to dynamically add, edit and remove Trait-Assets from the said storage.
v1
Github can also be temporarily misused as image host. However its very restricted in terms of scalability as it has a soft limit of 1GB
and hard limit of 5GB
overall storage capazity.
Thus its not the best option in the long run but the best option for the short run,
as its easy to setup and integrates with our CMS
system.
The max file size is 100MB
and the max repo size is 5GB. The only limiting facctor might be the max repo size as its not scalable. However it should be enough for now. If we assume each trait with the differen scaling factors requires 2MB
we could store 2500
Traits. The base Okay Bear collection has 171
Traits.
Ressources
We will built the backend plugin and play and have an Image Upload Handler
so we can easily swap the Image Hosting Provider in case we run into any issues. Here are some considerable alternatives:
- Google Drive
- AWS (not free)
-
Client-side data shaping + Navigating a relational Graph e.g. Frontend can decide whehter it only requires the Trait ID's of a Bear or all Trait Information already baked into the Response -> only one request instead of potential 2 as we would only return the Trait ID's via the REST API; Easier support for multipe display languages -> Frontend can decide what language the display name of a Trait should be
-
Auto documentation + Types for the Backend and Frontend. Wouldn't be a problem with REST either if we could've figured out how to generate Backend Types (Typescript) based on the created
Open API
file. In Spring Boot its easy but we decided to go with NodeJs + Express for simplicity as the majority devs knows how to write Typescript and can work on frontend and backend. -
Using REST for POST requests GraphQL is an awesome to dynamically query data but not really built around POST requests. For example sending formadata (for sending binary data) seems like to be easier with REST.
Ressources: