This project is a technical challenge project which is powered by flask, docker and openresty.
-
for connection to mongo db and operate mongo like queries.
-
for defining mongo models and access to mongo throughout ORM
-
for executing commands
-
interactive commandline
├── config.py
├── bucket
│ ├── fixtures
│ │ ├── user_prefixes.json
│ │ ├── users.json
│ │ └── prefixes.json
│ ├── services
│ │ ├── bucket.py
│ │ ├── __init__.py
│ ├── mongo_models
│ │ ├── user.py
│ │ ├── prefix.py
│ │ ├── user_prefix.py
│ │ ├── __init__.py
│ ├── views
│ │ ├── bucket.py
│ │ ├── __init__.py
│ ├── __init__.py
│ ├── tests
│ │ ├── test_config.py
│ │ ├── test_bucket.py
│ │ ├── base.py
│ │ └── __init__.py
├── __init__.py
├── tree.py
├── base
│ ├── namedtuples.py
│ ├── mixins.py
│ ├── data_loader.py
│ ├── __init__.py
└── helper.py
flask app is defined under object_challenge/__init__.py
flask app is defined under object_challenge/config.py
- DevelopmentConfig
- TestingConfig
- ProductionConfig
mongo models are defined under object_challenge/mongo_models
directory.
- prefixes
- users
- user_prefixes
endpoint | action | payloads |
---|---|---|
/bucket |
'POST' | {'bucket':'bucket_name'} |
/arvan |
'POST' | {'bucket':'bucket_name'} |
a lua middleware that first send request to the flask app and then based on the response will decide whether send the response to the user or proxy pass the request to the arvan's endpoints
- prefixes.json
{"prefix_id": 1, "prefix": "arvan"} {"prefix_id": 2, "prefix": "pushe"}
- users.json
{"user_id": 1, "name": "a", "auth_token": "token_1"} {"user_id": 2, "name": "b", "auth_token": "token_2"} {"user_id": 3, "name": "c", "auth_token": "token_3"}
- user_prefixes.json
{"user_id": 1, "prefix_id": 1, "is_allowed": true} {"user_id": 1, "prefix_id": 2, "is_allowed": false} {"user_id": 2, "prefix_id": 1, "is_allowed": true} {"user_id": 2, "prefix_id": 2, "is_allowed": true}
curl -X POST \
http://185.239.107.132/bucket \
-H 'authorization: Token token_1' \
-H 'content-type: application/json' \
-d '{
"bucket": "pushe3"
}'
- install requirements
pip install -r requirements/development.txt
- load env
export $(cat deployment/env_dir/flask.env | xargs)
- runserver
python manage.py runserver
- install docker and setup github ssh keys
-
git clone git@github.com:mohammadmasoumi/object_challenge.git
-
cd /deployment
-
docker-compose up -d
This project use flask-shell-ipython
as an interactive flask shell.
python manage.py shell
- run server command
python manage.py runserver
- run server command
python manage.py shell
- load initial data command.
object_challenge/object_challenge/fixtures
python manage.py init