Skip to content

noa-portswigger/simple-db-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple DB App

A RESTful API service demonstrating database integration with PostgreSQL, built using Java 21, Jetty, and Google Guice.

Features

  • RESTful API with JSON responses
  • PostgreSQL database integration with connection pooling
  • Dependency injection using Google Guice
  • TOML configuration
  • Docker Compose for local development

Technology Stack

  • 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)

Getting Started

Prerequisites

  • Java 21
  • Docker and Docker Compose

Setup

  1. Generate a random password using echo "$(openssl rand -base64 32)" > .postgres_password

  2. Start the PostgreSQL database:

    docker-compose up -d
  3. 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

API Endpoints

  • GET /api/products - Get all products
  • GET /api/products/{id} - Get product by ID
  • POST /api/products - Create new product

Example Usage

# 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"}'

Development

Build

./gradlew build

Run Tests

./gradlew test

Stop Database

docker-compose down

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages