AI-powered REST API for electronic item valuation built with Spring Boot 4.0.2 for the European market. It integrates Llama 3.3-70B via Hugging Face for intelligent price estimation in EUR (β¬) with market-based fallback pricing. Demonstrates clean layered architecture (Controller β Service β Repository β Entity/DTO), AI integration, error handling, and REST best practices.
-
AI-Powered Valuation
- Natural language descriptions via Llama 3.3-70B
- Intelligent price estimation based on market data
- Fallback pricing when AI is unavailable
- Condition-based price adjustment (1-10 scale)
-
Complete CRUD operations
- Create, Read, Update, Delete estimations
- Historical tracking with timestamps
- Price and description storage
-
Architecture & Quality
- Clean layered architecture
- DTOs for API communication
- Centralized error handling
- BigDecimal for precise currency values
- Proper JSON serialization (tools.jackson)
- CORS enabled for frontend integration
| Technology | Version |
|---|---|
| Java | 17+ |
| Spring Boot | 4.0.2 |
| Spring Data JPA | - |
| PostgreSQL | - |
| Hugging Face API | Llama 3.3-70B |
| Lombok | - |
| tools.jackson (Jackson 3.x) | bundled with Spring Boot 4 |
com.yann.smart_valuator_api
β
βββ config/ β Spring configuration (JacksonConfig, CORS)
βββ controller/ β REST endpoints (EstimationController)
βββ service/ β Business logic (EstimationService, HuggingFaceService)
βββ repository/ β JPA interfaces for persistence
βββ entity/ β JPA entities (Estimation)
βββ DTO/ β API communication objects (AiEstimationResult, ChatCompletionRequest)
Client Server Hugging Face
β β β
βββββ POST /api/estimations ββββ>β β
β βββββ AI Request βββββββββββββββ>β
β β β Llama 3.3-70B
β β<βββ JSON Response ββββββββββββββ processes item
β β β
β β Parse & Validate β
β β (or use fallback pricing) β
β β β
β<βββ 200 OK + Estimation ββββββββ Save to database β
β β β
βββββ GET /api/estimations βββββ>β β
β<βββ List of estimations ββββββββ β
- Submit Item β Client sends item details (name, brand, category, year, condition)
- AI Processing β API calls Llama 3.3-70B with structured prompt
- Price Calculation β AI estimates market value or fallback applies condition-based pricing
- Storage β Estimation saved with description, price, and timestamp
- Retrieval β Historical estimations can be queried and managed
| Method | Endpoint | Description | Body Required |
|---|---|---|---|
| POST | /api/estimations |
Create new estimation | Yes |
| GET | /api/estimations |
List all estimations | No |
| GET | /api/estimations/{id} |
Get estimation by ID | No |
| PUT | /api/estimations/{id} |
Update estimation | Yes |
| DELETE | /api/estimations/{id} |
Delete estimation | No |
POST /api/estimations
Content-Type: application/json
{
"itemName": "iPhone 14 Pro",
"brand": "Apple",
"category": "Smartphone",
"year": 2022,
"conditionRating": 8
}{
"id": 1,
"itemName": "iPhone 14 Pro",
"brand": "Apple",
"category": "Smartphone",
"year": 2022,
"conditionRating": 8,
"estimatedPrice": 400.00,
"aiDescription": "iPhone 14 Pro from 2022 in very good condition (8/10). This model retains strong resale value in the European market with its A16 chip and advanced camera system.",
"createdAt": "2026-02-13T08:30:15.123456"
}GET /api/estimations[
{
"id": 1,
"itemName": "iPhone 14 Pro",
"estimatedPrice": 400.00,
"createdAt": "2026-02-13T08:30:15.123456",
...
},
{
"id": 2,
"itemName": "MacBook Pro",
"estimatedPrice": 680.00,
"createdAt": "2026-02-13T08:25:10.654321",
...
}
]PUT /api/estimations/1
Content-Type: application/json
{
"itemName": "iPhone 14 Pro Max",
"brand": "Apple",
"category": "Smartphone",
"year": 2022,
"conditionRating": 9,
"estimatedPrice": 500.00,
"aiDescription": "Updated description"
}DELETE /api/estimations/1- Natural language prompts with European market context
- Structured JSON output parsing
- Markdown cleanup and validation
- Timeout handling (15s connection, 30s read)
- Pricing in EUR (β¬) for European market
Base Prices by Category (EUR):
| Product Category | Base Price (EUR) |
|---|---|
| iPhone 15/16 | β¬650 |
| iPhone 14 | β¬500 |
| iPhone 13 | β¬380 |
| iPhone 12 | β¬280 |
| iPhone 11 | β¬200 |
| iPhone X/10 | β¬170 |
| Samsung Galaxy S23/24 | β¬470 |
| Samsung Galaxy S22/21 | β¬320 |
| MacBook Pro | β¬850 |
| MacBook Air | β¬550 |
| iPad Pro | β¬470 |
| iPad Air | β¬280 |
| Generic Laptop | β¬370 |
| Generic Tablet | β¬180 |
| Smartwatch | β¬230 |
| AirPods | β¬90 |
| Gaming Console | β¬320 |
Condition Multiplier:
Final Price = Base Price Γ (Condition Rating / 10)
Example:
iPhone 14 (base: β¬500) with condition 8/10
= β¬500 Γ 0.8 = β¬400.00
# Java 17+
java -version
# Maven
mvn -version
# PostgreSQL running on localhost:5432# Clone the project
git clone <repo-url>
cd smart-valuator-api
# Configure database
# Edit src/main/resources/application.properties:
spring.datasource.url=jdbc:postgresql://localhost:5432/smartvaluator
spring.datasource.username=your_username
spring.datasource.password=your_password
# Set Hugging Face API key as environment variable
export HF_API_KEY=your_huggingface_api_key
# Build
mvn clean compile
# Run tests
mvn test
# Run the project
mvn spring-boot:runAPI available at: http://localhost:8080
# Database
spring.datasource.url=jdbc:postgresql://localhost:5432/smartvaluator
spring.datasource.username=smartvaluator
spring.datasource.password=smartvaluator
spring.jpa.hibernate.ddl-auto=update
# Hugging Face API β set HF_API_KEY as an environment variable
hf.api.key=${HF_API_KEY}
# Server (default port)
server.port=8080
# CORS is enabled globally via @CrossOrigin on EstimationControllerCREATE TABLE estimations (
id SERIAL PRIMARY KEY,
item_name VARCHAR(255) NOT NULL,
brand VARCHAR(100),
category VARCHAR(100),
year INTEGER NOT NULL,
condition_rating INTEGER CHECK (condition_rating BETWEEN 1 AND 10),
estimated_price NUMERIC(10,2),
ai_description TEXT,
created_at TIMESTAMP DEFAULT NOW()
);// Automatic fallback to market-based pricing
if (aiResponse.equals("API_ERROR")) {
return createFallbackResult(productDetails);
}// Configured timeouts prevent hanging
factory.setConnectTimeout(15000); // 15s
factory.setReadTimeout(30000); // 30s// Ensures price is never null or zero
if (price == null || price.compareTo(BigDecimal.ZERO) == 0) {
price = estimateFallbackPrice(productDetails);
}- BigDecimal is used for all monetary values to ensure precision
- EUR (β¬) is the currency for all prices (European market)
- LocalDateTime is serialized in ISO-8601 format for frontend compatibility
- tools.jackson (Jackson 3.x) is used for JSON processing in Spring Boot 4
- Fallback pricing ensures the system works even without AI connectivity
- Condition rating (1-10) directly affects final price estimation
- AI descriptions provide natural language context for valuations in European market context
- All timestamps are automatically generated via
@PrePersist - CORS is configured to allow frontend access from
localhost:4200 - Prices are adjusted for European market (approx. 0.92x USD β EUR conversion)
- Start PostgreSQL database
- Configure API key in
application.properties - Run the application:
mvn spring-boot:run - Test with Postman or integrated frontend:
- Create estimation β Verify AI description and price
- List estimations β Check historical data
- Update estimation β Modify values
- Delete estimation β Clean up data
- User authentication and authorization
- Multiple AI model support
- Image upload for item photos
- Price history tracking over time
- Market trend analysis
- Export estimations to PDF/Excel
- Email notifications for price changes
- Mobile app integration
Personal project β Educational purpose β No restrictive licenses