Backend to the clone of the popular social media platform reddit
- Technology Stack
- Getting Started
- Documentation
- Explore the APIs
- Runing the tests
- Deployment
- Contributing
- Reporting Issues and Suggesting Improvements
- Versioning
- Authors
- License
- Acknowledgments
- JDK - Java™ Platform, Standard Edition Development Kit
- Spring Boot - Framework to ease the bootstrapping and development of new Spring Applications
- Maven - Dependency Management
- Lombok - Never write another getter or equals method again, with one annotation your class has a fully featured builder, Automate your logging variables, and much more.
- Swagger - Open-Source software framework backed by a large ecosystem of tools that helps developers design, build, document, and consume RESTful Web services.
- git - Free and Open-Source distributed version control system
- gitignore.io - Create useful .gitignore files for your project.
- Dependabot - Automated dependency updates.
- Postman - API Development Environment (Testing Docmentation)
- Mailtrap - Safe Email Testing for Staging & Development.
- Contributor Covenant - Used for the Code of Conduct.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
- You need to have MySQL installed on your machine to run the application in
dev
profile. Using theMySQL Workbench
or on any other MySQL client/console, create a database/schema namedreddit_clone
.
-- create schema
CREATE SCHEMA reddit_clone;
-- use schema
USE reddit_clone;
-- Create user
create user 'reddit_clone'@'localhost' identified by 'reddit_clone';
-- Grant privileges to user
grant all privileges on *.* to 'reddit_clone'@'localhost' with grant option;
After creating the database/schema, you need to add your MySQL username
and password
in the application-dev.properties
file on src/main/resource
. The lines that must be modified are as follows:
spring.datasource.url=jdbc:mysql://localhost:3306/reddit_clone?useSSL=false&allowPublicKeyRetrieval=true
spring.datasource.username=reddit_clone
spring.datasource.password=reddit_clone
- A Java Keystore File is required to generate JSON Web Token.
keytool -genkey -alias redditclone -keyalg RSA -keystore redditclone.jks -keysize 2048
There are several ways to run a Spring Boot application on your local machine. One way is to execute the main
method in the io.github.anantharajuc.rc.RedditCloneApplication
class from your IDE.
- Download the zip or clone the Git repository.
- Unzip the zip file (if you downloaded one)
- Open Command Prompt and Change directory (cd) to folder containing pom.xml
- Open Eclipse
- File -> Import -> Existing Maven Project -> Navigate to the folder where you unzipped the zip
- Select the project
- Choose the Spring Boot Application file (search for @SpringBootApplication)
- Right Click on the file and Run as Java Application
Alternatively you can use the Spring Boot Maven plugin like so:
$ git clone https://github.com/Spring-Boot-Framework/Reddit-Clone.git
$ cd Reddit-Clone
$ mvn spring-boot:run
The code can also be built into a jar and then executed/run. Once the jar is built, run the jar by double clicking on it or by using the command
$ git clone https://github.com/Spring-Boot-Framework/Reddit-Clone.git
$ cd Reddit-Clone
$ mvn package -DskipTests
$ java -jar target/Reddit-Clone-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev
To shutdown the jar, follow the below mentioned steps on a Windows machine.
- In command prompt execute the jcmd command to print a list of all running Java processes
- Taskkill /PID PROCESS_ID_OF_RUNNING_APP /F execute this command by replacing the PROCESS_ID_OF_RUNNING_APP with the actual process id of the running jar found out from executing the previous command
- Swagger -
http://localhost:8080/swagger-ui.html
- Documentation & Testing - Postman Collection for offline testing is available in the documents folder.
URL | Method |
---|---|
http://localhost:8080/actuator/ |
GET |
Username | Password | Role | Permission | Resource |
---|---|---|---|---|
johndoe |
password |
PERSON |
/user |
|
AdminUser |
password |
ADMIN |
PERSON_CREATE,PERSON_READ,PERSON_UPDATE,PERSON_DELETE |
/user |
AdminTraineeUser |
password |
ADMINTRAINEE |
PERSON_READ |
/user |
URL | Method | Remarks | Sample Valid Request Body |
---|---|---|---|
http://localhost:8080/api/v1/auth/signup |
POST | JSON | |
http://localhost:8080/api/v1/auth/verification/{verification-token} |
GET | ||
http://localhost:8080/api/v1/auth/login |
POST | Bearer Token, Refresh Token is generated | JSON |
http://localhost:8080/api/v1/subreddit |
POST | Bearer Token should be passed for authorization | JSON |
http://localhost:8080/api/v1/auth/refresh/token |
POST | Refresh Token from login should be passed | JSON |
{
"username":"johndoe",
"email":"domain@example.com",
"password":"abcd1234"
}
{
"username":"johndoe",
"password":"abcd1234"
}
{
"name":"my-cool-subreddit",
"description":"My subreddit for all thing cool."
}
{
"token":"1178cd43-21d2-45b4-8b5f-c79aa1d5b76e",
"username":"johndoe"
}
$ mvn test //Run all the unit test classes.
Explain what these tests test and why
Give an example
Explain what these tests test and why
Give an example
Add additional notes about how to deploy this on a live system
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
This Project uses GitHub's integrated issue tracking system to record bugs and feature requests. If you want to raise an issue, please follow the recommendations below:
- Before you log a bug, please search the issue tracker to see if someone has already reported the problem.
- If the issue doesn't already exist, create a new issue
- Please provide as much information as possible with the issue report.
- If you need to paste code, or include a stack trace use Markdown +++```+++ escapes before and after your text.
We use SemVer for versioning. For the versions available, see the tags on this repository
- Anantha Raju C - @AnanthaRajuC
See also the list of contributors who participated in this project.
-
This project is licensed under the MIT License - see the LICENSE.md file for details
-
FOSSA third-party code, license compliance and vulnerabilities
- https://github.com/SaiUpadhyayula/spring-reddit-clone is used as a starting point/reference for this project.