Local Development
This guide will help you set up and run AnswerAI in your local development environment for ultimate privacy and control.
Prerequisites
Before you begin, ensure you have the following installed:
Project Structure
AnswerAI is a monorepo project with multiple packages:
Certainly! I'll list out the rest of the @packages folders with descriptions based on the information available in the provided code blocks. Here's an expanded list of the packages:
server
: Node.js backend for API logicui
: React frontendcomponents
: Integration componentsdocs
: Documentation siteembed
: Javascript library to display AnswerAI chatbot on your website
Here's a more detailed breakdown of each package:
-
server
:- Main backend server for AnswerAI
- Handles API logic, database interactions, and server-side operations
- Contains marketplaces and chatflow configurations
-
ui
:- React-based frontend for the AnswerAI application
- Provides the user interface for interacting with AnswerAI
-
components
:- Contains integration components and nodes for AnswerAI
- Includes various LLM models, tools, and utilities
-
docs
:- Documentation site for AnswerAI
- Contains user guides, API documentation, and developer resources
-
embed
:- Javascript library for embedding AnswerAI chatbot on websites
- Provides components and features for full chatbot integration
These packages work together to create the full AnswerAI ecosystem, providing a comprehensive solution for building and deploying AI-powered chatbots and workflows.
Setup
- Clone the repository:
git clone https://github.com/AnswerAI/AnswerAI.git
cd AnswerAI
- Install dependencies:
pnpm install
- Build the project:
pnpm build
Running the Application
To start the application in development mode:
pnpm dev
This command will start both the backend server and the frontend development server. The application will be available at http://localhost:8080.
For production mode:
pnpm start
The application will be available at http://localhost:3000.
Environment Configuration
- Create
.env
files in bothpackages/ui
andpackages/server
directories. - Use the
.env.example
files in each directory as a reference for the required environment variables.
Key environment variables:
packages/ui/.env
: SetVITE_PORT
for the frontend development serverpackages/server/.env
: SetPORT
for the backend server
Development Workflow
- Make changes to the code in
packages/ui
orpackages/server
. - The development server will automatically reload with your changes.
- For changes in
packages/components
, you need to rebuild the project:
pnpm build
Project Configuration
The project uses the following key configurations:
- TypeScript Configuration:
{
"compilerOptions": {
"lib": ["ES2020", "ES2021.String"],
"experimentalDecorators": true /* Enable experimental support for TC39 stage 2 draft decorators. */,
"emitDecoratorMetadata": true /* Emit design-type metadata for decorated declarations in source files. */,
"target": "ES2020", // or higher
"outDir": "./dist/",
"resolveJsonModule": true,
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
"strict": true /* Enable all strict type-checking options. */,
"skipLibCheck": true /* Skip type checking all .d.ts files. */,
"sourceMap": true,
"strictPropertyInitialization": false,
"useUnknownInCatchVariables": false,
"declaration": true,
"module": "commonjs"
},
"include": ["src", "nodes", "credentials"],
"exclude": ["gulpfile.ts", "node_modules", "dist"]
}
- Prettier Configuration:
"prettier": {
"printWidth": 140,
"singleQuote": true,
"jsxSingleQuote": true,
"trailingComma": "none",
"tabWidth": 4,
"semi": false,
"endOfLine": "auto"
},
- Babel Configuration:
"babel": {
"presets": [
"@babel/preset-typescript",
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
]
]
},
Testing
To run end-to-end tests:
pnpm test:e2e
For component tests:
pnpm test:cmp
Documentation
To run the documentation site locally:
cd packages/docs
pnpm start
The documentation will be available at http://localhost:4242.
Troubleshooting
- If you encounter memory issues during build, try increasing the Node.js heap size:
export NODE_OPTIONS="--max-old-space-size=4096"
pnpm build
- Ensure all required environment variables are set correctly in your
.env
files. - For any other issues, check the console output for error messages or refer to the project's issue tracker on GitHub.
Contributing
Please refer to the CONTRIBUTING.md
file in the repository for guidelines on how to contribute to the project.
This guide should help you get started with running AnswerAI locally. If you encounter any issues or have questions, please refer to the project's documentation or reach out to the development team.