Spring BootJavaMySQLRedisSolidityNode.jsNext.jsTypeScript

Melodiket

Smart contract-based band concert ticketing service. Provides a transparent ticketing system using blockchain technology to solve opaque profit distribution issues and ticket scalping problems. An integrated platform for venue managers, musicians, and audiences.

Melodiket

프로젝트 개요

A smart contract-based band concert ticketing service that introduces blockchain technology to solve opaque and unfair profit distribution issues and ticket scalping problems.

This project clearly separated presentation, business, and data layers through 3-tier architecture design and built an automated profit distribution system using smart contracts. Venue managers can set separate amounts for the venue, musicians, and bonuses when registering concerts, audiences can select their favorite band when booking to show support, and profits are automatically and transparently distributed after the concert.

Through blockchain transparency, all transaction records are recorded on the blockchain and can be verified by anyone, ensuring fairness in profit distribution. Additionally, audiences can create NFT-based personalized photocards to commemorate concerts they attended, and can include their favorite band's signature on the photocard to create unique memories.

As a backend developer, this project provided valuable experience implementing core enterprise-level backend features such as authentication/authorization systems using Spring Security, global exception handling and error management, Redisson-based distributed lock implementation for concurrency control, and complex business logic for concert contracts (musician approval, contract state management, settlement processing).

나의 역할

  • 3-tier 아키텍처 설계 및 핵심 비즈니스 로직 구현: 공연 목록 조회 시 쿼리 튜닝 및 인덱스 최적화를 통한 성능 향상, 실행 계획 분석을 통한 N+1 문제 해결 및 fetch join 최적화, 커서 기반 페이징으로 대량 데이터 조회 성능 개선

  • Spring Security 기반 JWT 인증/인가 시스템 구현

  • 전역 예외 처리 핸들러 및 에러 핸들링 구현

  • Redisson 기반 분산 락을 통한 분산환경 동시성 제어 구현: 좌석 예매 시 동시성 문제 해결을 위해 분산 락 적용, MySQL 트랜잭션 격리수준(REPEATABLE READ)과 분산 락을 조합하여 데이터 일관성 보장

  • 공연 계약 주요 비즈니스 로직 구현 (뮤지션 승인/거절, 계약 상태 관리, 정산 처리)

  • 상태 패턴 및 전략 패턴을 활용한 계약 상태 전이 로직 개발

  • 스마트 컨트랙트와 백엔드 연동 (Web3j 활용)

  • RESTful API 설계 및 구현

기술적 도전과제

Complex Concert Contract State Management

Applied State Pattern to clearly model various states of concert contracts (pending, approved, confirmed, cancelled, etc.). Defined allowed operations and state transition rules for each state to manage business logic complexity and improve code readability.

Blockchain Transaction Processing and Synchronization

Integrated smart contracts with backend using Web3j and implemented a mechanism to track transaction status. Considering that blockchain transactions are processed asynchronously, maintained data consistency by storing transaction hashes and periodically checking status. Applied Compensating Transaction pattern to rollback DB state when transactions fail, and resolved synchronization issues between blockchain and DB through event-based architecture.

Global Exception Handling and Error Response Standardization

Implemented a global exception handler using Spring's @ControllerAdvice to handle all exceptions in a consistent format. Defined custom exception classes and mapped appropriate HTTP status codes and error messages to provide error responses that clients can easily understand and handle.

Security Enhancement for Authentication/Authorization System

Implemented a token-based authentication system by combining Spring Security and JWT. Applied Role-Based Access Control (RBAC) to finely control APIs accessible based on user roles (audience, musician, venue manager). Also enhanced security by implementing token expiration times and refresh token mechanisms.

Managing Hybrid Database Structure

Adopted a hybrid structure where structured data (users, concert information, contracts) is stored in MySQL and unstructured data (logs, metadata) is stored in MongoDB. Established data storage and retrieval strategies suitable for each database's characteristics and ensured data consistency by clearly defining transaction boundaries.

프로젝트 성과

Project Excellence Award

Awarded Samsung Electronics Excellence Award in SSAFY 11th Specialization Project.

Blockchain-based Transparent Profit Distribution

Implemented automated profit distribution system using smart contracts. Directly deployed on Ethereum network to ensure transaction transparency and fairness.

NFT Personalized Photocard

Allows audiences to create NFT photocards to commemorate concerts they attended, and can include their favorite band's signature to create personalized memories. Stored permanently using IPFS distributed storage.

기술 선택 이유

Spring Boot 3

A proven framework for enterprise-level application development, enabling RESTful API development and loosely coupled design through dependency injection. Particularly effective for security enhancement through Spring Security and efficient data persistence management through JPA.

Spring Security

Implements JWT-based authentication and Role-Based Access Control (RBAC) to securely handle user authentication and authorization. Performs security validation at the request level through filter chains and enables fine-grained access control for various endpoints.

Redis & Redisson

