A powerful backend service built with Node.js and TypeScript, featuring advanced data processing capabilities, AI integration, and real-time communication.
- AI Integration: Built-in support for various AI services including Anthropic and OpenAI
- Real-time Communication: WebSocket support via Socket.IO
- Vector Database: PostgreSQL with pgvector for efficient similarity searches
- File Processing: Support for PDF parsing and multimedia handling
- External Integrations:
- Discord.js for Discord bot functionality
- Telegram integration via Telegraf
- YouTube transcript processing
- Google APIs integration
- Authentication: Privy authentication integration
- Analytics: Amplitude analytics integration
- Rate Limiting: Redis-based rate limiting
- Web Scraping: Playwright and Puppeteer support for advanced web scraping
note: for simple usage use this with The Agentscan frontend
- Node.js (v18.x)
- PostgreSQL (v16 or later)
- Redis
- npm
- Git
- Clone the repository:
git clone git@github.com:ExploreLabsxyz/agentscan-express.git
cd agentscan-express- Install dependencies:
npm install- Copy the environment variables:
cp .env.example .env- Configure your environment variables in
.env
- Install PostgreSQL:
# macOS (using Homebrew)
brew install postgresql@16
# Ubuntu/Debian
sudo apt-get update
sudo apt-get install postgresql-16- Install pgvector from source:
# Clone pgvector repository
cd /tmp
git clone --branch v0.5.1 https://github.com/pgvector/pgvector.git
cd pgvector
make
sudo make install
# Note: If you encounter any build errors, you may need to install build dependencies:
# macOS: xcode-select --install
# Ubuntu/Debian: sudo apt-get install postgresql-server-dev-16 build-essential- Create a local database and set up the postgres user:
# Create the database
createdb agentscan_local
# Set up postgres user with password
psql -d postgres -c "ALTER USER postgres WITH PASSWORD 'postgres';"
# Enable pgvector extension
psql -d agentscan_local -c "CREATE EXTENSION IF NOT EXISTS vector;"- Configure your local environment variables:
# Add these to your .env file
LOCAL_POSTGRES_URL="postgresql://postgres:postgres@localhost:5432/agentscan_local"
LOCAL_POSTGRES_USER=postgres
LOCAL_POSTGRES_HOST=localhost
LOCAL_POSTGRES_DB=agentscan_local
LOCAL_POSTGRES_PASSWORD=postgres
LOCAL_POSTGRES_PORT=5432
LOCAL_POSTGRES_SSL=false
USE_LOCAL_DB=true- Initialize the database schema:
# Generate and apply migrations
npx drizzle-kit generate
npx drizzle-kit pushTo switch between local and production databases:
- For local development: Set
USE_LOCAL_DB=truein your.env - For production: Set
USE_LOCAL_DB=falsein your.env
- Generate migrations:
npm run db:generate- Push schema changes:
npm run db:pushif you get an error try doing:
npm run db:migrateor running this before migrate and or push
psql -d agentscan_local -f src/db/migrations/0000_tired_gauntlet.sql- View database with Drizzle Studio:
npm run db:studioThe project includes functionality to export current database data and seed a local database. This is useful for development and testing purposes.
To export the current state of your database to a seed file:
npm run db:export-seed
# or
node src/db/seed/seed.ts exportThis will create a seed-data.json file in the src/db/seed directory containing your current database state.
To populate your local database with the exported seed data:
npm run db:seed
# or
node src/db/seed/seed.ts seedNote: Seeding operations will only work when USE_LOCAL_DB=true is set in your environment variables. This is a safety measure to prevent accidental modifications to production databases.
If you encounter issues with pgvector:
- Verify the installation:
psql -d agentscan_local -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';"- Common issues:
- If pgvector is not found, ensure you've built and installed it correctly
- If you get a version mismatch, try rebuilding pgvector
- If you get build errors, make sure you have the required development tools installed
Start the development server:
npm run devThe server will be available at http://localhost:4000 (or the port specified in your .env).
- The local database uses the pgvector extension for vector similarity search capabilities
- All tables are created in the public schema
- The database supports vector embeddings with 512 dimensions
- Includes support for HNSW indexes for fast similarity search
npm run dev- Start the development server with hot reloadnpm start- Start the production servernpm run build- Build the TypeScript projectnpm run db:generate- Generate database migrationsnpm run db:push- Push database schema changesnpm run db:studio- Launch Drizzle Studio for database managementnpm run db:export-seed- Export current database statenpm run db:seed- Seed the database with exported data
src/
├── db/ # Database configuration and migrations
├── services/ # Core services and business logic
├── routes/ # API routes and controllers
├── middleware/ # Express middleware
├── utils/ # Utility functions and helpers
|── types/ # TypeScript type definitions
|-- initalizers/ # Initialize provider services (postgres, redis etc)
This project is licensed under the MIT License - see the LICENSE file for details.