Skip to content

πŸ€– This project is the backend API server for the Gemini AI Chatbot, supporting inquiries related to Thiago Bardini's career. Using Gemini AI, it connects to a MongoDB database to retrieve initial data and runs in a Node.js environment.

Notifications You must be signed in to change notification settings

thiagobardini/api-chat-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

26 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Demo Report Logo


Chatbot API Server

Description

πŸ€– This project is the backend API server for the Gemini AI Chatbot, which provides specialized support for inquiries related to Thiago Bardini's professional career. Engineered with Gemini AI, this chatbot backend connects to a MongoDB database to retrieve initial data and is configured to run in a Node.js environment.

Technologies Used

  • Node.js: Asynchronous, event-driven JavaScript runtime.
  • Express.js: Web framework for Node.js, used to build the server API.
  • Google Generative AI: AI technology used to generate predictive responses.
  • MongoDB: NoSQL database used to store initial and configuration data.
  • dotenv: Module to load environment variables from a .env file.
  • Nodemon: Tool that automatically restarts the Node.js server on file changes.

Installation

Prerequisites

  • Node.js (version 18.x or higher)
  • MongoDB Atlas or a local MongoDB instance
  • Google Cloud account to access the Google Generative AI API

Steps

  1. Clone this repository:

    git clone git@github.com:thiagobardini/api-chat-server.git
  2. Install project dependencies:

    pnpm install
  3. Create a .env file in the project root with the following environment variables:

    GEMINI_API_KEY="your-google-generative-ai-api-key"
    PORT=8000
    NODE_ENV="development"
    MONGODB_URI="your-mongodb-connection-uri"
    
  4. Start the server:

    pnpm start

The server will run on the port defined in the .env file (default is 3000).

Project Structure

.
β”œβ”€β”€ api/
β”‚   └── index.js           # Main file for the Express server
β”œβ”€β”€ db.js                  # MongoDB connection and data retrieval functions
β”œβ”€β”€ .env                   # Environment variables configuration file
β”œβ”€β”€ package.json           # Project dependencies and scripts
β”œβ”€β”€ README.md              # Project documentation
└── ...                    # Other project files

Endpoints

GET /

Default route to check if the server is running.

  • URL: /
  • HTTP Method: GET
  • Response: Express on Vercel

GET /test-fetch-text

Test route to retrieve initial text from MongoDB.

  • URL: /test-fetch-text
  • HTTP Method: GET
  • Response: Retrieved text: <text>

POST /chat-with-gemini

Main route to interact with the chatbot.

  • URL: /chat-with-gemini

  • HTTP Method: POST

  • Request Body:

    {
      "message": "your message",
      "history": [
        {
          "role": "user",
          "parts": [{ "text": "previous message" }]
        }
      ]
    }
  • Response: Text generated by Google Generative AI

Heroku Commands

To deploy the project to Heroku, use the following commands:

git add .
git commit -m "message"
# if not logged in
heroku login 
git push heroku main
# if add new text to MongoDB run the restart command
heroku restart -a chat-box-portfolio 
heroku logs --tail -a chat-box-portfolio
heroku open -a chat-box-portfolio

Contribution

If you wish to contribute to this project, feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License.

Links

About

πŸ€– This project is the backend API server for the Gemini AI Chatbot, supporting inquiries related to Thiago Bardini's career. Using Gemini AI, it connects to a MongoDB database to retrieve initial data and runs in a Node.js environment.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published