Simple authentication example app built using microservices architecture.
It has few services and client app which consumes these services.
Services are built using: Go, Kafka, Redis, PostgreSQL.
Client is simple ReactJS application.
To start the app quickly with default configurations follow the next steps:
- Create email-service.env file in ./services/email
# SMTP #
SMTP_USER=user_email_address
SMTP_PASS=user_email_password
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
-
Run
docker-compose upto start all services and client app. -
Go to client app and try all services on address:
http://localhost:3000
To start the app with custom configurations follow the next steps:
- Create email-service.env file in ./services/email
# SMTP #
SMTP_USER=user_email_address
SMTP_PASS=user_email_password
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
# KAFKA #
KAFKA_TOPIC=verify-user
KAFKA_CLIENT_ID=kafka-client-id
KAFKA_BROKER_HOST=kafka
KAFKA_BROKER_PORT=9092
- Create redis-storage-service.env file in ./services/redis-storage
# KAFKA #
KAFKA_REG_TOPIC=register-user
KAFKA_VER_TOPIC=verify-user
KAFKA_CLIENT_ID=kafka-client-id
KAFKA_BROKER_HOST=kafka
KAFKA_BROKER_PORT=9092
# REDIS #
REDIS_HOST=redis
REDIS_PORT=6379
- Create user-service.env file in ./services/user
# USER SERVICE #
PORT=8080
# KAFKA #
KAFKA_REG_TOPIC=register-user
KAFKA_VER_TOPIC=verified-user
KAFKA_CLIENT_ID=kafka-client-id
KAFKA_BROKER_HOST=kafka
KAFKA_BROKER_PORT=9092
# REDIS #
REDIS_HOST=redis
REDIS_PORT=6379
- Create user-storage-service.env file in ./services/user-storage
# USER STORAGE SERVICE #
DB_DRIVER=postgres
DB_HOST=database
DB_PORT=5432
DB_NAME=kafka-example
DB_USER=admin
DB_PASS=admin
# KAFKA #
KAFKA_VER_TOPIC=verified-user
KAFKA_CLIENT_ID=kafka-client-id
KAFKA_BROKER_HOST=kafka
KAFKA_BROKER_PORT=9092
- Create auth-service.env file in ./services/auth
# AUTH SERVICE #
PORT=8081
# REDIS #
REDIS_HOST=redis
REDIS_PORT=6379
JWT_SECRET=supersecret
# DB #
DB_DRIVER=postgres
DB_HOST=database
DB_PORT=5432
DB_NAME=kafka-example
DB_USER=admin
DB_PASS=admin
-
Run
docker-compose upto start all services and client app. -
Go to client app and try all services on address:
http://localhost:3000
Note: If you try to use your gmail account to send email, most probably it will fail with error "Username and Password not accepted". You need to enable less secure apps. Check out this link: https://hotter.io/docs/email-accounts/secure-app-gmail/