Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Crypto Portfolio API

A backend REST API built with Spring Boot for tracking cryptocurrency portfolios with real-time price data from CoinGecko

Tech Stack

  • Java 17
  • Spring Boot 4
  • Spring Data JPA
  • MySQL
  • Lombok
  • MapStruct
  • Docker
  • CoinGecko API

Features

  • Full CRUD for users coins and portfolios
  • Real-time cryptocurrency price fetching via CoinGecko API
  • Live profit/loss calculation per portfolio holding
  • Top 50 coins market data endpoint
  • Custom validation annotations
  • Global exception handling with structured error responses
  • Input validation with custom error messages

Endpoints

Users

Method URL Description
GET /CRIPTO/API/V1/users Get all users
GET /CRIPTO/API/V1/users/{id} Get user by id
POST /CRIPTO/API/V1/users Add user
PUT /CRIPTO/API/V1/users/{id} Update user
DELETE /CRIPTO/API/V1/users/{id} Delete user

Coins

Method URL Description
GET /CRIPTO/API/V1/coins Get all coins
GET /CRIPTO/API/V1/coins/{id} Get coin by id
POST /CRIPTO/API/V1/coins Add coin
PUT /CRIPTO/API/V1/coins/{id} Update coin
DELETE /CRIPTO/API/V1/coins/{id} Delete coin
GET /CRIPTO/API/V1/coins/price/{coinGeckoId} Get live price and 24h change
GET /CRIPTO/API/V1/coins/market Get top 50 coins market data

Portfolio

Method URL Description
GET /CRIPTO/API/V1/portfolio Get all portfolios
GET /CRIPTO/API/V1/portfolio/{id} Get portfolio by id
GET /CRIPTO/API/V1/portfolio/user/{userId} Get portfolios by user
POST /CRIPTO/API/V1/portfolio Add portfolio
PUT /CRIPTO/API/V1/portfolio/{id} Update portfolio
DELETE /CRIPTO/API/V1/portfolio/{id} Delete portfolio

Running Locally

1 Start MySQL with Docker

docker run --name mysql -e MYSQL_ROOT_PASSWORD=1234 -p 3307:3306 -d mysql

2 Create the database

CREATE DATABASE CriptoAPI;

3 Create application.properties in src/main/resources

spring.application.name=CRIPTOAPI
server.port=8080
spring.datasource.url=jdbc:mysql://localhost:3307/CriptoAPI?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=YOUR_PASSWORD
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
coingecko.api.key=YOUR_COINGECKO_API_KEY

4 Run the application

mvn spring-boot:run

Frontend

A simple HTML/CSS/JS dashboard is included in the frontend folder featuring market data portfolio tracking coin management and user management

About

A RESTful Crypto Portfolio Tracking API built with Spring Boot that fetches real-time cryptocurrency data from CoinGecko API featuring portfolio management per-user holdings tracking live price and profit/loss calculation and full CRUD operations for users and coins

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages