Skip to content

spiderocious/askaboutme-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AskAboutMe Platform

AI-powered digital knowledge twin platform where users create comprehensive profiles through conversational onboarding, and guests can ask questions answered by AI.

Features

  • AI-Powered Onboarding: Dynamic questionnaire that adapts based on user responses
  • Semantic Search: Vector embeddings for intelligent question matching
  • Background Processing: Async normalization of Q&As into structured data
  • Rate Limiting: Per-user and site-wide limits
  • Three-Tier System: Free, Pro, and Business tiers
  • Admin Panel: User management, tier configuration, job monitoring

Tech Stack

  • Backend: Node.js 18+, Express, TypeScript
  • Database: PostgreSQL 15+ with pgvector extension
  • Cache: node-cache (in-memory)
  • Queue: Custom database-backed queue
  • AI: OpenAI API (GPT-4 + text-embedding-3-small)

Prerequisites

  • Node.js 18+
  • Docker and Docker Compose
  • OpenAI API key

Quick Start

1. Clone and Install

git clone <repository-url>
cd askaboutme
npm install

2. Set Up Environment

cp .env.example .env

Edit .env and add your configuration:

# Required
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/askaboutme
JWT_SECRET=your-secret-key-here
OPENAI_API_KEY=sk-your-openai-key-here

# Optional
ADMIN_EMAIL=admin@example.com
ADMIN_PASSWORD=secure-password

3. Start Database

docker-compose up -d

This starts PostgreSQL in a Docker container.

4. Run Migrations

npm run migrate

5. Seed Database (Optional)

npm run seed

This creates an admin user if ADMIN_EMAIL and ADMIN_PASSWORD are set.

6. Start Development Server

# Terminal 1: API Server
npm run dev

# Terminal 2: Background Workers
npm run worker

The API will be available at http://localhost:3000.

API Documentation

Health Check

GET /health

Authentication

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - Login
  • GET /api/auth/me - Get current user
  • PUT /api/auth/password - Change password
  • DELETE /api/auth/account - Delete account

Onboarding

  • GET /api/onboarding/session - Get/create onboarding session
  • POST /api/onboarding/answer - Submit answer
  • POST /api/onboarding/complete - Complete onboarding
  • GET /api/onboarding/resume - Resume incomplete session

Profile Management

  • GET /api/profile/overview - Get profile overview and stats
  • GET /api/profile/qas - Get Q&A history (paginated, filterable)
  • PUT /api/profile/qas/:id - Update a Q&A answer
  • DELETE /api/profile/qas/:id - Delete a Q&A
  • GET /api/profile/entities - Get extracted entities
  • POST /api/profile/reprocess - Reprocess all Q&As
  • GET /api/profile/guest-questions - Get questions from guests
  • POST /api/profile/guest-questions/:id/improve - Improve guest answer

Guest Interaction

  • GET /api/ask/:username - Get user's public profile
  • POST /api/ask/:username - Ask a question
  • GET /api/ask/:username/conversation/:conversationId - Get conversation history
  • GET /api/ask/:username/rate-limit - Check rate limit status

Admin Panel

  • GET /api/admin/users - List all users (paginated, filterable)
  • GET /api/admin/users/:userId - Get user details
  • POST /api/admin/users/:userId/suspend - Suspend user
  • POST /api/admin/users/:userId/unsuspend - Unsuspend user
  • DELETE /api/admin/users/:userId - Delete user
  • GET /api/admin/stats - Get platform statistics
  • GET /api/admin/tier-configs - Get tier configurations
  • PUT /api/admin/tier-configs/:tierName - Update tier config
  • GET /api/admin/jobs - List background jobs

Tiers & Settings

  • GET /api/tiers/current - Get current tier info
  • GET /api/tiers/available - List available tiers
  • POST /api/tiers/upgrade - Request tier upgrade
  • GET /api/settings - Get user settings
  • PUT /api/settings - Update settings
  • PUT /api/settings/visibility - Update profile visibility

Background Jobs

  • GET /api/jobs - List user's jobs
  • GET /api/jobs/:jobId - Get job status
  • GET /api/jobs/status - Get jobs overview

See docs/tech-doc.md for complete API documentation.

Project Structure

/src
  /db               - Database connection and migrations
  /middleware       - Auth, validation, rate limiting
  /queue            - Bull queue and job processors
  /routes           - API route handlers
  /services         - Business logic layer
  /types            - TypeScript type definitions
  /utils            - Helpers and utilities
  app.ts            - Express app configuration
  index.ts          - API server entry point
  worker.ts         - Background worker entry point
/docs               - Documentation
  prd.md           - Product Requirements
  tech-doc.md      - Technical Implementation
  architecture-decisions.md - Architecture decisions

Development Commands

npm run dev          # Start API server in development mode
npm run worker       # Start background worker
npm run build        # Compile TypeScript
npm run start        # Start production server
npm run migrate      # Run database migrations
npm run seed         # Seed database
npm test             # Run tests
npm run commitico "message"  # Commit changes

Testing

# Run all tests
npm test

# Run with coverage
npm run test:coverage

Production Deployment

  1. Build the project:
npm run build
  1. Set production environment variables

  2. Run migrations:

npm run migrate
  1. Start services:
# Start API server
npm start

# Start worker (in separate process)
npm run worker

Environment Variables

See .env.example for all available configuration options.

Documentation

License

MIT

Support

For issues and questions, please open an issue on GitHub.

About

AskAboutMe allows users to create an AI-powered digital knowledge twin of themselves. Users complete an onboarding questionnaire, then system uses AI to build a comprehensive knowledge base. Others can then interact with this knowledge base through a chat interface, asking questions and receive answers as if they were talking to the user directly.

Resources

Stars

Watchers

Forks

Contributors