Balance Takehome is a prototype GraphQL API to connect with the merge.dev Unified API to access and retrieve Accounting data from common models like Company Info, Accounts and Transactions.
- Build images and start docker containers using:
cd balance-takehome
docker-compose up --build- Access pgAdmin through http://localhost:5050 to verify the schema creation and the ingested data:
- Access GraphiQL (In-Browser GraphQL IDE) through http://localhost:8000/graphql and execute the following queries:
1.
query {
balanceBreakdown {
... on DateTimeType {
now
}
... on BankAccountsList {
accounts {
name
currentBalance
}
}
}
}
2.
query {
incomeAndExpenses(month:10, year:2023) {
income
expenses
}
}
3.
query {
transactionsForInterval(startDate:"2023-03-01", endDate:"2023-03-21") {
... on TransactionsList {
transactions {
transactionDate
name
transactionTo
transactionFrom
amount
}
}
}
}- Execute the unit tests session through
pytest:
docker exec balance_takehome_app pytest- Execute the pre-configured
Blackpython formatter:
docker exec balance_takehome_app black main.py app tests- Execute the
isortutility to manage imports:
docker exec balance_takehome_app isort main.py app tests- Execute a static type checking analysis using
mypy:
docker exec balance_takehome_app mypy main.py app tests- After any database schema/tables change, you'd have to execute the following migration commands:
docker exec balance_takehome_app alembic revision --autogenerate
docker exec balance_takehome_app alembic upgrade head- FastAPI provides high performance and good coding time. Also, through its async capabilities and web server (ASGI Standard - Asynchronous Server Gateway Interface), we can schedule a coroutine that executes the polling process with real time confidence just as a Celery task.
- PostgreSQL is widely used as a relational database for API's supported by ORM's to abstract the interaction. Using it we gain flexibility and particular capabilities/utilities like the
on_conflict_do_updatemethod to execute theUPSERToperation using constraints.
- The SQLModel library mixes the features from SQLAlchemy & Pydantic. It provides a layer of communication (between both libraries) that allows the creation of database tables through type annotations, just as simple as a
dataclassor a PydanticBaseModel. Avoiding code duplication and supporting a clean codebase.



