An open API service indexing awesome lists of open source software.

https://github.com/sbrunomello/simdex

Backend of a crypto exchange simulator with account creation, login, and transaction simulation using Spring Security.
https://github.com/sbrunomello/simdex

api-rest blockchain cryptocurrency exchange finance java jwt open-source plataform simulator spring-boot spring-mvc spring-security

Last synced: 4 months ago
JSON representation

Backend of a crypto exchange simulator with account creation, login, and transaction simulation using Spring Security.

Awesome Lists containing this project

README

          

![Java](https://img.shields.io/badge/java-%23ED8B00.svg?style=for-the-badge&logo=openjdk&logoColor=white)
![Spring](https://img.shields.io/badge/spring-%236DB33F.svg?style=for-the-badge&logo=spring&logoColor=white)

# Simdex โ€“ SIMulated DEXchange (Spring Boot Backend)

**Simdex** is a simulation platform for decentralized crypto exchange logic, built with Spring Boot. It features secure user registration/login, crypto price tracking via CoinMarketCap, and basic portfolio management. Designed as an educational and prototyping project for fullstack blockchain enthusiasts.

> ๐Ÿงช This backend powers the [Simdex Frontend](https://github.com/sbrunomello/simdex-web)

---

## ๐Ÿ’ก Key Features

- โœ… **User Registration & Login** with Spring Security
- ๐Ÿ”‘ **JWT Authentication** with token-based sessions
- ๐Ÿ“ˆ **Live Crypto Price Tracking** using CoinMarketCap API
- ๐Ÿ’ผ **User Portfolio Structure** for holding simulated assets
- ๐Ÿ“ฆ Modular architecture with clean domain separation
- ๐Ÿงช Ready for REST API testing (Postman/Insomnia)

---

## ๐Ÿ” Auth System

- `/auth/register` โ†’ creates a new user
- `/auth/login` โ†’ returns JWT token
- Role system via `ERole.ROLE_ADMIN`, extendable

Spring Security is fully configured with:

- AuthenticationManager
- BCrypt password encoding
- TokenService for JWT generation

---

## ๐Ÿ“Š Crypto Price Endpoint

- `/api/v2/price` โ†’ Returns real-time BTC price from CoinMarketCap API
- Uses native Java 11+ `HttpClient` and `javax.json` to parse the response
- Requires a valid API key from CMC in the controller

```java
JsonObject cryptoData = jsonObject.getJsonObject("data").getJsonObject("BTC");
JsonNumber price = cryptoData.getJsonObject("quote").getJsonObject("USD").getJsonNumber("price");
```

---

## ๐Ÿ“‚ Project Structure

```
/controllers
AuthController.java โ†’ login/register endpoints
CMCIntegrationController.java โ†’ price data from CoinMarketCap
SimdexController.java โ†’ basic health/test routes

/domain
user/ โ†’ user, roles, DTOs
crypto/ โ†’ (holdings, portfolio โ€“ WIP)

/repositories
UserRepository.java

/security
SecurityConfig.java
TokenService.java

/resources
application.properties

pom.xml
```

---

## โ–ถ๏ธ How to Run

### Prerequisites

- Java 17+
- Maven
- PostgreSQL (or H2 for dev)
- CoinMarketCap API Key (free plan works)

### Steps

```bash
git clone https://github.com/sbrunomello/simdex.git
cd simdex
mvn spring-boot:run
```

Backend will run on:
`http://localhost:8080`

---

## ๐Ÿงช Example Requests

### Register

```http
POST /auth/register
{
"username": "mello",
"password": "123456",
"email": "mello@example.com",
"firstName": "Bruno",
"lastName": "Mello"
}
```

### Get BTC Price

```http
GET /api/v2/price
โ†’ name: Bitcoin | price: 69234.56
```

---

## ๐Ÿงฉ Frontend

Simdex is designed to work with:
๐Ÿ‘‰ [`simdex-web`](https://github.com/sbrunomello/simdex-web) โ€“ Angular app for user interface, wallet, and order management

---

## ๐Ÿš€ Roadmap

- [ ] Add real-time price updates via WebSocket
- [ ] User portfolio API (add/remove simulated assets)
- [ ] Simulated buy/sell logic
- [ ] Historical chart tracking (via CMC)
- [ ] Admin dashboard

---

## ๐Ÿ“ฌ Contact

- [GitHub](https://github.com/sbrunomello)
Built with โš™๏ธ by Mello