Skip to content

Danor93/Clarticle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

40 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Clarticle - AI-Powered RAG Chat System

Clarticle is a RAG (Retrieval-Augmented Generation) chat system that enables intelligent conversations about your article collection using Claude AI.

๐Ÿ—๏ธ Architecture Overview

Clarticle uses a hybrid microservices architecture combining Go and Node.js for optimal performance:

%%{init: {'flowchart': {'htmlLabels': false}, 'securityLevel': 'loose'}}%%
graph TD
    subgraph "Clarticle Frontend"
        A[React Client]
    end

    A <--> |HTTP/API| B

    subgraph "Clarticle Backend Services"
        B[Go API Gateway]
        B <--> |HTTP| C
        B --> |Cache| D[Redis Cache]
        C[Node.js RAG Service]
        C <--> |Embeddings| E[FAISS Vector Store]
        C <--> |API| F[Claude AI API]
        C --> |Fetch & Process| G[Web Articles]
    end

    subgraph "Data Layer"
        E --> H[Local Vector Storage]
        I[articles.json]
        J[PostgreSQL Database]
    end

    I --> |Load on Startup| C
    B <--> |SQL| J

    style A fill:#61dafb,stroke:#21262d,stroke-width:2px,color:#000
    style B fill:#0969da,stroke:#21262d,stroke-width:2px,color:#fff
    style C fill:#2ea043,stroke:#21262d,stroke-width:2px,color:#fff
    style D fill:#cf222e,stroke:#21262d,stroke-width:2px,color:#fff
    style J fill:#336791,stroke:#21262d,stroke-width:2px,color:#fff
    style F fill:#fb8500,stroke:#21262d,stroke-width:2px,color:#000
    style G fill:#6e7781,stroke:#21262d,stroke-width:2px,color:#fff
    style I fill:#6e7781,stroke:#21262d,stroke-width:2px,color:#fff
Loading

๐Ÿ“ Project Structure

Article-Chat/
โ”œโ”€โ”€ client/                      # React frontend application
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/          # React components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ui/              # shadcn/ui components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ChatInterface.tsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ArticleManager.tsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Footer.tsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ theme-provider.tsx
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ theme-toggle.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ lib/                 # Utilities and API client
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ api.ts
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ utils.ts
โ”‚   โ”‚   โ”œโ”€โ”€ App.tsx              # Main app component
โ”‚   โ”‚   โ”œโ”€โ”€ main.tsx             # Entry point
โ”‚   โ”‚   โ””โ”€โ”€ index.css            # Global styles
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ”œโ”€โ”€ vite.config.ts           # Vite configuration
โ”‚   โ”œโ”€โ”€ tailwind.config.js       # Tailwind CSS config
โ”‚   โ””โ”€โ”€ README.md                # Frontend documentation
โ”‚
โ”œโ”€โ”€ server/                      # Go backend (API Gateway)
โ”‚   โ”œโ”€โ”€ cmd/
โ”‚   โ”‚   โ””โ”€โ”€ api/
โ”‚   โ”‚       โ””โ”€โ”€ main.go          # Entry point
โ”‚   โ”œโ”€โ”€ internal/                # Private packages
โ”‚   โ”‚   โ”œโ”€โ”€ config/              # Configuration management
โ”‚   โ”‚   โ”œโ”€โ”€ handlers/            # HTTP handlers
โ”‚   โ”‚   โ”œโ”€โ”€ middleware/          # HTTP middleware
โ”‚   โ”‚   โ”œโ”€โ”€ models/              # Data models
โ”‚   โ”‚   โ”œโ”€โ”€ services/            # Business logic
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ rag_client.go    # RAG service client
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ cache.go         # Redis cache service
โ”‚   โ”‚   โ”œโ”€โ”€ validation/          # Input validation
โ”‚   โ”‚   โ”œโ”€โ”€ errors/              # Error handling
โ”‚   โ”‚   โ””โ”€โ”€ workers/             # Worker pools
โ”‚   โ”œโ”€โ”€ go.mod
โ”‚   โ”œโ”€โ”€ go.sum
โ”‚   โ””โ”€โ”€ README.md                # Backend documentation
โ”‚
โ”œโ”€โ”€ rag-service/                 # Node.js RAG service
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ services/            # Core services
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ claude.service.ts
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ embeddings.service.ts
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ faiss-vectorstore.service.ts
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ langchain.service.ts
โ”‚   โ”‚   โ”œโ”€โ”€ routes/              # API routes
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ chat.routes.ts
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ articles.routes.ts
โ”‚   โ”‚   โ”œโ”€โ”€ middleware/          # Express middleware
โ”‚   โ”‚   โ”œโ”€โ”€ utils/               # Utilities
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ errors.ts
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ startup-loader.ts
โ”‚   โ”‚   โ””โ”€โ”€ index.ts             # Entry point
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ”œโ”€โ”€ tsconfig.json
โ”‚   โ”œโ”€โ”€ nodemon.json             # Nodemon config
โ”‚   โ””โ”€โ”€ README.md                # RAG service documentation
โ”‚
โ”œโ”€โ”€ data/                        # Data directory
โ”‚   โ”œโ”€โ”€ articles.json            # Initial articles list
โ”‚   โ””โ”€โ”€ faiss_store/             # Vector store (generated)
โ”‚
โ”œโ”€โ”€ docker-compose.yml           # Docker orchestration
โ”œโ”€โ”€ client.Dockerfile            # Frontend container
โ”œโ”€โ”€ server.Dockerfile            # Backend container
โ”œโ”€โ”€ rag-service.Dockerfile       # RAG service container
โ”œโ”€โ”€ nginx.conf                   # Nginx configuration for frontend
โ”œโ”€โ”€ README.md                    # This file
โ”œโ”€โ”€ INSTALL.md                   # Installation guide

