A simple API server for querying bank branches data using both REST API and GraphQL approaches.
- REST API endpoints for querying bank and branch information
- GraphQL API at
/gql
for more flexible querying - Ready for Heroku deployment
- Clone the repository
- Create a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Run the application:
python app.py
- Access the API at http://localhost:5000
GET /api/banks
- Get all banksGET /api/banks/{bank_id}
- Get a specific bank by IDGET /api/branches
- Get all branchesGET /api/branches/{ifsc}
- Get a specific branch by IFSC codeGET /api/bank/{bank_id}/branches
- Get all branches for a specific bank
/gql
- GraphQL endpoint with GraphiQL interface
Example query:
query {
branches {
edges {
node {
branch
bank {
name
}
ifsc
}
}
}
}
The application uses SQLite for simplicity but can be easily configured to use other databases like PostgreSQL for production deployment.
Click the "Deploy to Heroku" button at the top of this README to deploy the application with a single click.
- Create a Heroku account if you don't have one
- Install the Heroku CLI
- Login to Heroku:
heroku login
- Create a new Heroku app:
heroku create your-app-name
- Push to Heroku:
git push heroku main
Approximately 8 hours to complete this assignment.
app.py
- Main application file with both REST and GraphQL implementationsmodels.py
- Database modelsdatabase.py
- Database connection and initializationdata/bank_branches.csv
- Sample datarequirements.txt
- DependenciesProcfile
- Heroku deployment configuration