Implemented concurrency control using Redisson-based distributed locks. To solve concurrency issues when multiple users try to book the same seat simultaneously, applied Redis-based distributed locks to ensure atomicity of seat reservations and maintain data consistency. Built a safe and reliable seat booking system even in distributed environments through Redisson's distributed lock features. Also utilized Redis as a cache to store frequently accessed data such as concert lists and seat information, reducing DB load and improving response times. Resolved synchronization issues between cache and DB through Write-Through strategy and TTL-based cache invalidation.

Solidity & Web3j

Wrote smart contracts in Solidity to implement automated profit distribution logic on the blockchain. Integrated Java backend with Ethereum blockchain network through Web3j to implement smart contract deployment and invocation features.

Node.js & IPFS

Built an IPFS node server using Node.js to store NFT photocard metadata and images in a distributed storage. Enables permanent data storage and access through IPFS's hash-based content addressing.

시스템 아키텍처

Click to enlarge.

System Architecture

System Architecture

Complete system structure based on 3-tier architecture: Integrated structure of frontend (Next.js), backend (Spring Boot), blockchain (Solidity), and distributed storage (IPFS)

NFT Photocard Distribution

NFT Photocard Distribution

Complete sequence of concert contract and booking process: Full flow from concert registration through musician approval, ticketing, to entry processing

Key Features

Key Features

Database entity relationship diagram: Relationship structure between core entities such as users, concerts, contracts, and tickets

성능 최적화

Query Optimization and N+1 Problem Resolution

Resolved N+1 problems and optimized fetch joins through execution plan analysis when querying concert lists. Significantly reduced unnecessary queries to improve response times and enhanced query performance by adding appropriate indexes.

Redis Caching Strategy

Utilized Redis as a cache to store frequently accessed data such as concert lists and seat information, reducing DB load and improving response times. Resolved synchronization issues between cache and DB through Write-Through strategy and TTL-based cache invalidation.

데이터베이스 최적화

Cursor-based Pagination

Applied cursor-based pagination to resolve performance issues of offset-based pagination when querying large amounts of data. Improved performance by efficiently utilizing indexes through a method that queries the next page based on the last queried ID.

Concurrency Control through Distributed Locks

Resolved concurrency issues during seat reservations using Redisson-based distributed locks. Ensured data consistency by combining MySQL transaction isolation level (REPEATABLE READ) with distributed locks, preventing race conditions when multiple users try to book the same seat simultaneously.

API 설계

Designed a consistent API structure following RESTful API design principles. Introduced API documentation automation using Springfox to improve collaboration efficiency, and provided consistent error response formats through a global exception handler. Provided intuitive APIs using resource-centered URL structures and appropriate HTTP status codes.

보안 구현

JWT Authentication/Authorization based on Spring Security

Implemented a token-based authentication system by combining Spring Security and JWT. Applied Role-Based Access Control (RBAC) to finely control APIs accessible based on user roles (audience, musician, venue manager). Enhanced security by implementing token expiration times and refresh token mechanisms.

Global Exception Handling and Error Handling

Implemented a global exception handler using Spring's @ControllerAdvice to handle all exceptions in a consistent format. Defined custom exception classes and mapped appropriate HTTP status codes and error messages to provide error responses that clients can easily understand and handle.

테스트 전략

Wrote unit tests and integration tests to verify the accuracy of core business logic. Particularly focused on testing concert contract state transition logic and distributed lock behavior to ensure reliability. Also validated the entire flow through integration tests for API endpoints.

KPT 회고

Keep

Clearly separating responsibilities through 3-tier architecture significantly improved maintainability and scalability. Designed stable APIs with a global exception handler and security system using Spring Security.

Cleanly implemented complex business logic for concert contracts using state and strategy patterns, and gained experience applying blockchain technology to actual services through smart contract and backend integration.

Problem

We lacked sufficient investigation into blockchain transaction processing in the early stages of the project.

We didn't deeply consider real-world operational constraints such as blockchain network latency, gas costs, and transaction processing times, and failed to systematically design solutions for data synchronization issues between smart contracts and backend or rollback handling for failed transactions.

Try

Before introducing blockchain, I will conduct performance benchmarks in real operational environments and introduce a process to compare and analyze characteristics of various blockchain networks (Ethereum, Polygon, etc.) to select the network optimized for the project.

Before deploying smart contracts, I will conduct sufficient load testing on testnets and perform analysis to predict operational costs by applying gas optimization techniques.

Considering the uncertainty that can arise from blockchain characteristics, I would like to try reviewing non-blockchain alternative solutions together and designing a hybrid architecture.

프로젝트 정보

프로젝트 출처
Samsung Software Academy For Youth 11th Specialization Project
기간
2024.08 - 2024.10
팀 규모
3FE 3BE
담당 역할
Backend Developer

기술 스택

Spring BootJavaMySQLRedisSolidityNode.jsNext.jsTypeScript

스크린샷

Click to enlarge.

Concert Registration

로딩 중...

Concert Approval

로딩 중...

My Concerts

로딩 중...

Concert List

로딩 중...

Wishlist

로딩 중...

Concert Booking

로딩 중...

Mobile Ticket

로딩 중...

Ticket Scanning

로딩 중...

Transaction

로딩 중...

Photocard Creation

로딩 중...

Photocard Sharing

로딩 중...

Photocard KakaoTalk Sharing

로딩 중...