This project is a Scala-based implementation designed to replicate the customer endpoints of a specified API using GraphQL. It's containerized with Docker for easy deployment and scalability.
src/main/scala/domain/models
: Contains domain model definitions.src/main/scala/domain/services
: Contains service interfaces and implementations.src/main/scala/infrastructure/repository
: Contains an in-memory repository for simplicity.src/main/scala/api/graphql
: Contains GraphQL schema definitions.src/main/scala/api/routes
: Contains Akka HTTP route definitions.src/main/scala
: Contains the main application entry point.src/test/scala
: Contains the test suite for the project.
- Ensure you have Scala and SBT installed on your machine.
- Clone this repository and navigate to the project directory.
git clone <repository-url>
cd trueml-backend-scala
Run the application using SBT.
sbt run
The server will start and listen on http://localhost:8080. You can send GraphQL queries to http://localhost:8080/graphql.
Build the Docker image
docker run -d -p 8080:8080 trueml-backend-scala
Now the application is running in a Docker container, and you can access it at http://localhost:8080/graphql.
Run the test suite using SBT:
sbt test
The application is containerized using Docker, making it easy to deploy in any environment that supports Docker containers.
Deploying on AWS can be done using Amazon Elastic Kubernetes Service (EKS).
-
Build a Docker Image:
First, build a Docker image of your application.
docker build -t trueml-backend-scala:latest .
-
Push the Docker Image to Amazon Elastic Container Registry (ECR):
Create a repository in ECR and push your Docker image to it.
aws ecr create-repository --repository-name trueml-backend-scala aws ecr get-login-password --region region | docker login --username AWS --password-stdin <account-id>.dkr.ecr.<region>.amazonaws.com docker tag trueml-backend-scala:latest <account-id>.dkr.ecr.<region>.amazonaws.com/trueml-backend-scala:latest docker push <account-id>.dkr.ecr.<region>.amazonaws.com/trueml-backend-scala:latest
-
Create a Kubernetes Cluster on EKS:
eksctl create cluster --name trueml-backend-scala-cluster --nodes 3
-
Deploy the Application to EKS:
Apply the configuration to deploy the application and expose it via a LoadBalancer service:
kubectl apply -f deployment.yaml
-
Access the Application:
After a few minutes, you should be able to access the application via the external IP address provided by the LoadBalancer service. You can find this IP address by running:
kubectl get svc trueml-backend-scala-service
Your application should now be accessible at
http://<external-ip>:80/graphql
.