diff --git a/README.md b/README.md index 91887ccad..f24502ce7 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Complete documentation is available in the [docs/](./docs/) folder: ## Technology Stack - **Backend**: Java 21, Spring Boot 3.3.2 -- **Frontend**: React 18, TypeScript +- **Frontend**: React 19, TypeScript, Vite - **Build**: Maven - **Testing**: JUnit 5, Jest, PIT mutation testing - **Quality**: SonarCloud, JaCoCo diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md index 1df2002bf..327248ca3 100644 --- a/docs/DEVELOPMENT.md +++ b/docs/DEVELOPMENT.md @@ -440,7 +440,7 @@ mvn clean install # Frontend coverage cd frontend -npm test -- --coverage +npm test # View: coverage/lcov-report/index.html ``` diff --git a/docs/SETUP.md b/docs/SETUP.md index 181a62270..fcb76366b 100644 --- a/docs/SETUP.md +++ b/docs/SETUP.md @@ -130,7 +130,7 @@ cd frontend npm start ``` -This starts a development server on http://localhost:3000 with live reloading. +This starts a development server on http://localhost:5173 with live reloading. **Note**: The development server needs the backend running separately on port 8080. @@ -165,12 +165,22 @@ Main configuration files: **API Endpoint Configuration**: -Edit `frontend/src/constant.ts`: +The frontend uses relative API paths (e.g. `/logic/...`). When served by the Spring Boot JAR both frontend and API share the same origin, so no extra configuration is needed. + +During local frontend development (Vite dev server on port 5173), `vite.config.ts` proxies `/logic` requests to the backend on port 8080: + +```typescript +server: { + proxy: { + '/logic': 'http://localhost:8080', + }, +}, +``` + +The only frontend constant that controls behaviour is the logic type in `frontend/src/constant.ts`: ```typescript -export const API_BASE_URL = process.env.REACT_APP_API_URL || 'http://localhost:8080'; -export const CLASSICAL_API = `${API_BASE_URL}/api/classical`; -export const MODAL_API = `${API_BASE_URL}/api/modal`; +export const LOGIC: string = 'classical'; ``` ## Running Tests @@ -187,7 +197,7 @@ mvn clean test mvn test -pl domain/logic-language/framework ``` -**Run with coverage**: +**Run with coverage (coverage is collected by default)**: ```powershell mvn clean install ``` @@ -196,22 +206,17 @@ Coverage reports are generated in: `target/site/jacoco/index.html` ### Frontend Tests -**Run all tests**: +**Run all tests** (coverage is collected by default): ```powershell cd frontend npm test ``` -**Run with coverage**: -```powershell -npm test -- --coverage -``` - Coverage report: `frontend/coverage/lcov-report/index.html` **Run specific test file**: ```powershell -npm test -- Expressions.test.tsx +npm test -- --testPathPattern=Expressions ``` ## Docker Deployment @@ -345,7 +350,7 @@ cd frontend npm start ``` -Access at: http://localhost:3000 (frontend will proxy API calls to backend) +Access at: http://localhost:5173 — Vite proxies `/logic` requests to the backend on port 8080 (configured in `frontend/vite.config.ts`). ## Integration with IDEs diff --git a/frontend/src/constant.ts b/frontend/src/constant.ts index 3b082537d..0fdf63aae 100644 --- a/frontend/src/constant.ts +++ b/frontend/src/constant.ts @@ -1,3 +1 @@ - -export const BASE_URL: string = "http://localhost:8080/" -export const LOGIC: string = "classical" \ No newline at end of file +export const LOGIC: string = "classical" diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 150d61810..941390a77 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -5,4 +5,9 @@ import react from '@vitejs/plugin-react'; export default defineConfig({ plugins: [react()], publicDir: 'public', + server: { + proxy: { + '/logic': 'http://localhost:8080', + }, + }, });