← Selected work

Case study 01 / Interview exercise

Financial Portfolio Tracker.

From individual trades to portfolio-level performance.

01 The problem

A trade log records individual transactions. To see how a portfolio performed, those transactions need to be grouped and their gains and losses calculated consistently.

02 The solution

The project pairs a dashboard with API routes to manage portfolios and trades. A separate chart endpoint returns a profit-and-loss total for each portfolio.

03 The architecture

Next.js serves the dashboard and HTTP handlers in one application. Prisma maps portfolios and trades to PostgreSQL, where each trade belongs to one portfolio. The chart handler reads portfolios with their trades and calculates each total in the application.

  1. 01DashboardPortfolio and trade views
  2. 02Route handlersPortfolio, trade, and chart endpoints
  3. 03PostgreSQLPortfolio-to-trade relation via Prisma

04 Engineering decisions

Keeping the total derived from trades avoids maintaining a separate balance that could drift after edits. The handler reads every included trade to compute the totals. That makes the formula easy to follow, while database-side aggregation would reduce how many rows move into the application as the dataset grows.

05 Technologies

  • TypeScript
  • Next.js
  • Prisma
  • PostgreSQL
  • Docker Compose

06 Explore

Next case study

Distributed Application Service