A simple Flask API for storing users and groups of users. Optimized for read-performance over write performance based on the client-side specifications.
- Framework: This is a single Flask app using the Flask-RESTful module to implement a RESTful API.
- Data/Persistence: Currently uses an in-memory data layer, but this can be swapped easily based on performance/scaling requirements with changes to
usergroups/db.py
and minimal changes tousergroups/models/base.py
. - Minimal API = No dependencies on outside services
Any version of python2.7 with setuptools and pip, Recommended: virtualenv
- Checkout the repo
- Set up virtualenv from root directory
- Install requirements with pip
- Run the server
- Option 1. No options (default port 5000, minimal logging):
python runserver.py
- Option 2. Customize
- set env for development configs:
export USERGROUPS_ENV=DEVELOPMENT
- AND/OR Run on custom port
python runserver.py --port XXXX
- set env for development configs:
- Option 1. No options (default port 5000, minimal logging):
git clone git@github.com:bri-bri/user-groups.git && cd user-groups
virtualenv env && . env/bin/activate
pip install -r requirements.txt
export USERGROUPS_ENV=DEVELOPMENT
python runserver.py --port 5000
Simply run the following command and verify the output manually:
sh ./integration-test.sh
TODO... real unit tests
- Without request parameters:
curl -i http://127.0.0.1:5000/users/<userid>
- With request parameters:
curl -i -X POST http://127.0.0.1:5000/users/ -d '{"userid":"user1", "first_name":"John", "last_name": "Doe", "groups":["gentlemen", "scholars"]}' -H "Content-type: application/json"
- Unit Tests for controllers and models (partially implemented but not presentable)
- Commented code
- Persistent log storage (w/ improved logging and logger class)
- process manager config (e.g. supervisord)
- Datastore options need to be considered based on further requirements and prototype performance
- custom RequestParser
- custom ExceptionHandler
- custom ResponseHandler routing all responses
- metric/performance tracking
- misc. work to get it running in a distributed remote environment
All work - including research and testing - took about 7.5 hours.
2015-07-09 PM - 2.5 hours setting up skeleton
2015-07-10 NOON - 0.5 hours researching
2015-07-10 PM - 2.5 hours finishing core functionality
2015-07-11 AM - 1.0 hour attempting unit tests
2015-07-11 NOON - 1.0 hour doing integration test instead & writing setup instructions
Grand total: 7 hours