An open API service indexing awesome lists of open source software.

https://github.com/tecteluy/ask-my-bot

A high-performance, AI-powered chatbot built with Go 1.24.6 featuring Post-Quantum Cryptography (PQC) implementation using Cloudflare CIRCL. This project demonstrates enterprise-grade Go architecture with clean code patterns, advanced security features, and AI/ML integration.
https://github.com/tecteluy/ask-my-bot

api gin golang gorm jwt oauth2 post-quantum-cryptography rag-chatbot rbac swagger

Last synced: 2 months ago
JSON representation

A high-performance, AI-powered chatbot built with Go 1.24.6 featuring Post-Quantum Cryptography (PQC) implementation using Cloudflare CIRCL. This project demonstrates enterprise-grade Go architecture with clean code patterns, advanced security features, and AI/ML integration.

Awesome Lists containing this project

README

          

# Ask My Bot 🤖 - AI-Powered Chat Platform

A high-performance, AI-powered chatbot built with **Go 1.24.6** featuring **Post-Quantum Cryptography (PQC)** implementation using Cloudflare CIRCL. This project demonstrates enterprise-grade Go architecture with clean code patterns, advanced security features, and AI/ML integration.

[![Go Version](https://img.shields.io/badge/Go-1.24.6-blue.svg)](https://golang.org)
[![PQC](https://img.shields.io/badge/PQC-Kyber768-green.svg)](https://github.com/cloudflare/circl)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Docker](https://img.shields.io/badge/Docker-supported-blue.svg)](https://docker.com)

## � Key Features

### **🔐 Post-Quantum Cryptography (PQC)**
- **Cloudflare CIRCL Integration**: Production-ready PQC implementation
- **Kyber768 KEM Algorithm**: NIST-standardized lattice-based encryption
- **Quantum-Safe Operations**: Key generation, encapsulation, and decapsulation
- **Future-Proof Security**: Protection against quantum computer attacks

### **🤖 AI-Powered Chat System**
- **OpenAI GPT Integration**: Intelligent responses using latest AI models
- **Vector Similarity Search**: Semantic analysis using PostgreSQL pgvector
- **Contextual Conversations**: Memory-aware chat interactions
- **Real-time Processing**: WebSocket support for live communication

### **🏗️ Enterprise Go Architecture**
- **Clean Architecture**: Service/Repository pattern implementation
- **Dependency Injection**: Modular and testable component design
- **Interface-Driven**: Pluggable service architectures
- **SOLID Principles**: Maintainable and scalable codebase

### **🛡️ Advanced Security**
- **OAuth 2.0 Integration**: Google and GitHub authentication
- **JWT Token Management**: Secure session handling
- **Role-Based Access Control**: Admin and user permission systems
- **Security Middleware**: CORS, rate limiting, and request validation

### **� Production Features**
- **PostgreSQL + pgvector**: Advanced database with vector operations
- **Comprehensive Testing**: Unit and integration test coverage
- **Docker Support**: Containerized deployment ready
- **API Documentation**: OpenAPI/Swagger specifications
- **Health Monitoring**: Service health checks and observability

## 🛠️ Technology Stack

### **Backend Technologies**
- **Go 1.24.6** - Latest Go version with enhanced performance
- **Gin Framework** - High-performance HTTP web framework
- **GORM** - Type-safe ORM for database operations
- **PostgreSQL 15+** - Advanced relational database
- **pgvector** - Vector similarity search extension
- **Cloudflare CIRCL** - Post-Quantum Cryptography library
- **JWT** - Secure token-based authentication
- **Viper** - Configuration management
- **Docker** - Containerization and deployment

### **AI & ML Integration**
- **OpenAI API** - GPT models for intelligent responses
- **Vector Embeddings** - Semantic search and similarity
- **Real-time Processing** - WebSocket communication

### **Security & Authentication**
- **OAuth 2.0** - Google and GitHub integration
- **JWT Tokens** - Stateless authentication
- **CORS Protection** - Cross-origin request security
- **Rate Limiting** - Request throttling
- **Post-Quantum Cryptography** - Future-proof encryption

## 🏗️ Architecture Overview

```
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Next.js UI │────│ Go Backend │────│ PostgreSQL │
│ (Port 3000) │ │ (Port 8080) │ │ + pgvector │
│ │ │ │ │ │
│ - React 19 │ │ - Gin Framework │ │ - User Data │
│ - TypeScript │ │ - GORM ORM │ │ - Chat History │
│ - Tailwind CSS │ │ - PQC Service │ │ - Embeddings │
│ - NextAuth │ │ - AI Service │ │ - Quantum Keys │
└─────────────────┘ └─────────────────┘ └─────────────────┘

┌─────────────────┐
│ External APIs │
│ │
│ - OpenAI GPT │
│ - Google OAuth │
│ - GitHub OAuth │
└─────────────────┘
```

### **Core Service Architecture**

```go
// Main service interfaces
type Services struct {
Auth AuthService // Authentication & authorization
Chat ChatService // Chat conversation management
Vector VectorService // Embedding operations
AI AIService // OpenAI integration
CV CVService // Content management
User UserService // User operations
PqCrypto PqCryptoService // Post-Quantum Cryptography
}

// PQC Service Example
type PqCryptoService interface {
GenerateKeyPair(ctx context.Context, algorithm PQCAlgorithm) (*PQCKeyPair, error)
Encapsulate(ctx context.Context, publicKey []byte) ([]byte, []byte, error)
Decapsulate(ctx context.Context, ciphertext []byte, privateKey []byte) ([]byte, error)
}
```

## 📋 Prerequisites

- **Go 1.21+** - [Download Go](https://golang.org/dl/)
- **PostgreSQL 15+** - [PostgreSQL Installation](https://www.postgresql.org/)
- **pgvector Extension** - [pgvector Setup](https://github.com/pgvector/pgvector)
- **Docker & Docker Compose** - [Docker Installation](https://docs.docker.com/get-docker/) (optional)
- **OpenAI API Key** - [Get API Key](https://platform.openai.com/api-keys)
- **OAuth Apps** - Google/GitHub OAuth credentials for authentication

## 🚀 Quick Start

### 1. Clone the Repository

```bash
git clone https://github.com/tecteluy/ask-my-bot.git
cd ask-my-go-bot
```

### 2. Environment Setup

```bash
# 4. Environment Setup
# Copy environment template
cp .env.example .env.local

# Edit with your configuration
vim .env.local (set AI_PROVIDER=openai and OPENAI_API_KEY)
```

### 3. Database Setup (Docker - Recommended)

```bash
# Start PostgreSQL with pgvector
docker-compose up -d db

# Or use local PostgreSQL
# createdb askmygobot
# psql askmygobot -c "CREATE EXTENSION vector;"
```

### 4. Install Dependencies & Run

```bash
# Install Go dependencies
go mod download

# Run database migrations
make migrate

# Seed with sample data
make seed

# Start development server
make dev
```

### 5. Access the Application

- **API Server**: http://localhost:8080
- **API Documentation**: http://localhost:8080/docs (OpenAPI/Swagger)
- **Health Check**: http://localhost:8080/api/health
- **Frontend UI**: http://localhost:3000 (if using the Next.js frontend)

## 🔧 Development

### Available Commands

```bash
# Development
make dev # Start development server with hot reload
make test # Run all tests
make test-coverage # Run tests with coverage report
make lint # Run linter
make fmt # Format code

# Database
make migrate # Run database migrations
make migrate-down # Rollback migrations
make seed # Seed database with sample data
make db-reset # Reset database (caution!)

# Build & Deploy
make build # Build production binary
make docker-build # Build Docker image
make docker-up # Start all services with Docker
make docker-down # Stop all Docker services

# Documentation
make docs # Generate/serve API documentation
make serve-docs # Start documentation server
```

### Project Structure

```
ask-my-go-bot/
├── cmd/
│ └── server/ # Application entry point (main.go)
├── internal/
│ ├── api/ # HTTP routes and handlers
│ ├── auth/ # Authentication logic
│ ├── chat/ # Chat service implementation
│ ├── config/ # Configuration management
│ ├── database/ # Database connection and migrations
│ ├── handlers/ # HTTP request handlers
│ ├── middleware/ # HTTP middleware (CORS, auth, etc.)
│ ├── models/ # Data models and structures
│ ├── repositories/ # Data access layer
│ └── services/ # Business logic (AI, PQC, etc.)
├── migrations/ # Database schema migrations
├── scripts/ # Utility scripts
├── web/ # Static files and templates
├── docs/ # Documentation
├── docker/ # Docker configurations
├── .env.example # Environment template
├── docker-compose.yml # Docker services configuration
├── Makefile # Development commands
└── go.mod # Go dependencies
```

## 🐳 Docker Deployment

### Development with Docker

```bash
# Start all services
docker-compose up -d

# View logs
docker-compose logs -f app

# Execute commands in container
docker-compose exec app go test ./...
```

### Production Deployment

```bash
# Build and deploy
docker-compose -f docker-compose.prod.yml up -d

# Health check
curl http://localhost:8080/api/health
```

## 🔧 Configuration

### Environment Variables

| Variable | Description | Default | Required |
|----------|-------------|---------|----------|
| `PORT` | Server port | `8080` | No |
| `DATABASE_URL` | PostgreSQL connection string | - | Yes |
| `OPENAI_API_KEY` | OpenAI API key | - | Yes |
| `JWT_SECRET` | JWT signing secret | - | Yes |
| `GOOGLE_CLIENT_ID` | Google OAuth client ID | - | Yes |
| `GOOGLE_CLIENT_SECRET` | Google OAuth secret | - | Yes |
| `GITHUB_CLIENT_ID` | GitHub OAuth client ID | - | Yes |
| `GITHUB_CLIENT_SECRET` | GitHub OAuth secret | - | Yes |
| `ADMIN_EMAILS` | Comma-separated admin emails | - | No |
| `CORS_ORIGINS` | Allowed CORS origins | `*` | No |
| `LOG_LEVEL` | Logging level (debug, info, warn, error) | `info` | No |

### Database Configuration

The application requires PostgreSQL with the pgvector extension:

```sql
-- Enable vector extension
CREATE EXTENSION IF NOT EXISTS vector;

-- Example vector column
ALTER TABLE cv_sections ADD COLUMN embeddings vector(1536);
```

## 📚 Additional Documentation

- **[Development Setup](docs/development-setup.md)** - Detailed setup instructions
- **[Architecture Guide](docs/architecture.md)** - System design and components
- **[PQC Architecture](docs/pqc-architecture.md)** - Post-Quantum Cryptography details
- **[API Documentation](docs/api.md)** - REST API reference
- **[Deployment Guide](docs/deployment.md)** - Production deployment
- **[Contributing Guidelines](docs/contributing.md)** - How to contribute
- **[Troubleshooting](docs/troubleshooting.md)** - Common issues and solutions

## 🤝 Contributing

We welcome contributions! Please see our [Contributing Guidelines](docs/contributing.md) for details.

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## 📄 License

This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.

## 🙏 Acknowledgments

- **[Gin Web Framework](https://gin-gonic.com/)** - High-performance HTTP framework
- **[GORM](https://gorm.io/)** - Developer-friendly ORM for Go
- **[Cloudflare CIRCL](https://github.com/cloudflare/circl)** - Post-Quantum Cryptography library
- **[pgvector](https://github.com/pgvector/pgvector)** - Vector similarity search for PostgreSQL
- **[OpenAI](https://openai.com/)** - AI language models and APIs
- **[Next.js](https://nextjs.org/)** - React framework for the frontend UI

## 📞 Support & Contact

- **� Issues**: [GitHub Issues](https://github.com/tecteluy/ask-my-bot/issues)
- **� Discussions**: [GitHub Discussions](https://github.com/tecteluy/ask-my-bot/discussions)
- **📧 Email**: For enterprise support and inquiries

---

**Made with ❤️ Have a lot of fun...**