Skip to content

Commit

Permalink
Merge pull request #37 from Arquisoft/Rama-Bruno
Browse files Browse the repository at this point in the history
Implemented a new service called Question Service, which gathers information from Wikidata
  • Loading branch information
uo287983 authored Mar 2, 2025
2 parents cd917ae + 9eddb5c commit e118bd9
Show file tree
Hide file tree
Showing 12 changed files with 5,000 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ First, start the database. Either install and run Mongo or run it using docker:

You can use also services like Mongo Altas for running a Mongo database in the cloud.

Now launch the auth, user and gateway services. Just go to each directory and run `npm install` followed by `npm start`.
Now launch the auth, user, question and gateway services. Just go to each directory and run `npm install` followed by `npm start`.

Lastly, go to the webapp directory and launch this component with `npm install` followed by `npm start`.

Expand Down
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ services:
networks:
- mynetwork

questionservice:
container_name: questionservice-wichat_es4c
image: ghcr.io/arquisoft/wichat_es4c/questionservice:latest
profiles: ["dev", "prod"]
build: ./questionservice
ports:
- "8004:8004"
networks:
- mynetwork


gatewayservice:
container_name: gatewayservice-wichat_es4c
image: ghcr.io/arquisoft/wichat_es4c/gatewayservice:latest
Expand All @@ -58,6 +69,7 @@ services:
- userservice
- authservice
- llmservice
- questionservice
ports:
- "8000:8000"
networks:
Expand All @@ -66,6 +78,7 @@ services:
AUTH_SERVICE_URL: http://authservice:8002
USER_SERVICE_URL: http://userservice:8001
LLM_SERVICE_URL: http://llmservice:8003
QUESTION_SERVICE_URL: http://questionservice:8004

webapp:
container_name: webapp-wichat_es4c
Expand Down
12 changes: 12 additions & 0 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const port = 8000;
const llmServiceUrl = process.env.LLM_SERVICE_URL || 'http://localhost:8003';
const authServiceUrl = process.env.AUTH_SERVICE_URL || 'http://localhost:8002';
const userServiceUrl = process.env.USER_SERVICE_URL || 'http://localhost:8001';
const questionServiceUrl = process.env.QUESTION_SERVICE_URL || 'http://localhost:8004';


app.use(cors());
app.use(express.json());
Expand Down Expand Up @@ -73,6 +75,16 @@ if (fs.existsSync(openapiPath)) {
}


app.get('/question', async (req, res) => {
try {
const response = await axios.get(`${questionServiceUrl}/question`);
res.json(response.data);
} catch (error) {
res.status(error.response?.status || 500).json({ error: error.message });
}
});


// Start the gateway service
const server = app.listen(port, () => {
console.log(`Gateway Service listening at http://localhost:${port}`);
Expand Down
2 changes: 2 additions & 0 deletions questionservice/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
coverage
20 changes: 20 additions & 0 deletions questionservice/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use an official Node.js runtime as a parent image
FROM node:22

# Set the working directory in the container
WORKDIR /usr/src/questionservice

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install app dependencies
RUN npm install

# Copy the app source code to the working directory
COPY . .

# Expose the port the app runs on
EXPOSE 8004

# Define the command to run your app
CMD ["node", "question-service.js"]
Loading

0 comments on commit e118bd9

Please sign in to comment.