API for accessing bank card blocking information. This service provides endpoints to list banks and retrieve detailed instructions on how to block cards for a specific bank.
The API exposes the following endpoints based on the OpenAPI specification:
GET /banks: Lists all available banks with summary information (ID, name, logo).GET /banks/{bankId}: Retrieves detailed information for a specific bank, including IFSC code and various methods for blocking cards (toll-free numbers, SMS numbers, email, website links, etc.).
Refer to the openapi.json file for detailed request/response schemas.
-
Clone the repository:
git clone <repository-url> cd card-block-api
-
Create and activate a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install dependencies:
pip install -r requirements.txt
-
Install development dependencies (for testing):
pip install -r requirements-dev.txt
To run the application using the Flask development server:
python run.pyBy default, the server runs on http://127.0.0.1:5000. You can configure the host and port using environment variables:
FLASK_RUN_HOST: The host to bind to (default:127.0.0.1).FLASK_RUN_PORT: The port to listen on (default:5000).
Example:
export FLASK_RUN_HOST=0.0.0.0
export FLASK_RUN_PORT=8080
python run.pyFor production deployments, it's recommended to use a WSGI server like Gunicorn (which is included in requirements.txt).
gunicorn --bind 0.0.0.0:8000 "run:app"Adjust the bind address and port as needed.
To run the automated tests using pytest:
pytestTo run tests with coverage reporting:
pytestTo run tests and generate a coverage report:
pytest --cov=app tests/This will output a summary to the console. The current test coverage is 92%. You can also generate an HTML report for more detailed analysis:
pytest --cov=app --cov-report=html tests/
# Open htmlcov/index.html in your browserA Dockerfile is provided to build a container image for the application.
-
Build the image:
docker build -t card-block-api . -
Run the container:
docker run -p 5000:5000 card-block-api
This will start the application using Gunicorn inside the container, accessible on port 5000 of your host machine.
This project uses GitHub Actions for Continuous Integration and Continuous Deployment. The workflow configuration can be found in .github/workflows/ci-cd.yml. The workflow typically includes steps for:
- Setting up Python
- Installing dependencies
- Running linters (if configured)
- Running tests
- Building Docker image (optional)
- Deploying (optional)