This project is an asynchronous ATM service built with FastAPI. It handles ATM operations such as withdrawing money, refilling money, and checking the inventory. The inventory state is stored in Redis for production and in a JSON file for local testing.
- Withdraw money
- Refill money
- Check inventory
- Get total amount
- Maintenance mode
- Python 3.10
- Redis (for production)
- Docker (optional, for running with Docker)
-
Make the setup script executable and run it ( python3.10 should be installed and in %PATH% ):
git clone https://github.com/euhoro/mta_lakit.git cd mta_lakit chmod +x setup_and_run.sh ./setup_and_run.sh
-
Access the application:
-
Create a virtual environment:
python3.10 -m venv venv
-
Activate the virtual environment:
source venv/bin/activate
-
Install requirements`:
pip install -r requirements.txt
-
Running redis locally`:
docker run --name redis -d -p 6379:6379 redis
-
Run App`:
uvicorn main:app --reload
- Run the app`:
SETTINGS_MODE=redis docker-compose up --build
- Run to reload a full ATM`:
curl -L -g -X GET 'http://127.0.0.1:8000/atm/maintenance'
- Access the application:
- Run the app`:
SETTINGS_MODE=text docker-compose up --build
-
Set the environment variable:
export SETTINGS_MODE=text
-
Start the app:
uvicorn main:app --host 127.0.0.1 --port 8000 &
-
Run the tests:
pytest --cov=./ --cov-report=xml
-
Stop the app:
pkill -f "uvicorn main:app"
- Create 2 modules app and core
- Fix all pylint exceptions
- Optimize Logic Structure
- Achieve 95% Test Coverage
- Split tests to short (text) and long (redis)
- Integrate the stress test
Feel free to fork the repository and make contributions. Pull requests are welcome.
This project is licensed under the MIT License.