How cactus91869/muffin-wallet works
Purpose and Build Shape
Muffin Wallet is a multi-module Java/Spring Boot backend for wallet and transaction persistence and HTTP access. Gradle assembles the modules from settings.gradle and build.gradle; the runnable server is muffin-wallet-server.
Runtime Entry Point
Spring Boot starts at muffin-wallet-server/src/main/java/ru/hse/muffin/wallet/server/MuffinWalletApplication.java. Runtime configuration is supplied through muffin-wallet-server/src/main/resources/application.yaml, with a localhost-specific profile in muffin-wallet-server/src/main/resources/application-localhost.yaml.
HTTP/API Boundary
The server exposes wallet operations through muffin-wallet-server/src/main/java/ru/hse/muffin/wallet/server/controller/MuffinWalletController.java. API request/response DTOs are intentionally separate from persistence DTOs, under muffin-wallet-server/src/main/java/ru/hse/muffin/wallet/server/dto/MuffinWallet.java and muffin-wallet-server/src/main/java/ru/hse/muffin/wallet/server/dto/MuffinTransaction.java. The published API contract is muffin-wallet-api/src/main/resources/static/openapi/muffin-wallet-api-v1.yaml.
Service and Domain Translation
muffin-wallet-server/src/main/java/ru/hse/muffin/wallet/server/service/MuffinWalletService.java defines the application-facing wallet behavior, implemented by muffin-wallet-server/src/main/java/ru/hse/muffin/wallet/server/service/DefaultMuffinWalletService.java. This layer coordinates repository calls, maps data into server DTOs via muffin-wallet-server/src/main/java/ru/hse/muffin/wallet/server/mapper/MuffinWalletMapper.java, and converts missing-wallet conditions into MuffinWalletNotFoundException.
Persistence Contract Boundary
The data API module isolates consumers from storage implementation. muffin-wallet-data-api/src/main/java/ru/hse/muffin/wallet/data/api/MuffinWalletRepository.java and muffin-wallet-data-api/src/main/java/ru/hse/muffin/wallet/data/api/MuffinTransactionRepository.java are the repository interfaces; their storage-oriented models live in the adjacent dto package. The server should depend on these contracts rather than concrete database classes.
Data Implementation and Schema Lifecycle
Concrete repository implementations are muffin-wallet-data/src/main/java/ru/hse/muffin/wallet/data/repository/DefaultMuffinWalletRepository.java and muffin-wallet-data/src/main/java/ru/hse/muffin/wallet/data/repository/DefaultMuffinTransactionRepository.java. muffin-wallet-data/src/main/java/ru/hse/muffin/wallet/data/config/DataConfig.java supplies data-layer configuration and auto-configuration is registered through muffin-wallet-data/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports. Liquibase-style schema evolution begins at muffin-wallet-data/src/main/resources/db/changelog/db.changelog-master.yaml, defining wallet and transaction tables.
Primary Flow and Infrastructure
The normal flow is HTTP controller → wallet service → data-api repository contract → data repository implementation → relational database; returned persistence DTOs are mapped back to server API DTOs. Local database infrastructure is provisioned by local-env/docker-compose.yaml, with bootstrap SQL in local-env/init.sql. CI build execution is defined in .github/workflows/build.yaml.
Main entry points: MuffinWalletController.java Wallet controller · DefaultMuffinWalletService.java Default wallet service · DefaultMuffinWalletRepository.java Wallet repository · DefaultMuffinTransactionRepository.java Transaction repository
Components 17
Server runtime
- Spring Boot application
muffin-wallet-server/src/main/java/ru/hse/muffin/wallet/server/MuffinWalletApplication.java - Runtime configuration · Includes a localhost-specific profile.
muffin-wallet-server/src/main/resources/application.yaml - Wallet controller
muffin-wallet-server/src/main/java/ru/hse/muffin/wallet/server/controller/MuffinWalletController.java - OpenAPI v1 contract
muffin-wallet-api/src/main/resources/static/openapi/muffin-wallet-api-v1.yaml - Server API DTOs · Separate from persistence models.
muffin-wallet-server/src/main/java/ru/hse/muffin/wallet/server/dto/MuffinWallet.java - Wallet service contract
muffin-wallet-server/src/main/java/ru/hse/muffin/wallet/server/service/MuffinWalletService.java - Default wallet service · Coordinates repositories, mapping, and missing-wallet handling.
muffin-wallet-server/src/main/java/ru/hse/muffin/wallet/server/service/DefaultMuffinWalletService.java - Wallet mapper · Maps persistence data to server DTOs.
muffin-wallet-server/src/main/java/ru/hse/muffin/wallet/server/mapper/MuffinWalletMapper.java
Data layer
- Repository contracts · Storage-independent wallet and transaction access boundary.
muffin-wallet-data-api/src/main/java/ru/hse/muffin/wallet/data/api/MuffinWalletRepository.java - Wallet repository
muffin-wallet-data/src/main/java/ru/hse/muffin/wallet/data/repository/DefaultMuffinWalletRepository.java - Transaction repository
muffin-wallet-data/src/main/java/ru/hse/muffin/wallet/data/repository/DefaultMuffinTransactionRepository.java - Data auto-configuration · Registered as a Spring Boot auto-configuration.
muffin-wallet-data/src/main/java/ru/hse/muffin/wallet/data/config/DataConfig.java - Database changelog · Defines wallet and transaction tables.
muffin-wallet-data/src/main/resources/db/changelog/db.changelog-master.yaml - Relational database
Build & infrastructure
- Gradle multi-module build · Assembles all modules and the runnable server.
settings.gradle - CI build
.github/workflows/build.yaml - Local database environment · Provisions the local database with bootstrap SQL.
local-env/docker-compose.yaml
Connections 19
- CI build → Gradle multi-module build: runs
- Gradle multi-module build → Spring Boot application: builds
- Runtime configuration → Spring Boot application: configures
- Spring Boot application → Wallet controller: serves
- OpenAPI v1 contract → Wallet controller: defines API
- Wallet controller → Server API DTOs: uses
- Wallet controller → Wallet service contract: calls
- Default wallet service → Wallet service contract: implements
- Default wallet service → Repository contracts: depends on
- Default wallet service → Wallet mapper: maps through
- Wallet mapper → Server API DTOs: produces
- Wallet repository → Repository contracts: implements
- Transaction repository → Repository contracts: implements
- Data auto-configuration → Wallet repository: configures
- Data auto-configuration → Transaction repository: configures
- Wallet repository → Relational database: persists wallets
- Transaction repository → Relational database: persists transactions
- Database changelog → Relational database: evolves schema
- Local database environment → Relational database: provisions