Skip to content

EOL, React/TS/Tailwind Css + Spring Boot/Java/Hibernate + Docker & CI/CD

Notifications You must be signed in to change notification settings

Jantero93/forum

Repository files navigation

Full stack forum project

Project is a simple forum where you can register users, create topics and posts. Boards, topics and posts can be readed by anyone, but you have to be registered to create new topics or posts.


Project is somewhat done, probably no new features incoming At least for some time I'm trying keep production link alive. And maybe fix some minor bugs.

Production link: http://35.158.214.245/

Due to costs, prod is down for now. App is easily tested with docker locally on own computer. Instructions on this page.

Features coming:

  • Users can upvote posts Done
  • All tests run on pipeline Done
  • Users can edit posts in one hour from creation Done
  • Images can be attached to posts Probably never going for this
  • Long term goal: Put this application running on AWS or Azure Done (AWS EC2)

On dev and local (docker) environments automatically is generated admin user for testing purposes Username: admin, password: root


Features

  • Individual users with roles
  • Users can delete own posts. Admin can delete any posts
  • Boards are predefined at the moment
  • Users can create topics
  • Users can upvote posts (one upvote per post)
  • Users can update own posts one hour from creation. Admin can update anypost anytime.
  • Secure authentication with JSON Web Token

Techonologies:

Frontend

  • React + (TypeScript)
  • Tailwind CSS
  • React router V6
  • Nginx (only when dockerizing product application)

Backend (REST API)

  • Spring Boot 3.1.2 (Java 17)
  • Hibernate (PostgreSQL; using 15.1, other versions should be fine)
  • Controller-Service-Repository -pattern

Testing

  • Frontend unit tests: Jest
  • Frontend E2E tests: Cypress
  • Backend unit tests JUnit 5
  • Backend API tests: Spring Boot RestTemplate

Others

  • Docker (not needed for local developing, only used for creating prodcution application and for testing on pipeline)
  • GitHub Actions pipeline
  • AWS (EC2)

How to run project with docker (local mode)

In root folder run command

docker-compose -f "docker-compose.yml" --env-file .env.local up --build

All needed configurations and env variables are in Git. Application will be hosted on localhost port 80 (Nginx)

How to run project locally (development mode)

Next tools need to be installed to run this locally:

  • Node 18
  • Java 17
  • PostgreSQL 15.1 (some other versions may be ok, not tested)
  • Maven 3.9.1 (some other versions may be ok, not tested)

Frontend

In folder web-app

Install packages npm install

Or if you want exactly like package-lock.json, then npm ci

Start frontend in development mode npm run dev

Dev server starts on port 3000

Backend (with Maven)

In backend-forum folder run command next commands

Install packages mvn install -DskipTests=true

And run project on development mode mvn spring-boot:run -Dspring-boot.run.profiles=dev

Project starts on port 8080

Postgres

Create database called java-forum. Hibernate will automatically populate all needed database tables. Testing environment needs database java-forum-test


Testing

All tests are run on pipeline (GitHub Actions) when pushing / making pull request on master branch

Run tests locally

Frontend

Install packages if not already installed. In web-app folder run command

npm ci

Run unit tests with command npm test

Run e2e tests with command npm run test:e2e Before that start dev server on port 3000 npm run dev or npm run preview

Backend

In folder backend-forum start Spring Boot instance on port 8080 (default). Api tests will be run against on this instance.

mvn spring-boot:run -Dspring-boot.run.profiles=test

After that run command

mvn test -DargLine="-Dspring.profiles.active=test"

Command runs all unit & api tests in test env