๐Ÿ› ๏ธ Technology Stack

Frontend

  • React 19 with TypeScript
  • Vite for build tooling
  • shadcn/ui component library
  • Tailwind CSS v4 for styling

Backend (API Gateway)

  • Go 1.24+ with Fiber framework
  • PostgreSQL 15 for user authentication and data persistence
  • Worker pools for concurrent request handling
  • Redis for response caching
  • Structured logging with slog

RAG Service

  • Node.js 20+ with Express
  • LangChain.js for RAG pipeline
  • Claude AI (Anthropic) for language model
  • FAISS for local vector storage
  • HuggingFace Transformers for embeddings

Infrastructure

  • Docker & Docker Compose for containerization
  • Multi-stage builds for optimized images
  • PostgreSQL Alpine for lightweight database container

โœจ Key Features

  • User Authentication: Secure user registration, login, and session management
  • Intelligent Chat: Ask questions about your articles and get contextual answers
  • Conversation History: Persistent chat history with conversation management
  • Article Management: Add articles via URL for processing
  • Local Embeddings: Free embeddings using HuggingFace models
  • Response Caching: Lightning-fast repeated queries with Redis
  • Professional UI: Claude/ChatGPT-style interface with animations
  • Error Handling: Comprehensive error handling with detailed error codes
  • Concurrent Processing: Handle multiple users simultaneously

๐Ÿš€ Quick Start

For detailed installation instructions, see INSTALL.md.

# Clone repository
git clone https://github.com/Danor93/Clarticle.git
cd Clarticle

# Setup environment
cp server/.env.example server/.env
cp rag-service/.env.example rag-service/.env
cp client/.env.example client/.env

# Add your Anthropic API key to rag-service/.env
# ANTHROPIC_API_KEY=sk-ant-api03-your-key-here

# Start services
docker-compose up --build

# Access application
open http://localhost:3000

๐Ÿ“‹ Requirements

  • Docker Desktop
  • Anthropic Claude API key
  • 4GB+ RAM recommended
  • Modern web browser

๐ŸŽฏ How It Works

  1. Article Processing: Add articles via URL โ†’ Text extraction โ†’ Chunking โ†’ Embedding generation โ†’ Vector storage
  2. Chat Flow: User question โ†’ Vector search โ†’ Relevant context retrieval โ†’ Claude AI generation โ†’ Response
  3. Caching: Repeated questions are cached for instant responses

๐Ÿ”ง Configuration

Key environment variables:

  • ANTHROPIC_API_KEY: Your Claude API key (required)
  • CLAUDE_MODEL: Model selection (default: claude-3-7-sonnet-latest)
  • CHUNK_SIZE: Text chunk size for embeddings (default: 1000)
  • RAG_SEARCH_RESULTS: Number of context chunks to retrieve (default: 4)

๐Ÿ“Š Performance

  • Response Time: 5-8 seconds (first query), <100ms (cached)
  • Concurrent Users: 10-50 supported
  • Article Processing: 6-8 chunks per article
  • Cache Hit Rate: ~40% in typical usage

๐Ÿ”ฎ Future Enhancements

Potential features for extended development:

  • Streaming Responses: Real-time response streaming
  • Advanced Analytics: User engagement metrics and conversation analytics
  • Multi-tenant Support: Organization and team management
  • Testing Suite: Unit and integration tests
  • K8s Deployment: Kubernetes manifests and CI/CD pipelines

About

Clarticle - Intelligent chat system for conversations about articles using RAG with Claude AI. Hybrid Go + Node.js backend, React frontend. Features article processing, vector search, and contextually accurate AI responses.

Topics

Resources

Stars

Watchers

Forks

Contributors