A code sharing platform built using spring boot, hibernate and JPA as ORM with PostgreSQL which also follows a RESTful architecture.

Overview

Snap-Snippet


Springboot-version Java-version Gradle-version


A code sharing platform built using spring boot, hibernate and JPA as ORM with PostgreSQL which also follows a RESTful architecture.

Tech


Springboot Thymeleaf Gradle Hibernate PostgreSQL Heroku


Application Features

  • Post Snippet and get a unique id
  • Post Snippet with added restrictions
    • Time restriction
    • Views restriction
    • or Both
  • View top 10 latest unrestricted codes
  • Api features
    • Post
    • View
    • Delete

Build with gradle

Before starting make sure gradle is downloaded. To get started with gradle click here.

For manual installation

After downloading the latest gradle distribution configure your PATH environment variable to include the bin directory of the unzipped distribution.

For Linux & MacOS:
$ export PATH=$PATH:/opt/gradle/gradle-7.2/bin
For Windows:

In File Explorer right-click on the This PC (or Computer) icon, then click Properties -> Advanced System Settings -> Environmental Variables.

Under System Variables select Path, then click Edit. Add an entry for C:\Gradle\gradle-7.2\bin (make sure to unzip the content of the downloaded folder to C:\Gradle). Click OK to save.

To verify the installation open a console (or a Windows command prompt) and run gradle -v to run gradle and display the version, e.g.:

> gradle -v

------------------------------------------------------------
Gradle 7.2
------------------------------------------------------------

Building the project

As gradle is already initialized, after downloading the project all that's left to do is build the project. To build the project run the gradle build command following the gradle clean command.

> gradle clean
Starting a Gradle Daemon (subsequent builds will be faster)

BUILD SUCCESSFUL in 12s
1 actionable task: 1 executed
> gradle build

