Skip to content

GraphQL and REST API for customers, accounts and transactions data

Notifications You must be signed in to change notification settings

AddChew/customer-data-service-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

120 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unit Tests

Customer Data Service API

GraphQL API for customers, accounts and transactions data.

Built with:

  • MongoDB
  • Motor
  • FastAPI
  • Ray Serve
  • Strawberry

Project Setup

  1. Navigate into the deploy folder from the project root folder (i.e. customer-data-service-api/deploy)
cd deploy
  1. Create a .env file with the following terminal command
touch .env
  1. Generate an access key with the following terminal command
openssl rand -hex 16
  1. Add the following key-value pairs into the .env file
NUM_REPLICAS=2

APP_PORT=8000
RAY_DASHBOARD_PORT=8265

FIXTURES_SEED=0
NUM_CUSTOMERS=100
NUM_ACCOUNTS=300
NUM_TRANSACTIONS=5000

MONGO_HOST=mongo
MONGO_INITDB_ROOT_USERNAME=<your mongodb username>
MONGO_INITDB_ROOT_PASSWORD=<your mongodb password>

CUSTOMERS_DATABASE=customers_data

CUSTOMERS_COLLECTION=customers
ACCOUNTS_COLLECTION=accounts
TRANSACTIONS_COLLECTION=transactions

ACCESS_KEY=<your generated access key>
  1. Build docker image and start containers
docker compose up -d --build
  1. Navigate to the following urls to access the respective services
URL Service
http://localhost:8000/graphql GraphiQL
http://localhost:8000/docs SwaggerUI
http://localhost:8000/redoc Redoc
http://localhost:8265/#/overview Ray dashboard

How To Run Unittests

  1. Navigate to project root folder (i.e. customer-data-service-api)

  2. Install the necessary dependencies

pip install -r requirements-dev.txt
  1. Execute unittests
coverage run -m pytest -v
  1. Check test coverage
coverage report -m --fail-under=95

Releases

No releases published

Packages

No packages published

Languages