RobinHood backend architecture has been completely planned on microservice
as the core API
exposer.
Node
withExpress
as http server- Amazon
DynamoDB
forMaster
data persistenceUsers
andTenants
. MongoDB
64 bit for internal objects and attributes.PostGreSQL
was specifically selected due to its features such asGEO Spatial
supportTransactional
data andAudit Logs
.Amazon S3
buckets will be used for media assets storage.Redis | Memcache | Casandra
for caching.ELB
Elastic Load Balancer to keep allAPI
stateless.
- User request the
api.example.com
with login credentials asJWT Token
payload. - Login route checks for
Authentication
inside dynamoDB users schema and provides a validAuthorization
withAuth_Token
andAuth_Key
as a response to theLogin
request with encryption.
Request:
POST: `api.example.com/auth/login`
{
username: '[email protected]',
password: 'demo'
}
JWT(Response):
{
Auth_key: `7WOPM08FGFJH7ZBDV7MA170HBEWII8RMHQ`,
Auth_token:`NET91CNKCJ19IV7MA170HBEWII8RMHQ`,
user: {
fname: `Jack`,
lname: `Smith`,
email: `[email protected]`
others: {
education: [],
experiences: []
}
tenants_associated: {
'tenant1': {
'TENANT_UUID': '7MA170H',
'DB_NAME': '',
'DB_PASSWORD': '',
'DB_PORT': '',
'DB_USER': '',
'Totat_users': 190
},
'tenant2': {
'TENANT_UUID': '7MA170G',
'DB_NAME': '',
'DB_PASSWORD': '',
'DB_PORT': '',
'DB_USER': '',
'Totat_users': 2000
}
}
}
}
- Now based out on the
success
ofAuthorization
we start communicating with the server tenants only to the giventenants_associated
.
- Using the given
Auth_Key
andAuth_Token
andTENANT_UUID
start sending the request. ConnectionResolver
Middleware will understand theTenant_UUID
header and start establishing connection with the given Tenant.
Get started developing...
# install deps
npm install
# run in development mode
npm run dev
# run tests
npm run test
There are two key files:
server/routes.js
- This references the implementation of all of your routes. Add as many routes as you like and point each route your express handler functions.server/common/api.yaml
- This file contains your OpenAPI spec. Describe your API here. It's recommended that you to declare any and all validation logic in this YAML.
Install all package dependencies (one time operation)
npm install
Runs the application is development mode. Should not be used in production
npm run dev
or debug it
npm run dev:debug
Compiles the application and starts it in production production mode.
npm run compile
npm start
Run the Mocha unit tests
npm test
or debug them
npm run test:debug
- Open you're browser to http://localhost:3000
- Invoke the
/examples
endpointcurl http://localhost:3000/api/v1/examples
npm run dev:debug
npm run test:debug
# User modules
https://api.example.com/v1/users/
https://api.example.com/v1/users/findInvalid
https://api.example.com/v1/users/activeUsers
https://api.example.com/v1/users/onlineUsersAllocated
# Tenants modules
https://api.example.com/v1/tenants/
https://api.example.com/v1/tenants/newOrganization
https://api.example.com/v1/tenants/activity_logs
# Request headers
- https://api.example.com/v1/users/activeUsers
- Auth_key: username hashed
- Auth_token: everyday it refreshes and create a new hash
- tsc_id: 'microsoft'
https://slack.com
https://accounts.slack.com/login
## Tenants
https://logezy.slack.com
https://careazy.slack.com
- check for the domain slug {*}.slack.com
- pick the first string
- search for the database name matching the give `string`
- establish the connection to that database which has the name `string`
- Users
- UsersOrganization
- Organizations
Org1:
- Profile: pk Users.id
Org2:
- Profile pk Users.id
Org3:
- Profile pk Users.id
- Write the API Documentation
- Write the skeleton function
- Write minimum 5 to 10 testcases which should fail at first attempt
- Make the skeleton function in such a way that all tests are passing.
- ECMA6 as the standard way of writing code.
- TypeScript will be our base compiler.
- MERN stack.