Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions fullstack/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,46 @@
## Fullstack Developer

## Project Overview
This project was initialized with the necessary tech stack. As part of the task, we implemented a database that worked as a cache for exchange rates from the Czech National Bank API. The data is updated every 5 minutes and displayed to the user through a web interface.

## Features Implemented

### Backend (`packages/server`)
The architecture of the implementation is that we have a background job that refreshes the rates. In our case, it is an interval, but in a real production app, it would be something like a lambda function that will be triggered every 5 minutes. This is done to avoid making extra calls to the database when fetching the rates and adding unnecessary delay.

We created a GraphQL resolver with two methods:
- **`getRates`**: Fetches exchange rates from the PostgreSQL database, which works as a cache.
- **`updateExchangeRates`**: A mutation that fetches the latest exchange rates from the Czech National Bank API and updates the cache.

Additionally, we implemented:
- **Exchange Rates Model**: A model that represents exchange rates, stored in the PostgreSQL database.
- **Repository**: A repository to manage CRUD operations for the exchange rate data in the database.
- **Refresh Rates Job**: This job gets the latest exchange rates from the from the Czech National Bank API and later upserts the data in the cache.
- **Test for the Job**: In the tests folder there is a test for the refresh-rates job that can be run with ``npx jest`` in the ``fullstack/task`` directory

This setup ensures the cache stays up to date while providing fast and efficient data retrieval for the frontend.

### Frontend (`packages/client`)
The frontend has three main pages:

- **Dashboard**: The homepage of the application.
- **Exchange Rates**: Displays exchange rates, which automatically refresh every 5 minutes.
- **Convert Rates**: Allows users to convert between different currencies based on the latest exchange rates. The history of conversions is saved, allowing users to track their progression over time.

The frontend uses Apollo Client to fetch and display exchange rates.

### Setup Instructions
Follow these steps to install and run the project:

1️⃣ **Navigate to the project directory**
cd fullstack/task
2️⃣ **Install all dependencies**
yarn install
3️⃣ **Create and start the database**
yarn server db-create
4️⃣ **Start the backend server**
yarn server start
5️⃣ **Start the frontend server**
yarn client start
6️⃣ **Run the tests**
yarn server test
24,580 changes: 0 additions & 24,580 deletions fullstack/task/.pnp.cjs

This file was deleted.

285 changes: 0 additions & 285 deletions fullstack/task/.pnp.loader.mjs

This file was deleted.

2 changes: 1 addition & 1 deletion fullstack/task/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
nodeLinker: pnp
nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
Expand Down
23 changes: 23 additions & 0 deletions fullstack/task/packages/client/codegen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
overwrite: true
schema:
- http://localhost:4001/graphql:
headers:
client-version: 1.0.0
generates:
src/gql/types.tsx:
plugins:
- 'typescript'
- 'fragment-matcher'
config:
apolloClientVersion: 3
avoidOptionals: true
namingConvention:
enumValues: keep
src/gql/generated/possible-types.ts:
plugins:
- fragment-matcher
src/gql/graphql.schema.json:
plugins:
- 'introspection'
config:
apolloClientVersion: 3
Loading