Welcome to the Backend Service! This service, built with Node.js and Express.js, is designed to handle user requests and generate AI-powered answers. It's secure, scalable, and ready to integrate with a frontend application.
https://youtu.be/DnnjjRh2EZw?si=kTnAi0LJdLj4jl4B
- User Management: Create and manage user accounts.
- AI Integration: Generate answers using AI.
- Authentication & Authorization: Secure endpoints with JWT.
- Scalability: Designed to handle a large number of concurrent users.
- Dockerized: Easy deployment with Docker.
- Prerequisites
- Environment Variables
- Installation
- Running the Application
- Running Tests
- Docker Setup
- API Endpoints
- Architecture Diagram
Make sure you have the following installed:
-
MongoDB -- If you want to set up the DB locally OR
-
MongoDB Atlas --If you want to set up the DB on Cloud for free
Create a .env
file in the root directory and add the following:
MONGO_URI=<Your MongoDB URI>
JWT_SECRET=<Your JWT Secret>
OPENAI_API_KEY=<Your OpenAI API Key>
PORT=5003
Clone the repository and install dependencies:
git clone https://github.com/coderavdhesh/Avdhesh-Gupta-AnswerAi-Backend.git
cd path/to/Avdhesh-Gupta-AnswerAi-Backend
npm install
Start the application:
npm src/app.js
The server will run on http://localhost:5003, locally on your laptop.
Run the tests using Jest:
npm test
Build the Docker Image of the DockerFile:
docker build -t answerai-backend .
Run the Docker container(deploy the app locally):
docker run -p 5003:5003 answerai-backend
Build the Docker Image of the DockerFile, using Docker compose:
docker compose build
Run the Docker container(deploy the app locally):
docker run -p 5003:5003 answerai-backend
Run the Docker container(to run the unit test cases):
docker compose run -t tests
- Auth
POST /api/auth/login : Login a user.
POST /api/auth/logout : Logout a user.
POST /api/auth/refresh : Refresh access token.
- Users
GET /api/users : to reteive all the users in the database
POST /api/users/newUser : Create a new user account.
GET /api/users/:userId : Retrieve a user profile.
GET /api/users/:userId/questions : To retrive all the question of the specific user
- Questions
POST /api/questions: Accept user question and return AI-generated answer.
GET /api/questions/:questionId: Retrieve a specific question and answer by question ID.
Below is a high-level architecture diagram of the service:
This project is licensed under the MIT License. See the LICENSE file for details.