A RESTful API service demonstrating database integration with PostgreSQL, built using Java 21, Jetty, and Google Guice.
- RESTful API with JSON responses
- PostgreSQL database integration with connection pooling
- Dependency injection using Google Guice
- TOML configuration
- Docker Compose for local development
- Java 21
- Jetty 12 - HTTP server
- Google Guice 7 - Dependency injection
- PostgreSQL - Database
- HikariCP - Connection pooling
- Jackson - JSON/TOML processing
- Gradle - Build tool (Kotlin DSL)
- Java 21
- Docker and Docker Compose
-
Generate a random password using
echo "$(openssl rand -base64 32)" > .postgres_password -
Start the PostgreSQL database:
docker-compose up -d
-
Build and run the application in dev mode. This will read the database password from
.postgres_password:./gradlew run --args="--dev-mode"
The API will be available at http://localhost:8080
GET /api/products- Get all productsGET /api/products/{id}- Get product by IDPOST /api/products- Create new product
# Get all products
curl http://localhost:8080/api/products
# Get specific product
curl http://localhost:8080/api/products/1
# Create new product
curl -X POST http://localhost:8080/api/products \
-H "Content-Type: application/json" \
-d '{"name":"New Product"}'./gradlew build./gradlew testdocker-compose down