REST API Server for Japanese Exposure Notification App to fight against COVID-19 a.k.a. "まもりあい Japan".
- Architecture
- Technology Stack
- Getting Started
- Development Guideline
- Demo
- Test Reports
- Contact
- Contributing
- Code of Conduct
- License
The images made by Miro (read only access).
- Runtime Environment: Node.js 12.16.2
- Package Manager: npm 6.14.4
- Programming Language Processor: TypeScript 3.8.3
- Web Application Framework: Nest 7.0.7
- Amazon Route 53
- Amazon API Gateway
- AWS Lambda
- AWS Systems Manager
- Serverless Framework (to manage and deploy)
- Firebase Authentication
- Cloud Firestore
- Cloud Storage
npm install
Make sure you add the env vars in .env
file. Just copy the .env.template
file.
# Used by serverless framework to deploy to AWS Lambda.
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
# Used by Firebase Admin SDK. Obtained via serviceAccount.json file in Firebase Console.
FIREBASE_type
FIREBASE_project_id
FIREBASE_private_key_id
FIREBASE_private_key
FIREBASE_client_email
FIREBASE_client_id
FIREBASE_auth_uri
FIREBASE_token_uri
FIREBASE_auth_provider_x509_cert_url
FIREBASE_client_x509_cert_url
# Used for getting Firebase Token via Custom token in e2e tests. Obtained in Firebase Console.
FIREBASE_WEB_API_KEY
And then execute:
# development mode
npm run start
# watch mode
npm run start:dev
# serverless offline mode
npm run sls-offline
# production mode
npm run start:prod
# unit tests
npm run test
# end-to-end tests
npm run test:e2e
# get the test coverage
npm run test:cov
# deploy to DEV environment
npm run deploy:dev
.
├── .env (Make sure to create this file locally and fill the env vars)
├── src
│ ├── main.ts (This entry point is used for local server)
│ ├── lambda-main.ts (This entry point is used for lambda server)
│ ├── auth (module)
│ │ ├── guards
│ │ └── strategies (Implementation of Firebase Auth access token check)
│ ├── users (module)
│ │ ├── users.controller.ts (Controllers call their services)
│ │ ├── users.service.ts (Services can call other services and their own repository)
│ │ └── user.repository.ts (Repository should be called only by its parent service)
│ └── shared (module with shared business logic)
├── test (Contains the end-to-end (e2e) tests)
├── fdt-generator-webapp (Optional web app to generate firebase access tokens for testing)
└── serverless.yml (Serverless framework config file for infrastructure deployment)
As mentioned briefly in the project layout for users
, to keep layout clean, we follow this convention:
- Controllers: HTTP routes map to handler functions in controllers.
- Services: Controllers call their service function.
A) Auser controller
must call only auser service
, and not any other service if it can be avoided.
B) Auser service
can call other services likecats service
, etc.
C) Auser service
must call only auser repository
, and not any other repository if it can be avoided. If auser service
wants to modify data incats repository
, it must call correspondingcats service
funtion to do it. - Repositories: Repositories have data layer implementation, ex:
Firestore
in this project. They must be called only by their direct parent service, ex: Auser repository
is called by auser service
.
- Swagger UI: https://api-demo.mamori-i.jp/swagger
Bug reports and pull requests are welcome on GitHub at https://github.com/mamori-i-japan/mamori-i-japan-api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
Everyone interacting in the mamori-i-japan-api project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
The app is available as open source under the terms of the 2-Clause BSD License.
Links to some external articles and blog posts that talk about the backend in more detail.
In Japanese language (日本語で):
- Mamoriai Japan Official - まもりあい JAPAN 公式
- Takuya Kawatsu - Overall design of the application
- Daisuke Hirata - Development story
In English:
- Yash Murty - Backend for Japan's Contact Tracing App