RobinHood backend architecture has been completely planned on microservice as the core API exposer.
NodewithExpressas http server- Amazon
DynamoDBforMasterdata persistenceUsersandTenants. MongoDB64 bit for internal objects and attributes.PostGreSQLwas specifically selected due to its features such asGEO SpatialsupportTransactionaldata andAudit Logs.Amazon S3buckets will be used for media assets storage.Redis | Memcache | Casandrafor caching.ELBElastic Load Balancer to keep allAPIstateless.
- User request the
api.example.comwith login credentials asJWT Tokenpayload. - Login route checks for
Authenticationinside dynamoDB users schema and provides a validAuthorizationwithAuth_TokenandAuth_Keyas a response to theLoginrequest with encryption.
Request:
POST: `api.example.com/auth/login`
{
username: 'demo@gmail.com',
password: 'demo'
}
JWT(Response):
{
Auth_key: `7WOPM08FGFJH7ZBDV7MA170HBEWII8RMHQ`,
Auth_token:`NET91CNKCJ19IV7MA170HBEWII8RMHQ`,
user: {
fname: `Jack`,
lname: `Smith`,
email: `demo@gmail.com`
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
successofAuthorizationwe start communicating with the server tenants only to the giventenants_associated.
- Using the given
Auth_KeyandAuth_TokenandTENANT_UUIDstart sending the request. ConnectionResolverMiddleware will understand theTenant_UUIDheader 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 testThere 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 installRuns the application is development mode. Should not be used in production
npm run devor debug it
npm run dev:debugCompiles the application and starts it in production production mode.
npm run compile
npm startRun the Mocha unit tests
npm testor debug them
npm run test:debug- Open you're browser to http://localhost:3000
- Invoke the
/examplesendpointcurl 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.