Skip to content

Sumit0ubey/GlossaryAPI

Repository files navigation

🏛️ Imperial Pedia API

A comprehensive, enterprise-grade REST API for managing an encyclopedia of terms with advanced categorization, relationships, and multi-status support.

Java Spring Boot PostgreSQL Maven License

Status: Build Tests Code Quality Deployment Ready


📑 Table of Contents


🎯 Overview

Imperial Pedia API is a production-ready REST API built with Spring Boot for managing a comprehensive encyclopedia database. It provides full CRUD operations with advanced features including multi-status workflows, automatic categorization, and intelligent term relationships.

Project Status:COMPLETE AND FULLY FUNCTIONAL

  • Build Status: ✅ SUCCESS (0 Errors, 0 Warnings)
  • Test Coverage: ✅ 58/58 PASSED (8 Test Classes)
  • Compilation: ✅ 32/32 Source Files
  • Deployment Ready: ✅ YES

🚀 Quick Start

Prerequisites

  • Java 22+
  • Maven 3.8+
  • PostgreSQL 17.8+
  • Git/GitHub

Installation

# Clone the repository
git clone https://github.com/Sumit0ubey/ImperialPediaAPI
cd imperialpedia_api

# Build the project
mvn clean install

# Run the application
mvn spring-boot:run

The API will be available at http://localhost:8080/api


📚 Documentation

📖 Complete API Documentation

Comprehensive endpoint documentation with request/response examples, validation rules, and error scenarios.

👉 View API Documentation

📋 Project Summary

Detailed project overview, features, architecture, and completion status.

👉 View Project Summary

🎯 This README

Project overview and quick reference guide.


✨ Features

📝 Term Management

  • ✅ Create terms with rich metadata
  • ✅ Retrieve by letter, slug, or UUID
  • ✅ Update (full PUT & partial PATCH)
  • ✅ Delete permanently
  • ✅ Status-based filtering

🏷️ Category Management

  • ✅ Auto-create addCategories
  • ✅ Case-insensitive matching
  • ✅ Multiple addCategories per term
  • ✅ Smart deduplication

🔗 Relationship Management

  • ✅ Link terms by slug or UUID
  • ✅ Prevent self-references
  • ✅ Smart deduplication
  • ✅ Eager relationship loading

📊 Status Workflows

  • ✅ DRAFT (hidden)
  • ✅ PUBLISHED (public)
  • ✅ ARCHIVED (preserved)
  • ✅ Transition endpoints

🔐 Data Quality

  • ✅ Comprehensive validation
  • ✅ Automatic normalization
  • ✅ Null safety
  • ✅ Uniqueness constraints

📡 API Quality

  • ✅ Consistent responses
  • ✅ Proper HTTP codes
  • ✅ Error handling
  • ✅ Timestamp tracking

⚡ Request Protection

  • ✅ Configurable rate limiting (Bucket4j)
  • ✅ Endpoint-specific limit groups
  • ✅ Per-client bucket separation
  • ✅ Standard 429 Too Many Requests

🏗️ Architecture

Clean Layered Architecture

┌─────────────────────────────────────┐
│     HTTP / REST Controllers         │
├─────────────────────────────────────┤
│     Business Logic Layer            │
│     (Services + Interfaces)         │
├─────────────────────────────────────┤
│     Data Access Layer               │
│     (Repositories + Entities)       │
├─────────────────────────────────────┤
│     Utility & Infrastructure        │
│     (Utils, Config, Exception)      │
└─────────────────────────────────────┘

