Skip to content

avinashpathy/mutual-fund-brokerage

Repository files navigation

Mutual Fund Brokerage

  • This is a mutual fund brokerage backend service.
  • Tech stack used: AWS (Lambda Fucntions, DynamoDB, IAM, Secrets Manager, API Gateway, CloudFormation), TypeScript, Serverless Framework.
  • This repository consists of 5 lambda functions:
    • Register Handler: This handler code registers an user which is triggered by /register POST endpoint.
    • Login Handler: This handler code is used for logging in an user which is triggered by /login POST endpoint.
    • Mutual Fund Handler: This handler code selects a fund family house, fetches open-ended schemes for that family, and it is integrated with the RapidAPI to fetch mutual fund data.
    • Portfolio Handler: This handler code is used to add, view and delete investments of an user.
    • Update NAVS Handler: This handler code is used to track current value of the investments hourly.

Setup and Testing:

  • Prerequisites:

    • Install Node.js (18.x or later) and npm (8.x or later) on your machine.
    • Install the Serverless Framework using npm by running npm install -g serverless.
    • Create an AWS account and set up your AWS credentials.
    • Install the AWS CLI and configure it with your AWS credentials.
  • Setup

    • Clone the repository.

    • Repository Link: https://github.com/avinashpathy/mutual-fund-brokerage

    • Navigate to the project directory and install the dependencies by running npm install.

    • Run the below AWS CLI command to create your secrets (JWT Secret and RAPID API Key) in AWS Secrets Manager.

      • aws secretsmanager create-secret --name dev/auth/jwt --secret-string '{"JWT_SECRET":"ADD_YOUR_SECRET"}'
      • aws secretsmanager create-secret --name dev/rapidapikey --secret-string '{"RAPIDAPI_KEY":"ADD_YOUR_API_KEY"}'
    • Update the serverless.yml and sls.environments.yml file with your AWS region and other configuration settings as needed.

  • Deployment

    • Run serverless deploy to deploy the application to AWS.
    • The deployment process may take several minutes to complete.
    • Once the deployment is complete, you can verify that the application is running by checking the AWS CloudFormation console.
  • Testing

    • API Endpoints

      • The application exposes the following API endpoints:

        • POST /register: creates a new user account.
        • POST /login: logs in an existing user and returns a JSON Web Token.
        • GET /mutual-funds: retrieves a list of open ended mutual fund schemes.
        • GET /portfolio: retrieves a user's portfolio.
        • POST /portfolio: adds a new investment to a user's portfolio.
        • DELETE /portfolio: deletes an investment from a user's portfolio.
    • Use the below postman collection link to test the endpoints.

  • Database Creation:

    • Databases are created using Serverless framework.
    • Here is the link to the resource creation code (Line 125-205):
      resources:
      Resources:
      UsersTable:
      Type: AWS::DynamoDB::Table
      Properties:
      TableName: users-table
      AttributeDefinitions:
      - AttributeName: email
      AttributeType: S
      KeySchema:
      - AttributeName: email
      KeyType: HASH
      BillingMode: PAY_PER_REQUEST
      PortfolioTable:
      Type: AWS::DynamoDB::Table
      Properties:
      TableName: portfolio-table
      AttributeDefinitions:
      - AttributeName: userId
      AttributeType: S
      - AttributeName: fundId
      AttributeType: N
      KeySchema:
      - AttributeName: userId
      KeyType: HASH
      - AttributeName: fundId
      KeyType: RANGE
      BillingMode: PAY_PER_REQUEST
      GlobalSecondaryIndexes:
      - IndexName: UserIdIndex
      KeySchema:
      - AttributeName: userId
      KeyType: HASH
      Projection:
      ProjectionType: ALL
      TimeToLiveSpecification:
      AttributeName: ttl
      Enabled: true
      FundTrackingTable:
      Type: AWS::DynamoDB::Table
      Properties:
      TableName: mutual-fund-tracking-table
      AttributeDefinitions:
      - AttributeName: fundId
      AttributeType: N
      - AttributeName: timestamp
      AttributeType: S
      KeySchema:
      - AttributeName: fundId
      KeyType: HASH
      - AttributeName: timestamp
      KeyType: RANGE
      BillingMode: PAY_PER_REQUEST
      GlobalSecondaryIndexes:
      - IndexName: LastUpdatedIndex
      KeySchema:
      - AttributeName: timestamp
      KeyType: HASH
      Projection:
      ProjectionType: ALL
      TimeToLiveSpecification:
      AttributeName: ttl
      Enabled: true
      PortfolioValueTable:
      Type: AWS::DynamoDB::Table
      Properties:
      TableName: portfolio-update-table
      AttributeDefinitions:
      - AttributeName: userId
      AttributeType: S
      - AttributeName: timestamp
      AttributeType: S
      KeySchema:
      - AttributeName: userId
      KeyType: HASH
      - AttributeName: timestamp
      KeyType: RANGE
      BillingMode: PAY_PER_REQUEST

    Please feel free to reach out to [email protected] if you have any doubts.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published