> Task :test
2021-08-19 13:56:06.991  INFO 12964 --- [ionShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2021-08-19 13:56:06.991  INFO 12964 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2021-08-19 13:56:09.695  INFO 12964 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.

BUILD SUCCESSFUL in 1m 7s
7 actionable tasks: 7 executed

Run application locally

To run the app locally the following changes need to be made to the application.properties file:

# Set the database name as desired
spring.datasource.url=jdbc:postgresql://localhost:5432/snippet
spring.datasource.username=postgres
# Set the password as you desire
spring.datasource.password=Adnanrocks247

Now to set up the database in PostgreSQL we first open the psql shell (to install PostgreSQL, follow this link). After opening the shell press Enter four times and when asked for the password, type in the password used whilst installing PostgreSQL (refer to the previous link).

  1. Login to PostgreSQL
Server [localhost]:
Database [postgres]:
Port [5432]:
Username [postgres]:
Password for user postgres:
psql (13.4)
WARNING: Console code page (437) differs from Windows code page (1252)
         8-bit characters might not work correctly. See psql reference
         page "Notes for Windows users" for details.
Type "help" for help.
postgres=#
  1. Enter the command

CREATE DATABASE snippet;

  1. To make sure the desired database is created enter the \l command to view all the available databases
postgres=# \l
                                                 List of databases
   Name    |  Owner   | Encoding |          Collate           |           Ctype            |   Access privileges
-----------+----------+----------+----------------------------+----------------------------+-----------------------
 postgres  | postgres | UTF8     | English_United States.1252 | English_United States.1252 |
 snippet   | postgres | UTF8     | English_United States.1252 | English_United States.1252 |
 template0 | postgres | UTF8     | English_United States.1252 | English_United States.1252 | =c/postgres          +
           |          |          |                            |                            | postgres=CTc/postgres
 template1 | postgres | UTF8     | English_United States.1252 | English_United States.1252 | =c/postgres          +
           |          |          |                            |                            | postgres=CTc/postgres
(4 rows)
  1. Now rebuild the project or simply use an IDE (preferably Intellij) to run the application and then to view the web app use this link http://localhost:8080/.

Using the Api features

Postman

  • Post a snippet

To post a snippet open Postman then open a Post tab and paste the following link with the following end points https://snap-snippet.herokuapp.com/api/code/new.

Next in the body parameter type in the code with restrictions in the following JSON format:

{
  "code": "Secret code",
  "time": 5000,
  "views": 5
}

If the code is to be posted with no restrictions simply assign 0 to "time" and "views":

{
  "code": "Secret code",
  "time": 0,
  "views": 0
}

The reply should be in a json format with a unique id:

{
  "id": "983fca68-303c-4a52-b55e-87ac3c3b5fb2"
}
  • Get a snippet

To get a snippet open Postman then open a Get tab and paste the following link with the following end points (with the desired unique id) https://snap-snippet.herokuapp.com/api/code/983fca68-303c-4a52-b55e-87ac3c3b5fb2.

The response would be in the following json format:

{
  "code": "Secret code",
  "date": "2021/08/19 09:54:52",
  "time": 3800,
  "views": 4
}
  • Delete a snippet

To delete a snippet open Postman then open a DEL tab and paste the following link with the following end points ( with the desired unique id) https://snap-snippet.herokuapp.com/api/code/delete/983fca68-303c-4a52-b55e-87ac3c3b5fb2.

The response will be a simple Deleted! string message.


Try out the site at: https://snap-snippet.herokuapp.com/


License

License

You might also like...

Spring Kurulumundan Başlayarak, Spring IOC ve Dependency Injection, Hibernate, Maven ve Spring Boot Konularına Giriş Yapıyoruz.

Spring Kurulumundan Başlayarak, Spring IOC ve Dependency Injection, Hibernate, Maven ve Spring Boot Konularına Giriş Yapıyoruz.

Spring Tutorial for Beginners File Directory Apache Tomcat Apache Tomcat - Eclipse Bağlantısı Spring Paketlerinin İndirilmesi ve Projeye Entegrasyonu

Apr 11, 2022

Spring Boot JWT Authentication example with Spring Security & Spring Data JPA

Spring Boot JWT Authentication example with Spring Security & Spring Data JPA

Jan 26, 2022

A Spring Boot Camel boilerplate that aims to consume events from Apache Kafka, process it and send to a PostgreSQL database.

SPRING-BOOT CAMEL BOILERPLATE This is a Spring-Boot Camel Application model that you can use as a reference to study or even to use in your company. I

Apr 4, 2022

参考 DDD/Clean Architecture 设计理念,整合 Spring Boot/Spring Security/Mybatis Plus/Vavr 的 Spring Realworld 应用案例

参考 DDD/Clean Architecture 设计理念,整合 Spring Boot/Spring Security/Mybatis Plus/Vavr 的 Spring Realworld 应用案例

Demo · 更多项目 · 参考资料 ms-spring-ddd-examples Unified Domain-driven Layered Architecture for MicroService Apps,试图探索一套切实可行的应用架构规范,可以复制、可以理解、可以落地、可以控制复杂性的指导

Sep 23, 2022

Spring Boot Debezium Kafka PostgreSQL Relationship

Spring Boot Debezium Kafka PostgreSQL Relationship

spring-boot-debezium-db-kafka Spring-Boot-Debezium-Kafka-PostgreSQL Relationship Installation First,Configure docker-compose.yml Second,Write Db-Kafka

Aug 26, 2022

Movie,actor & director RESTful API. Sample app with jpa, flyway and testcontainers

Movie,actor & director RESTful API. Sample app with jpa, flyway and testcontainers

spring-restful-jpa-flyway Movie,actor & director RESTful API. Sample app with jpa, flyway and testcontainers.

Dec 10, 2022

Multi-Tenant Spring Boot Application with separate databases using Hibernate and H2.

Multi-Tenant Spring Boot Application A Spring Boot application that utilises a multi-tenancy architecture by providing multiple databases, one for eac

May 9, 2022

Not only Spring Boot but also important knowledge of Spring(不只是SpringBoot还有Spring重要知识点)

Not only Spring Boot but also important knowledge of Spring(不只是SpringBoot还有Spring重要知识点)

在线阅读 : https://snailclimb.gitee.io/springboot-guide (上面的地址访问速度缓慢的建议使用这个路径访问) 重要知识点 基础 Spring Boot 介绍 第一个 Hello World 第一个 RestFul Web 服务 Spring 如何优雅读取配

Jan 3, 2023

Cosmic Ink is a transcript application which was built with the help of Symbl AI and At Sign platform for back-end to store our data and authenticate

Cosmic-Ink Cosmic Ink is a transcript application which was built with the help of Symbl AI and At Sign platform for back-end to store our data and au

Dec 1, 2022
Owner
Adnan Hossain
develop, program, AI, coffee☕
Adnan Hossain
The goal of the project is to create a web application using Java EE and database (PostgreSQL) without connecting a modern technology stack like spring boot and hibernate

About The Project SignIn page SignUp page Profile page The goal of the project is to create a web application using Java EE and database (PostgreSQL)

Islam Khabibullin 2 Mar 23, 2022
Dynamically filters JPA entities with a simple query syntax. Provides JPA/Hibernate predicates and Spring Data specifications.

Spring Filter You need a way to dynamically filter entities without any effort? Just add me to your pom.xml. Your API will gain a full featured search

Turkraft 142 Dec 13, 2022
A simple quarkus app with hibernate as ORM, used to show the features of Hibernate Search

beer-manager-hibernate-search Project This project uses Quarkus, the Supersonic Subatomic Java Framework. If you want to learn more about Quarkus, ple

Sedona Solutions 3 Jan 6, 2022
Spring JPA Many To Many example with Hibernate and Spring Boot CRUD Rest API - ManyToMany annotation

Spring JPA Many To Many example with Hibernate and Spring Boot CRUD Rest API - ManyToMany annotation

null 17 Dec 28, 2022
This module explains about the example of Spring MVC + Database Integration with MySQL using Hibernate ORM with practical coding example and required JAR dependencies

SpringMVC-Database-Integration This module explains about the example of Spring MVC + Database Integration with MySQL using Hibernate ORM with practic

GowthamRaj K 3 Nov 2, 2021
This repository contains source code examples to support my course Spring Data JPA and Hibernate Beginner to Guru

Spring Data JPA - Spring Data JPA This repository contains source code examples to support my course Spring Data JPA and Hibernate Beginner to Guru Co

John Thompson 8 Aug 24, 2022
该仓库中主要是 Spring Boot 的入门学习教程以及一些常用的 Spring Boot 实战项目教程,包括 Spring Boot 使用的各种示例代码,同时也包括一些实战项目的项目源码和效果展示,实战项目包括基本的 web 开发以及目前大家普遍使用的线上博客项目/企业大型商城系统/前后端分离实践项目等,摆脱各种 hello world 入门案例的束缚,真正的掌握 Spring Boot 开发。

Spring Boot Projects 该仓库中主要是 Spring Boot 的入门学习教程以及一些常用的 Spring Boot 实战项目教程,包括 Spring Boot 使用的各种示例代码,同时也包括一些实战项目的项目源码和效果展示,实战项目包括基本的 web 开发以及目前大家普遍使用的前

十三 4.5k Dec 30, 2022
循序渐进,学习Spring Boot、Spring Boot & Shiro、Spring Batch、Spring Cloud、Spring Cloud Alibaba、Spring Security & Spring Security OAuth2,博客Spring系列源码:https://mrbird.cc

Spring 系列教程 该仓库为个人博客https://mrbird.cc中Spring系列源码,包含Spring Boot、Spring Boot & Shiro、Spring Cloud,Spring Boot & Spring Security & Spring Security OAuth2

mrbird 24.8k Jan 6, 2023
Applied Spring Data JPA technologies including mapping, connecting real DB, Hibernate, Queries, Paging & Sorting, various Relationships, Transactions

University Management In this project, I practiced & applied Spring Data JPA technologies including mapping, connecting real DB, Hibernate, Queries, P

SarvarKhalimov 2 Sep 5, 2022
Welcome to the EHS robotics club's GitHub repository, this will also be used as our primary community center and means of communication. Also be sure to join our remind for on the go updates @EHSFTC21

NOTICE This repository contains the public FTC SDK for the Ultimate Goal (2020-2021) competition season. Formerly this software project was hosted her

null 5 Feb 25, 2022