- Programming Language Python 3.7
- memcahe
- sqllite
- aiohttp
- svelte
- aiosqlite
I choose python over other Languages Due to
- familiarity
- fast iteration
- Mature web echo system
I choose memcahce and sqlite to meet the challenge
I choose aiohttp
- aysnc first
- can scale easily to a million user https://pawelmhm.github.io/asyncio/python/aiohttp/2016/04/22/asyncio-aiohttp.html
- lightweight
- easy to use and iterate on
(level one)
TenatBase ---| (level two A)
| |-> TenatBase -|(level three)
| | |-> __init__.py
| | |-> main.py
| | |-> tbase_cache.db
| | |-> web.py
| | |-> interfaces ->|(level 4)
| | |->sql_interface.py
| | |-> memcache_interface.py
| | |-> __init__.py
| |
| |-> poetry.lock
| |-> pyproject.toml
| |
| |
| |(level two B)
| |-> tests ->|
| |-> init.py
|-> README.md |-> test_tenatbase.py
|-> .flake8
|-> .pre-commit-config.yaml
|-> .pyproject.toml
is the head folder
TenatBase
- READ.md
- .pyproject.toml -> black formatter config
- .pre-commit-config.yaml
- .flake8 -> flake8 config
TenatBase
- TenatBase folder containg The app
- Folder to contain tests unfrotently i didnt' get to write any
- poetry.lock contains my packages
- pyproject.toml contains poetry config
*tests
- init.py
- test_tenatbase.py
- init.py
- main.py contains the code to run the CMD
- tbase_cache.db sqldb sqldatabase
- web.py run tofire up the server
- interfaces folder that contains all interfaces with 3 party systems
- sql_interface.py code that interfaces with sqllite
- memcache_interface.py code that interfaces with memcahce
- init.py
- install sqlite
- install memcache
- Install poetry https://poetry.eustace.io/
- run poetry install
- run poetry shell
- start memcache
- python run main to run cmd
- run python web.py to run webserver
- id -> UUID Field
- key -> timestamp
- value -> timestamp
* sql interface that contains 4 functions
| -> get_value_from_sql
| -> delete_value_from_sql
| -> insert_value_into_sql
| -> get_all_values
* memcache interace that contains four function
| -> set_memcahce
| -> get_from_memcahce
| -> delete_from_memcahce
contains web views
| -> health_check -> to check if the service is running
| -> get_value -> get on value for a givien key
| -> set_value -> add key and value pair
| -> delete_value - > delete from sql and memecahe
| -> get_values -> get all value in cache
POST http://127.0.0.1:800/set-value Body ex -> {"key":"code", "value":"test}
GET http://127.0.0.1:8000/get-value Body ex -> {"key":"code"}
Delete http://127.0.0.1:8000/delete-value
GET http://127.0.0.1:8000/get-values
==============
python main.py
python web.py to run the web interface
====================
to scale we will need to answer some questions firt ?
- Does the database of choice support fast key access ?
- is the database able to handle the amount of data we plan to store ?
- how many read and writes we are planning to do on a single node ?
- how do we expand the cluster given expected growth ?
- what is the maintaince process ?
After answering these questions we will be able to choose the right database for our needs
I choose aiohttp since it can scale to a million requests easily we will need to use a better logging tool like sentry we will need of course to add it our CI//CD
- better project planning
- url name scheme may feel inconsistent
- add tests