Skip to content

This app facilitates work-from-office requests and confirmations for companies under Covid-19 safety protocols. Built using microservice architecture and containerized REST and gRPC services in Go.

License

Notifications You must be signed in to change notification settings

szczynk/grpc-micro-safety

Repository files navigation

grpc-micro-safety

Logo

New Normal Safety

Tracking App Under New Normal Covid 19 Safety Protocol


Table of Contents

  1. Description
  2. Installation
  3. Services
  4. Entity Relation Diagram
  5. High Level Architecture Diagram
  6. Features
  7. API Scopes
  8. Contact

Description

Welcome to Work-From-Office Request and Confirmation App!

This application is designed to facilitate work-from-office (WFO) requests and confirmations for companies operating under new normal Covid-19 safety protocols. It was developed to help employees stay connected with their colleagues and maintain a sense of community while adhering to new safety guidelines.

This repository was created as a learning resource for building backend applications using microservice architecture and containerized REST and gRPC services written in Go. During the development of this application, a number of challenges were encountered, such as implementing queries that join data across multiple databases and enforcing Role-Based Access Control (RBAC) in distributed services. These challenges were addressed through careful design and development, and the resulting application serves as an excellent example of how to implement a robust and scalable backend architecture.

(back to top)

Installation

Clone the repository

git clone https://github.com/szczynk/grpc-micro-safety.git

You should have Docker installed beforehand.

.env.example is included on every services and main folder if you want to change env.

For default env, you just need to execute docker-compose command in the Makefile

Local development experience

To create and start required containers

docker-compose -f docker-compose.local.yml up -d

Then start every services

cd grpc-gateway && make run
cd auth && make run
cd user && make run
cd mail && make run
cd safety && make run

Open the following url in the browser for API documentation (development env)

http://localhost:5000/swagger-ui/

if you done then stop every services and remove containers by using

docker-compose -f docker-compose.local.yml down

and ctrl-c

Full docker experience

To create and start required containers

docker-compose up -d

That's great. Now we can use the backend at

http://localhost:5000

Open the following url in the browser for API documentation (development env)

http://localhost:5000/swagger-ui/

if you done then stop and remove containers by using

docker-compose down

For default admin credential

Username: [email protected]
Password: admin123

(back to top)

Services

Assuming in development env. Below are list of services:

(back to top)

Features

(back to top)

Entity Relation Diagram

Entity Relation Diagram for this app shown in the picture below erd

(back to top)

High Level Architecture Diagram

High Level Architecture Diagram for this app shown in the picture below hld

(back to top)

API Scopes

Auth

Method Endpoint Path Param Query Param Request Body JWT Token Role Fungsi
POST /auth/register - - username, email, password No user Register a new user
POST /auth/login - - email, password No user, admin login user and get access token & refresh token
GET /auth/verify-email/ code - - No user, admin Verify user's email by email
POST /auth/forgot-password - - email No user, admin Send reset password token by email
POST /auth/reset-password resetToken - password No user, admin Reset Password using reset token

(back to top)

Users

Method Endpoint Path Param Query Param Request Body JWT Token Role Fungsi
GET /auth/me - - - Yes user, admin Get user's profile data that is currently logged in
PATCH /auth/me - - username, avatar Yes user, admin update user's profile data
POST /auth/change-email - - email Yes user, admin change user's email
POST /auth/refresh-token - - refreshToken Yes user, admin Renew access token
POST /auth/logout - - refreshToken Yes user, admin Logout and delete refresh token
GET /users - username, email, role, verified, page, limit, sort - Yes admin Find lisf of users
POST /users - - username, email, password, role, avatar, verified Yes admin Create a new user by admin
GET /users/ id - - Yes admin Find user by user's id
PATCH /users/ id - username, email, password, role, avatar, verified Yes admin Edit user's data by user's id
DELETE /users/ id - - Yes admin Delete a user by user's id

(back to top)

Offices

Method Endpoint Path Param Query Param Request Body JWT Token Role Fungsi
GET /offices - name, detail, page, limit, sort - Yes user, admin Find list of offices
POST /offices - - name, detail Yes admin Create a new office by admin
GET /offices/ id - - Yes user, admin Find office by office's id
PATCH /offices/ id - name, detail Yes admin Edit office's data by office's id
DELETE /offices/ id - - Yes admin Delete a office by office's id

(back to top)

Workspaces

Method Endpoint Path Param Query Param Request Body JWT Token Role Fungsi
GET /workspaces - username, email, role, verified, page, limit, sort - Yes admin Find list of users in the office
POST /workspaces - - officeId, userId Yes admin Insert a user into the office
DELETE /workspaces/ userId - - Yes admin Delete a user in the office by user's id

(back to top)

Schedules

Method Endpoint Path Param Query Param Request Body JWT Token Role Fungsi
GET /schedules - officeId, month, year, page, limit, sort - Yes user, admin Find list of schedules for WFO
POST /schedules - - officeId, totalCapacity, month, year Yes admin Create a new schedule for a month by admin
GET /schedules/ id - - Yes user, admin Find schedule by schedule's id
PATCH /schedules/ id - totalCapacity Yes admin Edit schedule's total capacity by schedule's id
DELETE /schedules/ id - - Yes admin Delete a schedule by schedule's id

(back to top)

Certificates

Method Endpoint Path Param Query Param Request Body JWT Token Role Fungsi
GET /certificates - userId, status, page, limit, sort - Yes user, admin Find list of user's vaccine certificates
POST /certificates - - userId, dose, description, imageUrl Yes user, admin Insert a vaccince certificate by user
GET /certificates/ id - - Yes user, admin Find certificate by certificate's id
PATCH /certificates/ id - description, imageUrl, adminUsername, status, statusInfo Yes user, admin Edit certificate's data by certificate's id
DELETE /certificates/ id - - Yes admin Delete a certificate by certificate's id

(back to top)

Attendances

Method Endpoint Path Param Query Param Request Body JWT Token Role Fungsi
GET /attendances - userId, scheduleId, adminUsername, status, page, limit, sort - Yes user, admin Find list of attendances
POST /attendances - - userId, scheduleId, description, imageUrl Yes user, admin Create a new WFO request by user
GET /attendances/ id - - Yes user, admin Find attendance by attendance's id
PATCH /attendances/ id - scheduleId, adminUsername, status, statusInfo Yes admin Edit attendance's status by attendance's id
DELETE /attendances/ id - - Yes admin Delete a attendance by attendance's id

(back to top)

Checks

Method Endpoint Path Param Query Param Request Body JWT Token Role Fungsi
GET /checks - userId, scheduleId, page, limit, sort - Yes user, admin Find list of checks
GET /checks/ attendanceId - - Yes user, admin Find check by attendance's id
PATCH /check-in attendanceId - temperature Yes user, admin check-in on scheduled WFO request
PATCH /checks-out - - - Yes user, admin check-out after scheduled WFO request

(back to top)

Contact

  • Bagus Nuryasin
    Github Badge Linkedin Badge

(back to top)

©️ 2023 | Szczynk

About

This app facilitates work-from-office requests and confirmations for companies under Covid-19 safety protocols. Built using microservice architecture and containerized REST and gRPC services in Go.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published