Application developed during a Programmer Event, the Full Cycle Learning Experience promoted by @FullCycleSchool
| Overview | Technologies | Project | Run | Author |
This project is one application of a complete Full Cycle Chat project to talk in real time with Chat-GPT, with amazing technologies like NextJS for front-end, Back-End for Front-end with NextJS, Next Auth + Keyclock for Authentication and Users management, MySQL database, GO Lang for microsservice, Docker and the power of Chat-GPT with real time reactive data and gRPC communication.
This microsservice propurse it's basically connect with Chat-GPT and handle with this data. Creating and managing Chats, receiving a message and calculating a response, all communication doesn't use REST & JSON's but gRCP that is more fast, light and economic. Using MySQL as DataBase.
- Front-End & Back-End : NextJS | [ repositories ]
- microsservice : GO Lang | [ repositories ]
- Go Lang
- Chat-GPT - [OpenAI]
- Docker
- gRPC
- Protobuf
- Performance
- MySQL
- Tiktoken
- Viper
- uuid
- Gotenv
- Chi
- Streams
- Real Time
- Multi Thread & Concurrency
- Scalability
Among Others...
This API open a webserver stream connection that receive chat status and datas in real time from Front-End, connect with Chat-GPT using OpenAI Client and send a "pre-message" that gives to GPT a little context of this chat, storage the messages and tokens in order, calculate the specific used model token limit and when hit the token limit i keep in other storage the old tokens, it gives to us a best control of GPT context and avoid unforeseens and extra expenses, with this in mund, the API connect with MySQL Database to create or update the current chat and messages. GPT-Chat will read all valid tokens and analize the chat context to give a response incrementally, so the API will receive from GPT and send to Front-End piece by piece of GPT response in real time
This API is a Hybrid and support a REST connection, but i recomend to use gRPC for a better experience.
API Examples: ./api/chat.http
###
POST http://localhost:8081/chat HTTP/1.1
Content-Type: application/json
Authorization: 123456
{
"user_id": "1",
"user_message": "Olรก, qual รฉ o seu nome?"
}
###
POST http://localhost:8081/chat HTTP/1.1
Content-Type: application/json
Authorization: 123456
{
"chat_id": "a14fc851-7e95-49b5-a5b5-44479434becd",
"user_id": "1",
"user_message": "Quero saber mais sobre arquitetura de software"
}
POST http://localhost:8081/chat HTTP/1.1
Content-Type: application/json
Authorization: 123456
{
"chat_id": "a14fc851-7e95-49b5-a5b5-44479434becd",
"user_id": "1",
"user_message": "continue"
}
###
$ git clone "git@github.com:Samuel-Ricardo/GPT-Chat_Service.git"
$ git pull "git@github.com:Samuel-Ricardo/GPT-Chat_Service.git"
This application use Docker
so you dont need to install and cofigurate anything other than docker on your machine.
Once Docker is setup, we can start the project :D
# After setup docker environment just run this commmand on root project folder:
$ docker-compose up --build # For First Time run this command
$ docker-compose up # to run project
#Apps Running on:
$ MySQL: http://localhost:3306
$ API - REST: http://localhost:8081
$ API - gRPC: localhost:50052
See more: ./docker-compose.yaml
- You need to set your own GPT data on
.env
, get a free API key from OpenAI [ Click Here ].
First, you need to setup the GO Lang Microsservice, click on image bellow to setup it
Now, you can setup this NextJS App, click on image bellow to setup it
- Samuel Ricardo