-
Notifications
You must be signed in to change notification settings - Fork 0
mpclemens/parkside-loansubmit
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Simple loan submission/lookup class and interfaces into it. REQUIREMENTS: ============= sqlite3 (not sqlite2!) python2.7 python-flask The command-line UI runs in pure Python using standard libraries The REST API runs as a Flask app Both use the classes in parkside-loansubmit/loansubmit/Loan.py which implement the actual logic to validate and interact with the db, and have custom exceptions for validation failures VIRTUAL ENV: ============ I used a virtual environment locally for development. If you don't want to install Flask in your normal library path, setting up a virtual env is largely painless. Using your system's package manager, make sure you have these installled as an administrative user: python-pip python-virtualenv As a normal user account, create the virtual environment: virtualenv parkside-loansubmit/env ...and then start it up. source parkside-loansubmit/env/bin/activate The "(env) " identifier appears before my shell prompt while the virtual env is running. While the virtual environment is running, try: pip install Flask or pip install -r requirements.txt ...to install the necessary packages for the RESTful API. Type: deactivate ...to leave the virtual env. INTERFACES: =========== Both interfaces save/load data via sqlite3 to the file data/loansubmit.db To make sure everything is operating, I'd run the Load.py unit tests first. These include code that saves and loads to a test version of the database (loansubmit_t.db) cd parkside-loansubmit/loansubmit/ python test_Loan.py Interactive CLI: ---------------- python parkside-loansubmit/loansubmit-cli.py Pure Python 2.7 interactive CLI for the loansubmit/Loan.py class. Commands are: help, add, edit, find, quit JSON App: --------- source parkside-loansubmit/env/bin/activate (to run the virtual env) python parkside-loansubmit/loansubmit.py On my machine, this starts Flask on localhost port 5000 Try opening the following valid URLs in a browser or curl (tweaked if you're using a different port): http://localhost:5000/find/3 http://localhost:5000/edit/3?loan_status=Review http://localhost:5000/new/?payer_ssn=345-67-8910&prop_value=10000&loan_value=2500 Invalid URLs should return meaningful JSON: http://localhost:5000/FOOBAR http://localhost:5000/ http://localhost:5000/find/9999 http://localhost:5000/edit/1 http://localhost:5000/new MUSINGS: ======== * The app accepts GET to make it easier to test, but in real life I'd say it's limited to the "find/" path: "new/" would only be a POST, "/edit" would only be a PUT * I assumed that one person (SSN) could have multiple loans. Sure, why not? loan_id is really what matters * I'm saving loans where the LTV exceeds the specified amount (40%) as it wasn't clear if those should just be rejected out of hand and not assigned an id, or saved as "Denied" * I added the "edit" command in case a loan officer feels kindly at a future date to loans that were Denied at setup. :-) * SSN is a terrible key! Just awful. And casually exchanging it like this makes me fret, even though this is a toy problem. Years in healthcare have made me extra wary. Better that a "customers" table be established to encapsulate all the sensitive details Thanks for reading!
About
Parkside Lending challenge
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published