|
| 1 | +# WhisperWire |
| 2 | +This repository contains the WhisperWire chat application, consisting of a web frontend, backend API, and supporting infrastructure. |
| 3 | +## Project Structure |
| 4 | +``` |
| 5 | +/ |
| 6 | +├── ww-web/ # Frontend application |
| 7 | +├── ww-api/ # Backend API service |
| 8 | +└── infrastructure/ # Infrastructure configuration |
| 9 | +``` |
| 10 | +## Development Setup |
| 11 | +### Prerequisites |
| 12 | + |
| 13 | +Node.js (v23 or higher) |
| 14 | +Java 23 |
| 15 | +Docker and Docker Compose (eg. through Docker Desktop) |
| 16 | +IntelliJ IDEA (recommended for backend development) |
| 17 | +Minikube (for local Kubernetes development) |
| 18 | + |
| 19 | +### Frontend (ww-web) |
| 20 | +Navigate to the frontend directory: |
| 21 | +```bash |
| 22 | +cd ww-web |
| 23 | +``` |
| 24 | +Install dependencies: |
| 25 | +```bash |
| 26 | +npm install |
| 27 | +``` |
| 28 | +Start the development server: |
| 29 | +```bash |
| 30 | +npm run dev |
| 31 | +``` |
| 32 | +The application will be available at http://localhost:5173/conversations/1. |
| 33 | + |
| 34 | +You can specify the user name by changing the query parameter `userName`, eg. go to http://localhost:5173/conversations/1?userName=Frodo |
| 35 | +### Backend (ww-api) |
| 36 | + |
| 37 | +1. Open the ww-api directory in IntelliJ IDEA |
| 38 | +2. Let the IDE sync the Gradle dependencies |
| 39 | +3. Add a run/debug configuration with: |
| 40 | + |
| 41 | +```bash |
| 42 | +./gradlew bootRun SPRING_PROFILES_ACTIVE=local |
| 43 | +``` |
| 44 | +The API will be available at http://localhost:8080. |
| 45 | + |
| 46 | +### Infrastructure |
| 47 | + |
| 48 | +The application requires Zookeeper, Kafka, and PostgreSQL. Start these services using Docker Compose: |
| 49 | +```bash |
| 50 | +cd infrastructure |
| 51 | +docker compose up |
| 52 | +``` |
| 53 | + |
| 54 | +#### Kafka Topic Setup |
| 55 | +After starting with docker compose, create the required Kafka topic: |
| 56 | +```bash |
| 57 | +docker exec -it kafka kafka-topics \ |
| 58 | + --create \ |
| 59 | + --topic test-topic \ |
| 60 | + --partitions 1 \ |
| 61 | + --replication-factor 1 \ |
| 62 | + --bootstrap-server localhost:9092 |
| 63 | +``` |
| 64 | +## Production-like Environment |
| 65 | + |
| 66 | +### Using Docker Compose |
| 67 | +Run all services in a production-like configuration: |
| 68 | +```bash |
| 69 | +docker compose -f docker-compose-prod.yml up |
| 70 | +``` |
| 71 | + |
| 72 | +### Using Kubernetes (Minikube) |
| 73 | +Start Minikube: |
| 74 | +```bash |
| 75 | +minikube start |
| 76 | +``` |
| 77 | +Load the images into minikube (given that you've built them through docker compose above, if not, do that first through `docker compose -f docker-compose-prod.yml build`): |
| 78 | +```bash |
| 79 | +minikube image load wwapi:latest |
| 80 | +minikube image load wwweb:latest |
| 81 | +``` |
| 82 | +Apply infrastructure configurations: |
| 83 | +```bash |
| 84 | +kubectl apply -f persistent-volumes.yml |
| 85 | +kubectl apply -f persistent-volume-claims.yml |
| 86 | +kubectl apply -f zookeeper.yml |
| 87 | +kubectl apply -f kafka.yml |
| 88 | +kubectl apply -f postgres.yml |
| 89 | +kubectl apply -f jobs/kafka-topic-init.yml |
| 90 | +kubectl apply -f api.yml |
| 91 | +kubectl apply -f www.yml |
| 92 | +``` |
| 93 | +Use port forwarding so that both www and the api can be reached inside the cluster: |
| 94 | +```bash |
| 95 | +kubectl port-forward service/api 8080:8080 |
| 96 | +``` |
| 97 | +Open www: |
| 98 | +```bash |
| 99 | +minikube service www |
| 100 | +``` |
0 commit comments