GithubHelp home page GithubHelp logo

athna / mamori-i-japan-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mamori-i-japan/mamori-i-japan-api

0.0 1.0 0.0 3.2 MB

REST API Server for Japanese Exposure Notification App to fight against COVID-19 a.k.a. "まもりあいJAPAN".

License: BSD 2-Clause "Simplified" License

JavaScript 0.47% TypeScript 73.03% HTML 26.50%

mamori-i-japan-api's Introduction

mamori-i-japan-api

Build Status Version License

REST API Server for Japanese Exposure Notification App to fight against COVID-19 a.k.a. "まもりあい Japan".

Table of Contents

  1. Architecture
  2. Technology Stack
  3. Getting Started
  4. Development Guideline
  5. Demo
  6. Test Reports
  7. Contact
  8. Contributing
  9. Code of Conduct
  10. License

Architecture

Overview and Data Flow Diagram

Overview

Data Flow Diagram

The images made by Miro (read only access).

Technology Stack

Application

Hosting

Amazon Web Services

  • Amazon Route 53
  • Amazon API Gateway
  • AWS Lambda
  • AWS Systems Manager
  • Serverless Framework (to manage and deploy)

Firebase

  • Firebase Authentication
  • Cloud Firestore
  • Cloud Storage

Getting Started

Installation

npm install

Running the Application on Local

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

Testing

# unit tests
npm run test

# end-to-end tests
npm run test:e2e

# get the test coverage
npm run test:cov

Deployment

# deploy to DEV environment
npm run deploy:dev

Development Guideline

Project Layout (Brief Explanation)

.
├── .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 (Repositroy 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:

  1. Controllers: HTTP routes map to handler functions in controllers.
  2. Services: Controllers call their service function.
    A) A user controller must call only a user service, and not any other service if it can be avoided.
    B) A user service can call other services like cats service, etc.
    C) A user service must call only a user repository, and not any other repository if it can be avoided. If a user service wants to modify data in cats repository, it must call corresponding cats service funtion to do it.
  3. Repositories: Repositories have data layer implementation, ex: Firestore in this project. They must be called only by their direct parent service, ex: A user repository is called by a user service.

Demo

Test Reports

Contact

Contributing

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.

Contributors

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.

License

The app is available as open source under the terms of the 2-Clause BSD License.

External links/posts

Links to some external articles and blog posts that talk about the backend in more detail.

In Japanese language (日本語で):

In English:

mamori-i-japan-api's People

Contributors

yashmurty avatar shogo-mitomo avatar daisukehirata avatar daisuke-fukuda avatar tbnv999 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.