Spaces:
Sleeping
Sleeping
Merge branch 'main' of https://huggingface.co/spaces/ishans24/microservices
Browse filesFiles changed (2)
- README.md+5-218
- README_.mdAdded+219
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219# Task Management System (Microservices)A Spring Cloud microservice ecosystem for managing tasks with a React front-end. An API Gateway exposes the platform through a single port, Eureka provides service discovery, and MongoDB persists user, task, and submission data. The solution can be run locally with Gradle/npm or containerised end-to-end with Docker Compose.---## OverviewThis project implements a Task Management system using a microservices architecture. The system consists of three main microservices plus infrastructure components:- **TaskUserService** β authentication, JWT issuance, profile and admin endpoints.- **TaskService** β task CRUD, assignment and completion workflows.- **TaskSubmissionService** β submission lifecycle and coordination with other services via OpenFeign.- **EurekaServerConfiguration** β service registry for discovery and health status.- **APIGateway** β Spring Cloud Gateway with resilience policies and CORS/fallback handling.- **task-management-ui** β React SPA consuming the gateway APIs.Additional runtime services in Docker Compose:- **MongoDB** (Docker)- **Zipkin** (Docker) for tracing---## Tech stack- Java 17, Spring Boot 3.2, Spring Cloud 2023.0- Gradle 8- React 18 (Create React App)- Node.js 18+, npm 9+- MongoDB 6- Docker & Docker Compose (Docker Engine 24+, Compose v2 recommended)- Spring Security, Resilience4j, OpenFeign, Micrometer/Zipkin## Repository layout (high level)```APIGateWay/ # Spring Cloud Gateway serviceEurekaServerConfiguration/ # Eureka discovery serverTaskUserService/ # Authentication / User management serviceTaskService/ # Task domain microserviceTaskSubmissionService/ # Submission microservicetask-management-ui/ # React single page applicationbuild-all.sh # Builds all services and UIrun-system.sh # Builds and launches full stack with Composestop-system.sh # Stops the Compose stackdocker-compose.yml # Compose orchestration for services + MongoDB + Zipkin```---## Features (selected)### UserService- `POST /auth/signup` β user registration- `POST /auth/signin` β authentication (returns JWT)- `GET /api/user/profile` β get user profile### TaskService- `POST /api/tasks/create` β create new task (admin only)- `GET /api/tasks/{taskId}` β get task details- `PUT /api/tasks/{taskId}/assign/{userId}` β assign task to user (admin only)### TaskSubmissionService- `POST /api/submissions/submit` β submit completed task (authenticated users)- `GET /api/submissions/{submissionId}` β get submission details---## ConfigurationAll Spring services accept environment overrides (via environment variables or `application-*.properties`) for values such as:| Variable | Applies to | Purpose | Default (local) ||---|---:|---|---:|| `SERVER_PORT` | All Spring services | HTTP port override | service-specific || `SPRING_APP_NAME` | All services | Service identifier / registration name | - || `EUREKA_SERVER_URI` | Gateway & microservices | Eureka discovery endpoint | `http://localhost:8085/eureka` || `MONGODB_URI` | Backends | MongoDB connection string | `mongodb://localhost:27017/<db>` || `ZIPKIN_BASE_URL` | All services | Zipkin tracing endpoint | `http://localhost:9411` || `ZIPKIN_SAMPLER_PROBABILITY` | All services | Tracing sampling rate | `1.0` |Each service also exposes domain-specific properties (JWT secrets, CORS allowed origins, etc.) in its `application.properties`/`application-docker.properties` files. Defaults are safe for local usage but **must** be overridden for production.---## Prerequisites / System requirements- JDK 17+- Node.js 18+, npm 9+- Docker Engine 24+ and Docker Compose v2 (or docker-compose v1)- 8 GB RAM recommended when running full stack locally---## Setup & Running### Option 1 β Full stack via Docker Compose (recommended for quick end-to-end runs)1. (Optional) Create a Docker volume for MongoDB persistence:```bashdocker volume create mongo-data```2. Build and run everything (the `run-system.sh` helper can be used if present):```bash./run-system.sh# ordocker compose up --build```3. Verify services are registered in Eureka (default port shown by the compose file):- Eureka dashboard: `http://localhost:8085`- API Gateway health: `http://localhost:8090/actuator/health`- Zipkin UI: `http://localhost:9411`- React dev UI: `http://localhost:3000` (if using `npm start` instead of build)Stop everything:```bash./stop-system.sh# ordocker compose down```To remove persisted MongoDB data:```bashdocker volume rm mongo-data```### Option 2 β Run services locally (development)1. Start MongoDB locally or via Docker:```bashdocker run -p 27017:27017 --name mongo -d mongo:6.0```2. Start Eureka server:```bashcd EurekaServerConfiguration./gradlew bootRun```3. Start services in separate terminals:```bashcd TaskUserService && ./gradlew bootRuncd TaskService && ./gradlew bootRuncd TaskSubmissionService && ./gradlew bootRuncd APIGateWay && ./gradlew bootRun```4. Start React UI (dev mode):```bashcd task-management-uinpm installnpm start```When running behind the gateway, point the UI to the gateway base URL (example `.env`):```REACT_APP_API_BASE_URL=http://localhost:8090```---## Build### One-step build (bundles backends and UI)```bash./build-all.sh```### Manual builds- Backends: inside each service directory```bash./gradlew clean bootJar -x test```- UI```bashcd task-management-uinpm installnpm run build```---## Troubleshooting- **MongoDB health check fails**: ensure your host CPU supports AVX (required for MongoDB 6), or run a remote MongoDB instance and set `MONGODB_URI` accordingly.- **Port conflicts**: adjust `SERVER_PORT` environment variable for services.- **Gateway CORS errors**: set appropriate `GATEWAY_ALLOWED_ORIGIN_*` and `TASK_ALLOWED_ORIGINS` env vars to match your front-end origin(s).- **Zipkin unreachable**: either run Zipkin container or comment out `ZIPKIN_BASE_URL` in configs to disable tracing.---## Verification checklist- Eureka dashboard shows `USER-SERVICE`, `TASK-SERVICE`, and `TASK-SUBMISSION` as `UP`.- Gateway health endpoint returns `{"status":"UP"}`.- Service actuator health endpoints are available (e.g. `http://localhost:8081/actuator/health`, `:8082`, `:8083`).- MongoDB collections: `users`, `tasks`, `submissions`.---## Notes- Admin-only endpoints are protected by role checks (create/assign tasks).- OpenFeign is used for inter-service HTTP clients.- Production deployments should rotate secrets and secure all JWT keys / database credentials.---## ContributionContributions are welcome β open an issue or submit a PR.## LicenseThis project is licensed under the MIT License.---*Happy shipping! π*123456---title: microservicessdk: dockercolorFrom: greencolorTo: blue---
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219# Task Management System (Microservices)
A Spring Cloud microservice ecosystem for managing tasks with a React front-end. An API Gateway exposes the platform through a single port, Eureka provides service discovery, and MongoDB persists user, task, and submission data. The solution can be run locally with Gradle/npm or containerised end-to-end with Docker Compose.
---
## Overview
This project implements a Task Management system using a microservices architecture. The system consists of three main microservices plus infrastructure components:
- **TaskUserService** β authentication, JWT issuance, profile and admin endpoints.- **TaskService** β task CRUD, assignment and completion workflows.- **TaskSubmissionService** β submission lifecycle and coordination with other services via OpenFeign.- **EurekaServerConfiguration** β service registry for discovery and health status.- **APIGateway** β Spring Cloud Gateway with resilience policies and CORS/fallback handling.- **task-management-ui** β React SPA consuming the gateway APIs.
Additional runtime services in Docker Compose:- **MongoDB** (Docker)- **Zipkin** (Docker) for tracing
---
## Tech stack
- Java 17, Spring Boot 3.2, Spring Cloud 2023.0- Gradle 8- React 18 (Create React App)- Node.js 18+, npm 9+- MongoDB 6- Docker & Docker Compose (Docker Engine 24+, Compose v2 recommended)- Spring Security, Resilience4j, OpenFeign, Micrometer/Zipkin
## Repository layout (high level)
```APIGateWay/ # Spring Cloud Gateway serviceEurekaServerConfiguration/ # Eureka discovery serverTaskUserService/ # Authentication / User management serviceTaskService/ # Task domain microserviceTaskSubmissionService/ # Submission microservicetask-management-ui/ # React single page applicationbuild-all.sh # Builds all services and UIrun-system.sh # Builds and launches full stack with Composestop-system.sh # Stops the Compose stackdocker-compose.yml # Compose orchestration for services + MongoDB + Zipkin```
---
## Features (selected)
### UserService- `POST /auth/signup` β user registration- `POST /auth/signin` β authentication (returns JWT)- `GET /api/user/profile` β get user profile
### TaskService- `POST /api/tasks/create` β create new task (admin only)- `GET /api/tasks/{taskId}` β get task details- `PUT /api/tasks/{taskId}/assign/{userId}` β assign task to user (admin only)
### TaskSubmissionService- `POST /api/submissions/submit` β submit completed task (authenticated users)- `GET /api/submissions/{submissionId}` β get submission details
---
## Configuration
All Spring services accept environment overrides (via environment variables or `application-*.properties`) for values such as:
| Variable | Applies to | Purpose | Default (local) ||---|---:|---|---:|| `SERVER_PORT` | All Spring services | HTTP port override | service-specific || `SPRING_APP_NAME` | All services | Service identifier / registration name | - || `EUREKA_SERVER_URI` | Gateway & microservices | Eureka discovery endpoint | `http://localhost:8085/eureka` || `MONGODB_URI` | Backends | MongoDB connection string | `mongodb://localhost:27017/<db>` || `ZIPKIN_BASE_URL` | All services | Zipkin tracing endpoint | `http://localhost:9411` || `ZIPKIN_SAMPLER_PROBABILITY` | All services | Tracing sampling rate | `1.0` |
Each service also exposes domain-specific properties (JWT secrets, CORS allowed origins, etc.) in its `application.properties`/`application-docker.properties` files. Defaults are safe for local usage but **must** be overridden for production.
---
## Prerequisites / System requirements
- JDK 17+- Node.js 18+, npm 9+- Docker Engine 24+ and Docker Compose v2 (or docker-compose v1)- 8 GB RAM recommended when running full stack locally
---
## Setup & Running
### Option 1 β Full stack via Docker Compose (recommended for quick end-to-end runs)
1. (Optional) Create a Docker volume for MongoDB persistence: ```bash docker volume create mongo-data ```2. Build and run everything (the `run-system.sh` helper can be used if present): ```bash ./run-system.sh # or docker compose up --build ```3. Verify services are registered in Eureka (default port shown by the compose file): - Eureka dashboard: `http://localhost:8085` - API Gateway health: `http://localhost:8090/actuator/health` - Zipkin UI: `http://localhost:9411` - React dev UI: `http://localhost:3000` (if using `npm start` instead of build)
Stop everything:```bash./stop-system.sh# ordocker compose down```
To remove persisted MongoDB data:```bashdocker volume rm mongo-data```
### Option 2 β Run services locally (development)
1. Start MongoDB locally or via Docker: ```bash docker run -p 27017:27017 --name mongo -d mongo:6.0 ```2. Start Eureka server: ```bash cd EurekaServerConfiguration ./gradlew bootRun ```3. Start services in separate terminals: ```bash cd TaskUserService && ./gradlew bootRun cd TaskService && ./gradlew bootRun cd TaskSubmissionService && ./gradlew bootRun cd APIGateWay && ./gradlew bootRun ```4. Start React UI (dev mode): ```bash cd task-management-ui npm install npm start ```
When running behind the gateway, point the UI to the gateway base URL (example `.env`):```REACT_APP_API_BASE_URL=http://localhost:8090```
---
## Build
### One-step build (bundles backends and UI)
```bash./build-all.sh```
### Manual builds
- Backends: inside each service directory```bash./gradlew clean bootJar -x test```- UI```bashcd task-management-uinpm installnpm run build```
---
## Troubleshooting
- **MongoDB health check fails**: ensure your host CPU supports AVX (required for MongoDB 6), or run a remote MongoDB instance and set `MONGODB_URI` accordingly.- **Port conflicts**: adjust `SERVER_PORT` environment variable for services.- **Gateway CORS errors**: set appropriate `GATEWAY_ALLOWED_ORIGIN_*` and `TASK_ALLOWED_ORIGINS` env vars to match your front-end origin(s).- **Zipkin unreachable**: either run Zipkin container or comment out `ZIPKIN_BASE_URL` in configs to disable tracing.
---
## Verification checklist
- Eureka dashboard shows `USER-SERVICE`, `TASK-SERVICE`, and `TASK-SUBMISSION` as `UP`.- Gateway health endpoint returns `{"status":"UP"}`.- Service actuator health endpoints are available (e.g. `http://localhost:8081/actuator/health`, `:8082`, `:8083`).- MongoDB collections: `users`, `tasks`, `submissions`.
---
## Notes
- Admin-only endpoints are protected by role checks (create/assign tasks).- OpenFeign is used for inter-service HTTP clients.- Production deployments should rotate secrets and secure all JWT keys / database credentials.
---
## Contribution
Contributions are welcome β open an issue or submit a PR.
## License
This project is licensed under the MIT License.
---
*Happy shipping! π*README.md+5-218
README_.mdAdded+219