A REST API backend for tracking stock and multi-asset investment portfolios. EquiTrack lets users manage multiple portfolios, log buy/sell transactions across asset classes, monitor open positions with real-time P&L tracking, set price alerts, and maintain watchlists — all backed by role-based access control and revocable JWT sessions.
| Layer | Technology |
|---|---|
| Language | Java 17 |
| Framework | Spring Boot 4.0.5 |
| Security | Spring Security |
| Persistence | Spring Data JPA + Hibernate |
| Database | PostgreSQL |
| Validation | Jakarta Bean Validation |
| Boilerplate reduction | Lombok |
| Build | Maven |
Rather than a simple "stocks only" tracker, EquiTrack models six asset classes through the InstrumentType enum: STOCK, CRYPTO, ETF, FOREX, COMMODITY, BOND, and INDEX. Each instrument carries a Currency and an Exchange, which required normalizing the reference data into their own tables and adding admin-only management endpoints.
The Alert entity supports four condition types via ConditionType: ABOVE, BELOW, PERCENT_UP, and PERCENT_DOWN. This covers both absolute and relative triggers, which means the service layer will need to branch alert evaluation logic depending on whether the threshold is a raw price or a percentage of the last-seen price.
Rather than relying on short-lived access tokens alone, the domain model includes a RefreshToken entity persisted to the database. This enables server-side revocation of sessions — something stateless JWTs alone cannot provide — at the cost of a database lookup on each token refresh.
Position tracks qty, avgCost, and realizedPnl — the building blocks for both unrealized P&L (computed at query time from live price data) and realized P&L (updated on every SELL transaction). Keeping average cost accurate across partial sells is a non-trivial bookkeeping problem that the service layer will handle.
- Java 17+
- PostgreSQL 14+
- Maven 3.9+
git clone https://github.com/erfderdfg/EquiTrack.git
cd EquiTrackCREATE DATABASE stocktracker;Copy the example config and fill in your credentials:
cp src/main/resources/application.properties.example src/main/resources/application.propertiesEdit application.properties:
spring.datasource.url=jdbc:postgresql://localhost:5432/stocktracker
spring.datasource.username=your_username
spring.datasource.password=your_password
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.hibernate.ddl-auto=validate
spring.jpa.show-sql=trueNote:
ddl-auto=validateassumes the schema already exists. Usecreateon first run or apply migrations manually.
./mvnw spring-boot:runThe server starts on http://localhost:8080 by default.
src/main/java/com/equitrack/backend/
├── models/ # JPA entities and enums
│ └── enums/ # InstrumentType, ConditionType, TransactionSide, TransactionStatus, RoleType
├── repositories/ # Spring Data JPA repository interfaces
└── dto/
├── request/ # Validated inbound payloads
└── response/ # Outbound response shapes
- Service layer (business logic, P&L calculations, alert evaluation)
- REST controllers
- JWT authentication (access + refresh token flow)
- Price ingestion integration
- Alert scheduler / event-driven notification