A full-stack movie review app with a backend in Java (Spring Boot), a frontend in JavaScript (React), and a MongoDB database using Dev Container and Docker Compose for ease of development.
It makes development environment as code possible.
This project provides a one-click, ready-to-code development setup using Dev Container, which can be opened using GitHub Codespaces in the cloud or using Visual Studio Code on the local machine (with Docker Desktop and Dev Containers extensions installed).
When the dev container is launched, a MongoDB database service will be spun up automatically (thanks to Docker Compose). The dev container also includes an opinionated set of useful Visual Studio Code extensions. Besides, launch.json and tasks.json files are written to allow users to build and run frontend or backend servers directly in Visual Studio Code.
Those features improve the development experience, eliminating the need to spend time setting up a working, consistent development environment.
- Backend: Java, Spring Boot, JUnit
- Frontend: JavaScript, React, JSX, CSS, Node.js, ESLint, Jest
- Database: MongoDB
- Development: Dev Container, Docker Compose, Visual Studio Code
On GitHub, click Code
> Codespaces
> Create Codespaces on main
. Or click the badge below:
Wait until all Visual Studio Code extensions are installed and activated. Then, in Run and Debug
view, select Backend+Frontend
and press F5
to run both the backend and frontend servers. In Ports
panel, find 3000
and select Open in Browser
to play with the app.
Install software:
In Visual Studio Code, open the project, press F1
to show Command Palette
, and then type and select Dev Containers: Open Folder in Container
.
Same as the GitHub Codespaces instruction above.
Install software:
- Any code editor
- Docker Desktop
- JDK 17
- Node.js 18
- MongoDB 6
Start all services manually.
Database:
cd .devcontainer
docker compose up -d db # Spin up the MongoDB database container using Docker Compose
Backend:
cd backend
./mvnw spring-boot:run # Build and run the backend server
Frontend:
cd frontend
npm install # Install dependencies
npm start # Build and run the frontend server
Open the browser and connect to http://localhost:3000 to play with the app.
The MongoDB database will be seeded using the script in db/seed.sh
and the data in db/seed.json
when the database Docker volume is created.
People doing full-stack development frequently run into the Cross-Origin Resource Sharing (CORS) error, a security check implemented by browsers when making cross-origin frontend API requests to the backend.
This project takes advantage of the proxy feature of Create React App to make the origin (both the host and the port) of API requests to the backend server the same as the frontend app. Thus, the backend does not need to respond with Access-Control-Allow-Origin: *
in the HTTP header, which is not recommended in production.
The dev container includes Thunder Client extension, enabling REST API testing without leaving Visual Studio Code. A collection of backend APIs is written in thunder-tests/thunderclient.json
.
This project uses Jest as its JavaScript test runner. Files with .test.js
suffix can be tested. To run all tests, run:
cd frontend
CI=true npm run test
This project uses ESLint for JavaScript code linting. To lint all js files, run:
cd frontend/src
npx eslint . --ext .js
This project uses JUnit for Java code testing. To run all tests, run:
cd backend
./mvnw test
The dev container includes MongoDB Shell, which can be used to test queries and operations directly with the MongoDB database. To connect to the database, run:
mongosh mongodb://root:example@db
The default hostname is db
, the username is root
, and the password is example
. Those settings can be changed in docker-compose.yml
.
- Ubuntu 2022.04
- OpenJDK 17
- Node.js 18
- MongoDB 6
- Docker
- Extension Pack for Java (Java language server and tools)
- Thunder Client (REST API testing)
- Jest (JavaScript testing)
- ESLint (JavaScript linting)
- Prettier (Code formatting)
- EditorConfig for VS Code
- ES7+ React/Redux/React-Native snippets
- MongoDB for VS Code
- Path Intellisense
- Git Graph
- Git History
- Code Spell Checker
- Resource Monitor
This project is based on the awesome YouTube video by Farhan Hasin Chowdhury and Gavin Lon.