This repository contains the code for a Conversational Agent Application, developed as part of a technical recruitment test for an alternant/developer position focusing on SaaS Fullstack development. The application is designed to store and retrieve conversations between users and chatbots.
The application consists of two main parts:
-
API:
- Provides endpoints to retrieve conversations.
- Allows listing the 20 most recent conversations.
- Permits fetching all messages belonging to a specific conversation by its ID.
-
Frontend Application:
- Displays the 20 most recent conversations.
- Allows users to view messages belonging to a specific conversation.
Each conversation includes:
- Conversation ID
- One or more messages (each with a text content)
- Participants (bot and user)
- Number of messages in the conversation
- Conversation date
The objective of this exercise is to implement a basic version of the application. The following results are expected:
- Documentation for using the API.
- Documentation for running both the API and Frontend projects locally.
- TypeScript
- Express
- ReactJS
- PostgreSQL
Make sure you have Node.js and PostgreSQL installed on your machine.
Clone the project from GitHub:
git clone [email protected]:Drackass/Tolkai_test.git
cd Tolkai_test
cd server
npm install
- Create a PostgreSQL database with the name "tolkai" (or update the db.js file with your preferred name).
- Copy the contents of db_example.js into a new db.js file in the same directory.
- Fill in the connection information to your database in the db.js file.
tsc --watch
node --watch dist/index.js
The server should be accessible at http://localhost:5000.
Make sure you have Node.js installed on your machine.
cd client
npm install
npm start
The React application should open in your browser at http://localhost:3000.
Your PERN application is now configured. Ensure that the backend server is running with the node --watch .\server\index.js
command during development.
Adjust paths and commands based on your specific project structure.
http://localhost:5000
Request:
- Endpoint:
POST /conversations
- Description: Create a new conversation.
- Request Body:
user_id
(integer): User ID.assistant_id
(integer): Assistant/Bot ID.title
(string): Conversation title.
{
"user_id": 1,
"assistant_id": 2,
"title": "Sample Conversation"
}
Response:
- Status Code: 200 OK
- Response Body:
- Details of the created conversation.
{
"conversation_id": 1,
"user_id": 1,
"assistant_id": 2,
"title": "Sample Conversation",
"timestamp": "2023-12-13T12:34:56Z"
}
For more API documentation, refer to @API_DOC.md.
- PostgreSQL (Postgres) - Installation & Overview |ยฆ| SQL Tutorial |ยฆ| SQL for Beginners By Socratica
- PERN Stack Course - Postgres, Express, React, and Node By freeCodeCamp
- TypeScript Tutorial #1 - Introduction & Setup By Net Ninja
For detailed setup instructions, refer to @SETUP.md.