Skip to content

A social network built using Quarkus. Includes API testing and telemetry with Prometheus and Grafana

Notifications You must be signed in to change notification settings

jonasfschuh/quarkus-social-network-api

Repository files navigation

Quarkus Social Network API

Java Quarkus Postgres IntelliJ IDEA Swagger Prometheus Grafana Docker Hibernate Apache Maven

This project is an API built useing Quarkus, the Supersonic Subatomic Java Framework. If you want to learn more about Quarkus, please visit its website: https://quarkus.io/.

A simple social network for users to send short texts and follow each other. Contains a Users, Posts and Followers API

  • Java 17
  • Quarkus 3.14.2
  • H2 (tests)
  • PostgreSQL (production)
  • OpenAPI (Swagger)
  • API unit testes
  • Telemetry with Prometheus and Grafana

Table of Contents

Installation

  1. Clone the repository:
git clone https://github.com/jonasfschuh/quarkus-social-network-api.git

Notes:

Configuration

Quarkus starter

https://code.quarkus.io/

NOTE: Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.

Packaging and running the application

The application can be packaged using:

./mvnw package

It produces the quarkus-run.jar file in the target/quarkus-app/ directory. Be aware that it’s not an über-jar as the dependencies are copied into the target/quarkus-app/lib/ directory.

The application is now runnable using java -jar target/quarkus-app/quarkus-run.jar.

If you want to build an über-jar, execute the following command:

./mvnw package -Dquarkus.package.jar.type=uber-jar

The application, packaged as an über-jar, is now runnable using java -jar target/*-runner.jar.

Creating a native executable

You can create a native executable using:

./mvnw package -Dnative

Or, if you don't have GraalVM installed, you can run the native executable build in a container using:

./mvnw package -Dnative -Dquarkus.native.container-build=true

You can then execute your native executable with: ./target/quarkus-social-network-api-1.0-runner

Usage

Running the application in dev mode

  1. Start your PostgreSQL database using Docker or Local

  2. You can run your application in dev mode that enables live coding using:

./mvnw compile quarkus:dev

API Endpoints

The API provides the following endpoints:

Users

    GET /users - Retrieve a list of all registered users 
   POST /users - Create a new user and return the create user´s data
    PUT /users - Update the data of an existing user based on its ID
 DELETE /users - Delete an existing user based on its ID

Posts

    GET /users/{userId}/posts - Retrieve a list of all posts from a specific user
   POST /users/{userId}/posts - Create a new post for a specific user

Followers

    GET /users/{userId}/followers - Retrieve a list of all followers from a specific user
    PUT /users/{userId}/followers - Add a new follower to a specific user
 DELETE /users/{userId}/followers - Delete an existed follower from a specific user 

NOTES: More details about the API endpoints can be found in the Swagger UI, which is available at http://localhost:8080/q/swagger-ui/.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request to the repository.

When contributing to this project, please follow the existing code style, commit conventions, and submit your changes in a separate branch.

Screenshots

Quarkus dev User Interface

API Tests

Swagger-ui

Metrics

Prometheus

Grafana Dashboard

About

A social network built using Quarkus. Includes API testing and telemetry with Prometheus and Grafana

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published