Key Design Principles

  • Separation of Concerns: Each layer has a single responsibility
  • Dependency Injection: Loose coupling through Spring DI
  • DRY (Don't Repeat Yourself): Utility classes for common operations
  • SOLID Principles: Interface-based design and dependency inversion

📊 Project Structure

src/main/java/com/imperialpedia/api/
│
├── 🎮 controller/
│   ├── DefaultController.java         │ System info endpoint
│   ├── TermController.java            │ Term operation endpoints
│   └── CategoryController.java        │ Category retrieval and CRUD endpoints
│
├── ⚙️ service/
│   ├── TermService.java               │ Core business logic
│   └── CategoryService.java           │ Category operations
│
├── 💾 repository/
│   ├── TermRepository.java            │ Term data access
│   └── CategoryRepository.java        │ Category data access
│
├── 📦 dto/
│   ├── termdto/
│   │   ├── AddTerm.java               │ Create/Update request
│   │   ├── TermDetailResponse.java    │ Detail response
│   │   ├── TermListResponse.java      │ List response
│   │   ├── RelatedTermResponse.java   │ Related term info
│   │   └── Categories.java            │ Category DTO
│   └── InfoResponse.java              │ API info response
│
├── 🗂️ entity/
│   └── term/
│       ├── Term.java                  │ Main entity
│       ├── Category.java              │ Category entity
│       ├── RelatedTerm.java           │ Relationship entity
│       └── TermStatus.java            │ Status enum
│
├── ⚠️ exception/
│   ├── GlobalExceptionHandler.java    │ Centralized error handling
│   ├── ArgumentException.java         │ Input validation errors
│   ├── ResourceNotFoundException.java │ 404 errors
│   ├── ResourceAlreadyExistsException.java │ 409 errors
│   ├── IntegrityViolationException.java    │ Data integrity errors
│   └── TooManyRequestsException.java       │ 429 errors

├── 🚦 filter/
│   └── RateLimitFilter.java           │ Request throttling
│
├── 📤 response/
│   └── ApiResponse.java               │ Response wrapper
│
├── 🛠️ util/
│   └── TermInputUtils.java            │ Pure utility functions
│
├── ⚙️ configuration/
│   ├── ModelMapperConfig.java         │ DTO mapping config
│   ├── OpenApiConfig.java             │ Swagger/OpenAPI setup
│   ├── AppData.java                   │ App metadata
│   └── RateLimitProperties.java       │ Rate-limit rule config
│
└── 📋 interfaces/
    ├── TermServiceInterface.java      │ Term service contract
    └── CategoryServiceInterface.java  │ Category service contract

🔌 API Endpoints

📥 Retrieval Endpoints (GET)

Endpoint Purpose
GET /terms/letter/{letter} Published terms starting with letter
GET /terms/archived?letter=X Archived terms (optional letter filter)
GET /terms/draft?letter=X Draft terms (optional letter filter)
GET /terms/slug/{slug} Term by slug
GET /terms/{id} Term by UUID
GET /addCategories[?letter=X] Categories (all or by starting letter)

Base path: all endpoints are served under /api.

✍️ Creation Endpoint (POST)

Endpoint Purpose
POST /terms/create Create new term
POST /addCategories/create Create new category

🔄 Update Endpoints (PUT/PATCH)

Endpoint Purpose
PUT /terms/update/{id} Full update (all required fields)
PATCH /terms/update/{id} Partial update (optional fields)
PUT /addCategories/update/{id} Full category update
PATCH /addCategories/update/{id} Partial category update

🎛️ Status Endpoints (PUT)

Endpoint Purpose
PUT /terms/publish/{id} Publish term
PUT /terms/draft/{id} Move to draft
PUT /terms/archive/{id} Archive term

🗑️ Deletion Endpoint (DELETE)

Endpoint Purpose
DELETE /terms/delete/{id} Delete term
DELETE /addCategories/delete/{id} Delete category

ℹ️ System Endpoint (GET)

Endpoint Purpose
GET / API info & uptime

💾 Technology Stack

Category Technology Version
Language Java 22
Framework Spring Boot 4.0.4
ORM Hibernate / JPA 7.2.7
Database PostgreSQL 17.8
Build Tool Apache Maven Latest
Mapping ModelMapper Latest
Validation Jakarta Validation API Latest
API Docs SpringDoc / OpenAPI Latest
Logging SLF4J Latest

🧪 Testing & Quality

Test Results

Test Classes:   8
Test Methods:   58
Tests Run:      58/58
Failures:       0
Errors:         0
Success Rate:   100%
Compilation:    32/32 ✅
Warnings:       0

Code Quality Metrics

  • Compilation: 0 errors, 0 warnings
  • Code Organization: Clean layered architecture
  • Error Handling: Centralized with GlobalExceptionHandler
  • Validation: Comprehensive input validation
  • Null Safety: Proper null-checks throughout
  • Naming: Java/Spring best practices
  • Dependencies: All properly resolved

📡 API Response Format

All endpoints return consistent ApiResponse<T> wrapper:

{
  "success": true,
  "statusCode": 200,
  "message": "Operation successful",
  "data": { /* response data */ },
  "timestamp": "2026-03-22T11:13:15"
}

HTTP Status Codes

Code Meaning When
200 OK GET, PUT, PATCH success
201 Created POST success
204 No Content DELETE success
400 Bad Request Validation failed
404 Not Found Resource missing
409 Conflict Duplicate slug
429 Too Many Requests Rate limit exceeded
500 Server Error Unexpected error

🔐 Data Validation

All inputs validated for:

  • ✅ Null/blank checks
  • ✅ Type validation
  • ✅ Length constraints
  • ✅ Pattern validation (slug format)
  • ✅ Uniqueness checks (slugs, addCategories)
  • ✅ Reference existence (related terms)
  • ✅ Self-reference prevention
  • ✅ Automatic normalization (lowercase, trim, deduplicate)

📈 Future Enhancements

Priority enhancements for future versions:

  • 🔐 Authentication & Authorization (Spring Security)
  • 📄 Pagination (for list endpoints)
  • 🔍 Full-Text Search (Elasticsearch)
  • 💾 Caching Layer (Redis)
  • 📊 Audit Trail (request logging)
  • 🔄 Soft Delete (instead of hard delete)
  • 🏷️ API Versioning (v1, v2, etc.)
  • 📱 GraphQL Support (alternative to REST)
  • 🧪 Integration Tests (expanded test suite)

📝 Configuration

Environment Variables

Create .env file in project root (not included in Git):

# Database Configuration
DATABASE_HOST=localhost:5432
DATABASE_NAME=imperialpedia
DATABASE_USERNAME=postgres
DATABASE_PASSWORD=your_password

# App Metadata
APP_NAME="ImperialPedia API"
APP_DESCRIPTION="Backed service for ImperialPedia platform"
APP_VERSION=1.0.0
APP_ENVIRONMENT=local
APP_STATUS=UP

# CORS Configuration
CORS_ALLOWED_ORIGINS=http://localhost:3000
CORS_ALLOWED_ORIGIN_PATTERNS=
CORS_ALLOWED_METHODS=GET,POST,PUT,PATCH,DELETE,OPTIONS
CORS_ALLOWED_HEADERS=*
CORS_EXPOSED_HEADERS=X-Rate-Limit-Remaining,Retry-After
CORS_ALLOW_CREDENTIALS=true
CORS_MAX_AGE=3600

# Server Configuration
SERVER_PORT=8080
SERVER_SERVLET_CONTEXT_PATH=/api

# Logging
LOGGING_LEVEL=INFO

Application Properties

See src/main/resources/application.properties for detailed configuration.

CORS Notes

  • CORS settings are fully configurable using cors.* properties (or CORS_* env variables).
  • When credentials are enabled, wildcard * is not valid for origins/patterns.
  • Default local origin is http://localhost:3000.

🚀 Deployment

Docker (Recommended)

FROM openjdk:22-jdk-slim
COPY target/*.jar app.jar
ENTRYPOINT ["java", "-jar", "/app.jar"]

Manual Deployment

# Build JAR
mvn clean package

# Run JAR
java -jar target/api-0.0.1-SNAPSHOT.jar

📞 Support & Contributing

Reporting Issues

Please report issues with:

  1. Detailed description
  2. Steps to reproduce
  3. Expected vs actual behavior
  4. Environment details

Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


👥 Team

Development Team: Full Stack Development Project Lead: Architecture & Design Last Updated: March 23, 2026


🙏 Acknowledgments

  • Spring Framework Team
  • PostgreSQL Community
  • Hibernate Team
  • Open Source Contributors

Made with ❤️ for Excellence

⬆ Back to Top


About

A comprehensive, enterprise-grade REST API for managing an encyclopedia of terms with advanced categorization, relationships, and multi-status support. Built as a freelance project for Imperialpedia API

Topics

Resources

Stars

Watchers

Forks

Contributors