A microservice application that checks if a number is prime. The application consists of a backend service built with Spring Boot and a frontend built with HTML, CSS, and JavaScript.
- User registration and authentication
- JWT-based security
- Prime number checking
- PostgreSQL database for user storage
- Docker Compose for easy deployment
- Docker and Docker Compose
- Java 17 or higher (for development)
- Maven (for development)
-
Clone the repository:
git clone https://github.com/your-organization/prime-service.git cd prime-service
-
Start the application using Docker Compose:
cd manage-containers ./reboot.sh # On Unix/Mac # OR reboot.bat # On Windows
-
Access the frontend:
- Open the
practicum3/index.html
file in your browser - Or serve it using a simple HTTP server:
Then open http://localhost:8000 in your browser
cd practicum3 python -m http.server 8000
- Open the
-
Start the PostgreSQL database:
docker run -d --name primes-database -p 5001:5432 -e POSTGRES_PASSWORD=password -e POSTGRES_DB=primes postgres:alpine
-
Build and run the Spring Boot application:
mvn clean package java -jar target/prime-service-0.0.1-SNAPSHOT.jar
-
Access the frontend as described above.
-
Register:
POST /auth/register
- Request body:
{ "username": "user", "password": "password" }
- Response: User object
- Request body:
-
Login:
POST /auth/login
- Request body:
{ "username": "user", "password": "password" }
- Response: JWT token
- Request body:
- Check Prime:
GET /primes/{number}
- Requires authentication (JWT token in Authorization header)
- Response:
{ "isPrime": true/false }
- Backend: Spring Boot with Spring Security and JWT authentication
- Database: PostgreSQL for user storage
- Frontend: HTML, CSS, and JavaScript
- Containerization: Docker and Docker Compose
model
: Data models (Customer)repository
: Data access layerservice
: Business logiccontroller
: API endpointssecurity
: Security configuration
index.html
: Main HTML filestyles.css
: CSS stylesscript.js
: JavaScript code for API interaction
- If you encounter database connection issues, ensure PostgreSQL is running and accessible
- Check the logs for detailed error messages
- Ensure the correct environment variables are set in Docker Compose
This project is licensed under the MIT License - see the LICENSE file for details.