Database: MongoDB Backend service: Java + Spring API Gateway: Kong Metrics: Prometheus + Grafana
use admin
db.createUser( { user: "WeatherPlatform", pwd: passwordPrompt(), roles: ["readWrite"] }, { w: "majority" , wtimeout: 5000 } )
db.createUser( { user: "WeatherReporting", pwd: passwordPrompt(), roles: [ { "role": "readWrite", "db": "weather" }, { role: "readAnyDatabase", db: "admin" } ] }, { w: "majority" , wtimeout: 5000 } )
The API Gateway is started up with the docker profile gateway
.
You can generate a new secret with
$ export WEATHER_JWT_SECRET=$(openssl rand -hex 32 | base64 -w 0)
$ cd "C:\Program Files\MongoDB\Connector for BI\2.14\bin" && mongosqld.exe /p 27017 /sampleNamespaces weather.weather /schemaName weather /schemaSource weather /schemaMode auto /sampleSize 0 --auth --mongo-username %MONGO_WEATHER_REPORTING% --mongo-password %MONGO_WEATHER_REPORTING_PASSWORD%
First time setup may require port enabling for Prometheus to scrape metrics from services
$ sudo ufw allow 8080 & sudo ufw enable
To start the service
$ mvn clean package
$ docker compose build
- First time only
- [Optional] Startup Database
$ docker compose --profile db up
- If you already have a MongoDB container running you can just bring up the essential services with
$ docker compose up
- You can set up mongo manually using these docs
$ docker run -p 27017:27017 --restart unless-stopped --name mongodb -d mongodb/mongodb-community-server:latest
- If you already have a MongoDB container running you can just bring up the essential services with
- [Docker] Run the service and gateway
$ docker compose --profile gateway --profile service up
- Make changes necessary and add unit tests
- Run the new unit tests to ensure they pass
- Ex.
mvn test -Dtest=WeatherServiceTest#saveWeatherDataTest
- Ex.
- Run all unit tests to ensure nothing broke
mvn clean test
- Start service (see above) and manually smoke test changes
- Add changes with a meaningful commit message
- Push changes to a feature branch and submit a pull request to main branch