The evolution of a component-based architecture
See Git tags for step-by-step notes.
git tag -ln
v1 First commit
v2 Functional groups
v3 Feature groups (Bounded Context)
v4 Components
v5 Applications
v6 Services
v7 Databases
v8 Versioning
v9 Service Discovery
v10 Circuit Breaker-
Install redis
brew install redis
-
Modify
/opt/homebrew/etc/redis.conf(/usr/local/etc/redis.confon Intel Macs)requirepass foobared
-
Install mysql
brew install mysql
-
Modify
/opt/homebrew/etc/my.cnf(/usr/local/etc/my.cnfon Intel Macs)default-time-zone='+00:00' -
Database setup
sudo mysql -v -uroot --execute="drop user 'uservices'@'localhost'" sudo mysql -v -uroot --execute="create user 'uservices'@'localhost' identified by 'uservices';" for database_name in 'anime' 'poll'; do sudo mysql -v -uroot --execute="drop database if exists test_${database_name}" sudo mysql -v -uroot --execute="create database test_${database_name}" sudo mysql -v -uroot --execute="grant all on test_${database_name}.* to 'uservices'@'localhost';" sudo mysql -v -uroot --execute="grant select on performance_schema.* to 'uservices'@'localhost';" sudo mysql -v -uroot --execute="drop database if exists dev_${database_name}" sudo mysql -v -uroot --execute="create database dev_${database_name}" sudo mysql -v -uroot --execute="grant all on dev_${database_name}.* to 'uservices'@'localhost';" sudo mysql -v -uroot --execute="grant select on performance_schema.* to 'uservices'@'localhost';" done sudo mysql -v -uuservices -puservices test_anime --execute="select now();"
-
Schema Migrations
flyway -cleanDisabled=false -user=uservices -password=uservices -url="jdbc:mysql://localhost:3306/test_anime" -locations=filesystem:databases/anime-database clean migrate flyway -cleanDisabled=false -user=uservices -password=uservices -url="jdbc:mysql://localhost:3306/test_poll" -locations=filesystem:databases/poll-database clean migrate flyway -cleanDisabled=false -user=uservices -password=uservices -url="jdbc:mysql://localhost:3306/dev_anime" -locations=filesystem:databases/anime-database clean migrate flyway -cleanDisabled=false -user=uservices -password=uservices -url="jdbc:mysql://localhost:3306/dev_poll" -locations=filesystem:databases/poll-database clean migrate
-
Run tests
./gradlew build
Each server is configured through environment variables. Build the runnable jars first:
./gradlew buildStart the discovery server (backed by redis):
PORT=8888 \
REDIS_HOST=localhost \
REDIS_PASSWORD=foobared \
java -jar applications/discovery-server/build/libs/discovery-server.jarThen start each application server (backed by mysql), pointing it at the discovery server:
PORT=8880 \
DISCOVERY_SERVER_ENDPOINT=http://localhost:8888 \
java -jar applications/gateway-server/build/libs/gateway-server.jar
PORT=8881 \
DATABASE_URL="jdbc:mysql://localhost:3306/dev_anime?user=uservices&password=uservices" \
DISCOVERY_SERVER_ENDPOINT=http://localhost:8888 \
java -jar applications/anime-server/build/libs/anime-server.jar
PORT=8882 \
DATABASE_URL="jdbc:mysql://localhost:3306/dev_poll?user=uservices&password=uservices" \
DISCOVERY_SERVER_ENDPOINT=http://localhost:8888 \
java -jar applications/poll-server/build/libs/poll-server.jar
PORT=8883 \
MAL_CLIENT_ID="YOUR_MAL_CLIENT_ID" \
DISCOVERY_SERVER_ENDPOINT=http://localhost:8888 \
java -jar applications/mal-server/build/libs/mal-server.jar| Variable | Used by | Description |
|---|---|---|
PORT |
all servers | Port the server listens on |
DATABASE_URL |
application servers | JDBC URL for the server's mysql database |
REDIS_HOST / REDIS_PASSWORD |
discovery server | Redis connection used for the service registry |
DISCOVERY_SERVER_ENDPOINT |
application servers | Base URL of the discovery server for heartbeats and lookups |
This project is licensed under the Apache License 2.0. It is a derivative work based on application-continuum by initialcapacity.
The original architecture and source files have been modified and adapted for the malchart project, with the original commit history fully preserved.