Coder Social home page Coder Social logo

credit-approval's Introduction

CreditApproval

This straightforward Phoenix application employs live views on the front end. Therefore, no additional setup is required. To store user information and show the results to user, it makes advantage of the live view state. As a result, we can currently launch the application without any database setup. Later, we'll also build a database for it. The state (data) is discarded when the page is refreshed since the live view process is restarted with the default state. You can restart the entire flow at any moment without refreshing the page, though. Huraaaa!! This is therefore incredibly intriguing and easy to utilise.

Requirements:

  • Elixir 1.12.2
  • Erlang 24.0.6

Once Elixir setup is completed, then go into the project and perform following steps:

  • Install dependencies with mix deps.get
  • Start Phoenix endpoint with mix phx.server or inside IEx with iex -S mix phx.server

Now you can visit localhost:4000 from your browser.

Once it get started, we can see this screen: Alt text

Click on start button to fill only name & email field: Alt text

Click on Submit and questions start to appear one by one on screen: Alt text

User can go navigate back to previous question easily to answer the question again.

In last, expected result show on home screen.

Further Details About Files:

  • live view files path lib/credit_approval_web/live
  • home screen lib/credit_approval_web/live/calculate/index
  • component for questioning lib/credit_approval_web/live/calculate/question_component
  • embedded schema for user lib/credit_approval_web/live/calculate/user
  • embedded schema for user answers lib/credit_approval_web/live/calculate/user_answers
  • questions are list of maps, currently it's hard written in file because application doesn't has db yet lib/credit_approval/questions_data.ex
  • Request to get scoreCredits against points in lib/credit_approval/approval_client.ex

Although the application does not yet support databases, but its structure of entities can be readily copied to create migrations. So let's go through each entity to understand the structure. The current structure was created with the idea that the application owner might add more questions and change them in future. Owner can change the types of answers of questions for existing ones, such as strings, booleans, and integers, in the future. (Some questions can have numeric answers or some question can have boolean values etc) It has a question entity with both a description and the type of answer. The field answer type: float in the object of a question is present if the expected answer is a float value. Each question must be displayed at the appropriate stage where it occurs. To ensure the sequence of the questions on the form, an index key is also present.

Second entity represent the User and third entity is for User Answers which will hold question_id, user_id and answer with its value type.

Currently they are just embedded schemas which can fulfill the application current requirements.

Later on, we are thinkning to add

  • another new table which holds calculation related information.
  • another new table which holds question types e.g income, expense
  • currencies

(By building these tables, owner can set calculations for different answers at runtime. We will be able to use many features for example expense related answer should be subtract/add from income)).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.