Skip to content

Commit 1b404d0

Browse files
authored
Update README.md
1 parent 0e20c03 commit 1b404d0

1 file changed

Lines changed: 337 additions & 1 deletion

File tree

README.md

Lines changed: 337 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,339 @@
11
# HERMES REST API
22

3-
TODO
3+
HERMES REST API is a Spring Boot service that exposes the server-side capabilities of the HERMES AI component. The project combines a knowledge graph layer, a MongoDB persistence layer, and a planning engine based on PLATINUm to retrieve cultural knowledge, create new cultural entities, and synthesize personalized trips. The repository currently contains a placeholder README in the root, while the actual Java application lives under the `hai/` module.
4+
5+
## About the repository
6+
7+
The repository is described on GitHub as **"HERMES AI Server Component"**. The codebase is written in Java, and the main Maven module is `hai`, a Spring Boot application that depends on Spring Web, Spring Data MongoDB, Apache Jena, and PLATINUm. The application entry point is `HaiRestApi`, which also declares the REST endpoints documented below. citeturn158797view0turn713210view0turn803605view0
8+
9+
## Repository structure
10+
11+
```text
12+
HERMES_REST_API/
13+
├── README.md # currently a placeholder in the repository root
14+
├── hai/ # main Spring Boot application module
15+
│ ├── pom.xml
16+
│ ├── mvnw
17+
│ ├── src/
18+
│ │ ├── main/
19+
│ │ │ ├── java/it/cnr/istc/hermes/hai/
20+
│ │ │ └── resources/
21+
│ │ └── test/
22+
├── resources/
23+
├── hermes_api_tests/
24+
└── target/
25+
```
26+
27+
This layout is based on the public repository tree, which shows the root placeholder `README.md`, the `hai/` Maven module, top-level `resources/`, and test-related folders. Inside `hai/src/main/resources`, the project includes `application.properties`, several RDF/OWL knowledge files, and a `platinum` resource directory. citeturn158797view0turn872002view0turn103635view0turn141464view0
28+
29+
## Features
30+
31+
- REST endpoints for browsing HERMES knowledge topics and cultural entities. citeturn803605view0
32+
- Planning endpoint for generating personalized trips from selected topics and a requested duration. citeturn803605view0turn196169view0
33+
- Endpoint for posting a new cultural entity and attaching a topic-tagged textual description to the knowledge graph. citeturn803605view0turn196169view1
34+
- MongoDB-backed storage for incoming trip requests, generated POIs, planned trips, and posted entity requests. citeturn803605view0turn196169view0turn196169view1turn242977view0turn242977view1
35+
- Knowledge-graph support built on Apache Jena, with a configurable default RDF model loaded at startup or on first use. citeturn713210view0turn803605view0turn803605view1
36+
37+
## Tech stack
38+
39+
- Java
40+
- Spring Boot 3.0.12
41+
- Spring Web / WebFlux / Web Services
42+
- Spring Data MongoDB
43+
- Apache Jena 5.0.0
44+
- PLATINUm 2.3.0
45+
- Maven Wrapper (`mvnw`) in the `hai/` module citeturn713210view0turn872002view0
46+
47+
## Requirements
48+
49+
To run the service locally, you will need:
50+
51+
- Java 17 or newer, which is the baseline for Spring Boot 3.x
52+
- A reachable MongoDB instance
53+
- Access to the HERMES RDF knowledge model file
54+
- A PLATINUm installation or resource directory matching `planner.platinum.home`
55+
56+
The default application configuration expects:
57+
58+
- `knowledge.model.path=${HOME}/HERMES_AI/resources/hermes_20240509.rdf`
59+
- `spring.data.mongodb.uri=mongodb+srv://${MONGO_CLOUD_USER}:${MONGO_CLOUD_PASS}@cluster0.zjmi0.mongodb.net/hermes_ai`
60+
- `spring.data.mongodb.database=hermes_ai`
61+
- `planner.platinum.home=${HOME}/HERMES_AI/resources/platinum` citeturn803605view1
62+
63+
## Getting started
64+
65+
### 1. Clone the repository
66+
67+
```bash
68+
git clone https://github.com/pstlab/HERMES_REST_API.git
69+
cd HERMES_REST_API/hai
70+
```
71+
72+
### 2. Configure the environment
73+
74+
Create or edit the configuration under `hai/src/main/resources/application.properties`, or override the properties with your environment-specific values.
75+
76+
At minimum, check:
77+
78+
- the RDF knowledge model path
79+
- the MongoDB URI and database name
80+
- the PLATINUm home path citeturn803605view1
81+
82+
### 3. Build the application
83+
84+
From the `hai/` directory:
85+
86+
```bash
87+
./mvnw clean package
88+
```
89+
90+
Or, if Maven is installed globally:
91+
92+
```bash
93+
mvn clean package
94+
```
95+
96+
### 4. Run the application
97+
98+
```bash
99+
./mvnw spring-boot:run
100+
```
101+
102+
or
103+
104+
```bash
105+
java -jar target/hai-0.0.1-SNAPSHOT.jar
106+
```
107+
108+
The main class is `it.cnr.istc.hermes.hai.HaiRestApi`. citeturn713210view0turn803605view0
109+
110+
## API overview
111+
112+
The application exposes REST endpoints directly from `HaiRestApi`. The home endpoint is `/`, and the controller also registers a generic `/error` handler. Several knowledge endpoints are declared as `GET` methods but still accept a JSON request body containing a `uri` field. That is unusual for many HTTP clients, so in practice you may prefer to test them with tools such as cURL or Postman that allow bodies on `GET` requests. citeturn803605view0turn196169view2
113+
114+
### Base endpoint
115+
116+
#### `GET /`
117+
Returns a simple health-style greeting string.
118+
119+
Example response:
120+
121+
```text
122+
Hi, this is the HERMES AI Server API endpoint!.
123+
```
124+
125+
#### `GET /error`
126+
Returns a generic error message when request parameters are invalid or missing.
127+
128+
Example response:
129+
130+
```text
131+
OPS! Invalid or missing request parameters!
132+
```
133+
134+
Both endpoints are declared in `HaiRestApi`. citeturn803605view0
135+
136+
## Endpoint reference
137+
138+
### Knowledge endpoints
139+
140+
#### `GET /knowledge/topics`
141+
Returns a taxonomy of available trip topics. The result is a map where each parent topic is associated with its child topics. Topics are built from RDF resources and labels in the knowledge graph. citeturn803605view0turn196169view3
142+
143+
Example response shape:
144+
145+
```json
146+
{
147+
"{parent-topic}": [
148+
{ "id": "<topic-uri>", "label": "Topic label" },
149+
{ "id": "<subtopic-uri>", "label": "Subtopic label" }
150+
]
151+
}
152+
```
153+
154+
#### `GET /knowledge/entities`
155+
Returns all cultural entities belonging to the `CulturalProperty` class, including both tangible and intangible entities. citeturn803605view0turn242977view2
156+
157+
Example response shape:
158+
159+
```json
160+
[
161+
{
162+
"id": "<entity-uri>",
163+
"label": "Entity label",
164+
"tangible": true,
165+
"detailed": true,
166+
"culturalPropertyType": "<ontology-class-uri>"
167+
}
168+
]
169+
```
170+
171+
#### `GET /knowledge/entities2topic`
172+
Returns the cultural entities associated with a specific topic.
173+
174+
Request body:
175+
176+
```json
177+
{
178+
"uri": "<topic-uri>"
179+
}
180+
```
181+
182+
The request uses the `KnowledgeQuery` model, which contains a required `uri` field. citeturn803605view0turn196169view2
183+
184+
#### `GET /knowledge/descriptions`
185+
Returns the contextual descriptions associated with a specific cultural entity.
186+
187+
Request body:
188+
189+
```json
190+
{
191+
"uri": "<entity-uri>"
192+
}
193+
```
194+
195+
The endpoint resolves the URI in the knowledge graph, extracts the cultural entity, and then fetches all of its descriptions. citeturn803605view0
196+
197+
#### `GET /knowledge/entity/data`
198+
Returns detailed data for a specific cultural entity.
199+
200+
Request body:
201+
202+
```json
203+
{
204+
"uri": "<entity-uri>"
205+
}
206+
```
207+
208+
For tangible entities, the returned object can include fields such as visiting time, open hours, coordinates, accessibility flags, price, group visit support, and address. citeturn803605view0turn242977view3
209+
210+
### Planning endpoint
211+
212+
#### `POST /planner/trip`
213+
Generates a personalized trip from a user request. The server:
214+
215+
1. saves the trip request in MongoDB,
216+
2. finds cultural entities related to the requested topics,
217+
3. builds POIs around relevant tangible entities,
218+
4. invokes the PLATINUm-based planner when the total visit time exceeds the requested duration,
219+
5. returns a `PlannedTrip` object. citeturn803605view0turn196169view0turn242977view0turn242977view1
220+
221+
Request body example:
222+
223+
```json
224+
{
225+
"userId": "user-001",
226+
"duration": 240,
227+
"topics": [
228+
{ "id": "<topic-uri>", "label": "Archaeology" },
229+
{ "id": "<topic-uri>", "label": "Architecture" }
230+
],
231+
"groupSize": 2,
232+
"userLocation": [12.4964, 41.9028],
233+
"dVector": [true, false, false],
234+
"mVector": [true, true, false]
235+
}
236+
```
237+
238+
Relevant `TripRequest` fields inferred from the model:
239+
240+
- `userId` - required
241+
- `duration` - required
242+
- `topics` - required, non-empty
243+
- `time` - optional, defaults to request creation time
244+
- `userLocation` - optional `float[]`
245+
- `groupSize` - optional
246+
- `dVector` - optional `boolean[]`
247+
- `mVector` - optional `boolean[]` citeturn196169view0
248+
249+
Response highlights:
250+
251+
- `id`
252+
- `time`
253+
- `duration`
254+
- `hops` - ordered list of POIs
255+
- `request` - the originating trip request
256+
- `ranking`
257+
- `counter` citeturn242977view0
258+
259+
### Knowledge update endpoint
260+
261+
#### `POST /knowledge/entity`
262+
Creates a new knowledge-graph resource for a cultural entity and links it to a generated description tagged with one or more topics. The request is also persisted in MongoDB, and the endpoint returns the URI of the created node. citeturn803605view0turn196169view1
263+
264+
Request body example:
265+
266+
```json
267+
{
268+
"entityLabel": "Traditional Ceramic Workshop",
269+
"text": "A workshop preserving local ceramic techniques and oral traditions.",
270+
"culturalPropertyType": "<cultural-property-class-uri>",
271+
"topics": [
272+
{ "id": "<topic-uri>", "label": "Craftsmanship" }
273+
],
274+
"location": [12.4964, 41.9028],
275+
"groupSize": 10,
276+
"dVector": [false, false, false],
277+
"mVector": [true, false, true]
278+
}
279+
```
280+
281+
Relevant `PostEntityRequest` fields inferred from the model:
282+
283+
- `entityLabel` - required
284+
- `text` - required
285+
- `culturalPropertyType` - required
286+
- `topics` - required, non-empty
287+
- `resourceId` - optional, intended for updates but not yet used in the controller logic
288+
- `time` - auto-initialized
289+
- `location` - optional `float[]`
290+
- `groupSize` - optional
291+
- `dVector` - optional `boolean[]`
292+
- `mVector` - optional `boolean[]` citeturn196169view1turn803605view0
293+
294+
Response example:
295+
296+
```text
297+
http://example.org/resource/GeneratedEntity123
298+
```
299+
300+
### Service data endpoints
301+
302+
#### `GET /service/trips`
303+
Returns all planned trips stored in MongoDB. citeturn803605view0turn242977view0
304+
305+
#### `GET /service/pois`
306+
Returns all generated POIs stored in MongoDB. A POI contains a tangible cultural entity, a set of relevant descriptions, linked entities, ranking data, and usage counters. citeturn803605view0turn242977view1
307+
308+
## Data model summary
309+
310+
### `Topic`
311+
A lightweight object with:
312+
313+
- `id`: knowledge-base URI
314+
- `label`: human-readable topic label citeturn196169view3
315+
316+
### `KnowledgeQuery`
317+
A simple request model used by knowledge lookup endpoints:
318+
319+
- `uri`: required resource identifier citeturn196169view2
320+
321+
### `TripRequest`
322+
Represents the input used to generate a trip. Required fields are `userId`, `duration`, and a non-empty `topics` list. citeturn196169view0
323+
324+
### `PlannedTrip`
325+
Stores a generated itinerary, including requested duration, ordered POI hops, the original request, ranking, and a usage counter. citeturn242977view0
326+
327+
### `Poi`
328+
Represents a generated point of interest built around a tangible cultural entity, enriched with topic-relevant descriptions and linked entities. citeturn242977view1
329+
330+
## Notes and caveats
331+
332+
- The repository root `README.md` is currently just `# HERMES REST API TODO`, so replacing it with this file would immediately improve repository documentation. citeturn884965view0
333+
- The `src` entry at repository root is a symbolic link to `hai/src/main/java`. citeturn512769view0
334+
- Several read endpoints use `GET` together with a request body. Some clients, proxies, and API gateways do not handle GET bodies consistently, so this is worth documenting for users or revisiting in a future API revision. citeturn803605view0turn196169view2
335+
- The controller contains a `TODO` comment indicating that entity creation is not yet complete with all expected data properties. citeturn803605view0
336+
337+
## License
338+
339+
No license file was visible in the repository pages I inspected, so this README intentionally does not declare one. Add a license section once a repository license is published. citeturn158797view0

0 commit comments

Comments
 (0)