It is a Scala-based project built to demonstrate the use of gRPC, Akka HTTP, and JSON handling libraries for implementing a conversational system. The project integrates AWS SDKs, ScalaPB, and external APIs to process and handle requests efficiently.
- gRPC Integration: Implements a gRPC client and server using ScalaPB and Protobuf.
- Akka HTTP: Provides REST API endpoints for interacting with the system.
- JSON Handling: Supports JSON parsing and serialization using Circe and Spray JSON.
- AWS SDKs: Integrates with AWS Lambda and other AWS services.
- Logging: Uses SLF4J for logging, ensuring structured and detailed logs.
- Testing: Includes unit tests using ScalaTest.
Exercises441/
├── src/
│ ├── main/
│ │ ├── protobuf/ # Protobuf definitions for gRPC
│ │ │ └── lambda_service.proto
│ │ ├── resources/
│ │ │ └── application.conf # Configuration file
│ │ ├── scala/
│ │ ├── routes/ # Akka HTTP routes
│ │ │ └── LambdaRoutes.scala
│ │ ├── services/ # gRPC clients and additional services
│ │ │ ├── LambdaGrpcClient.scala
│ │ │ └── OllamaClient.scala
│ │ ├── AppMain.scala # Main application entry point
│ ├── test/
│ ├── scala/
│ │ ├── LambdaGrpcClientSpec.scala # Tests for LambdaGrpcClient
│ │ ├── OllamaClientSpec.scala # Tests for OllamaClient
├── build.sbt # SBT build definition
├── Docker
├── project/
│ ├── plugins.sbt # SBT plugins
│ └── build.properties # SBT version
└── README.md # Project documentation
- Scala 2.12.13
- SBT 1.8.0 or higher
- Java 11 or higher
- Clone the Repository:
git clone <repository-url>
cd Exercises441
- Install Dependencies: Ensure all dependencies are downloaded:
sbt update
- Compile the Project:
sbt compile
- Run the Application:
sbt run
- Test the Application: Run the test suite:
sbt test
You can run this project using Docker. Follow the steps below:
docker build -t my-scala-server .
docker run -d -p 8080:8080 my-scala-server
List running containers to get the container ID:
docker ps
Use the container ID from the previous step to access the shell:
docker exec -it <container-id> sh
Send a request to the application using curl
:
curl -X POST http://localhost:8080/process-request \
-H "Content-Type: application/json" \
-d '{"prompt": "Hello, can you help me?"}'
- POST /process-request
- Description: Processes a user request and returns a response.
- Request Body:
{
"prompt": "Your query here"
}
- Response Body:
{
"prompt": "Your query here",
"response": "Processed response from the system"
}
Example curl Command:
curl -X POST http://localhost:8080/process-request \
-H "Content-Type: application/json" \
-d '{"prompt": "Hello, can you help me?"}'
You can watch a demonstration of this project in the video below: