Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/International-Slackline-Association/Rankings-Backend
Server-side client of ISA Rankings (Serverless, NestJS, DynamoDB)
https://github.com/International-Slackline-Association/Rankings-Backend
aws-dynamodb dynamodb nestjs serverless serverless-framework serverless-offline typeorm
Last synced: about 1 month ago
JSON representation
Server-side client of ISA Rankings (Serverless, NestJS, DynamoDB)
- Host: GitHub
- URL: https://github.com/International-Slackline-Association/Rankings-Backend
- Owner: International-Slackline-Association
- License: gpl-3.0
- Created: 2018-06-08T12:05:21.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-01-10T14:41:13.000Z (11 months ago)
- Last Synced: 2024-08-01T15:35:55.255Z (4 months ago)
- Topics: aws-dynamodb, dynamodb, nestjs, serverless, serverless-framework, serverless-offline, typeorm
- Language: TypeScript
- Homepage: https://www.isa-rankings.org
- Size: 3.52 MB
- Stars: 174
- Watchers: 6
- Forks: 35
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-nestjs - Serverless-Lambda-DynamoDB - 具有 AWS Lambda,DynamoDB,DynamoDB Streams 的完全无服务器生产应用程序。 (资源)
- awesome-nestjs - Serverless-Lambda-DynamoDB - A fully SERVERLESS in-production application with AWS Lambda, DynamoDB, DynamoDB Streams. (Resources)
README
# Rankings-Backend
Server-side client of [isa-rankings.org]
**Technical Overview:**
- The server-side is entirely designed to be `serverless` on AWS.
- Requires knowledge on followings
- [Webpack]
- [NestJS]
- Typescript
- [Serverless Framework] (with [Serverless-Offline] plugin)
- AWS DynamoDB (main database)
- AWS DynamoDB Streams
- AWS Api Gateway
- AWS Lambda
- AWS CloudFormation (infrastructure as a code)
- AWS IAM Management (user, roles, policies)
- Redis (read through cache)---
### Why `serverless`?
- **Pay as you go:** You only pay for the resources you actively use, not when they are sitting idle. Perfect for low|inconsistent traffic applications.
- **Costs:** Extremely **cheap** . This application costs less than 1 dolar/month.
- **Maintenance & Operation:** You never manage infrastructure or any problem that comes with it. Only write the code and it works. Since its a volunteered project nobody wants to do anything but writing the application code---
## Architecture Overview
![Architecture]
---
## DynamoDB - (Database Design)
**DynamoDB is designed in such a way (primary keys and sort keys) so that it supports all the query patterns this application needs. It has only a single table with aggregated GSIs, hierarchical SKs.**
In short, it is customized for application's access patterns.
**_Overview of the table:_**
### Main Table
| PK | SK_GSI | LSI | GSI_SK | ...Attributes |
| ------------ | ---------------------------------------------------------- | -------------- | ---------------- | ------------- |
| Athlete:{id} | AthleteDetails | | {normalizedName} | ... |
| Athlete:{id} | Contest:{discipline}:{id} | Contest:{date} | {points} | ... |
| Athlete:{id} | Rankings:{type}:{year}:{discipline}:{gender}:{ageCategory} | | {points} | ... |
| Contests | Contest:{discipline}:{id} | Contest:{date} | | ... |**Possible Query Patterns:**
- Get details of athlete
- List contests of an athlete sorted by date
- Get a contest of an athlete
- Get a ranking of athlete
- Get details of a contest
- List details of contests sorted by date### GSI Table
| GSI | SK | PK | ...Attributes |
| --------------------------------------------------- | ---------------- | ------------ | ------------- |
| AthleteDetails | {normalizedName} | Athlete:{id} | ... |
| Contest:{discipline}:{id} | {points} | Athlete:{id} | ... |
| Rankings:{year}:{discipline}:{gender}:{ageCategory} | {points} | Athlete:{id} | ... |**Possible Query Patterns:**
- List details of athlete sorted by name
- List athletes of a contest sorted by points
- List athletes of a ranking sorted by points---
# Getting Started
To start with, serverless installation must be completed on your local comptuter.
How to: [Installation Guide](https://serverless.com/framework/docs/providers/aws/guide/installation/)
There are 2 environment stages, therefore you should have valid credentials for them. Checkout the `secrets.example.yml` under `serverless` folder.
Replace the values with real ones> For deployment `aws-cli` should be installed and configured with `Profiles` needed in the `serverless.yml` file. To get your credentials contact to ISA.
### Running on local
First, credentials are obtained from `.env` file. Replace the values in `.env.example` file with real ones depending on the stage you want to run (in `secrets.yml` you can see the stages)
Install dependencies
```shell
npm install
```Start serverless-offline
```shell
npm start
```API is served at `localhost:3000/`
### Project Folder Overview
[Gource] output
![GourceImage]
[nestjs]: https://github.com/nestjs/nest
[serverless-offline]: https://github.com/dherault/serverless-offline
[webpack]: https://webpack.js.org/
[dynamodb]: https://aws.amazon.com/dynamodb/
[serverless framework]: https://serverless.com/framework/docs/providers/aws/guide/quick-start/
[isa-rankings.org]: https://www.isa-rankings.org
[architecture]: docs/AWS_Architecture.png
[gource]: https://github.com/acaudwell/Gource
[gourceimage]: docs/GourceOutput.png