Klark
Klark is a micro SaaS platform that enables intelligent interaction with PDF documents using advanced AI capabilities. Built with modern technologies, it provides document summarization and an AI-powered chat interface for querying document content.
Features
š PDF Document Processing
- Document uploading and storage
- Automatic text extraction and analysis
- Document summarization
š¬ Interactive Chat Interface
- Real-time streaming responses
- Context-aware document querying
- Chat history analysis
- Intelligent question generation
š Security & Authentication
- Secure user authentication via Lucia
- Document access control
- Session management
š³ Payment Integration
- Stripe payment processing
- Subscription management
- Usage tracking
Tech Stack
Frontend
- Next.js with TypeScript
- Tailwind CSS for styling
- ShadCN/UI component library
- tRPC for type-safe API calls
Backend
- LangChain.js for AI operations
- OpenAI API for language processing
- ChromaDB for vector embeddings
- PostgreSQL with Drizzle ORM
- MinIO for PDF storage
- tRPC SSE for real-time streaming
Infrastructure
- Docker for containerization
- Traefik as reverse proxy and load balancer
- GitHub Actions for CI/CD
- Watchtower for automated deployments
Getting Started
Prerequisites
- Node.js 18+
- Docker and Docker Compose
- PostgreSQL
- MinIO
- ChromaDB
- OpenAI API key
Environment Setup
- Clone the repository:
git clone https://github.com/yourusername/klark.git
cd klark
- Install dependencies:
pnpm install
- Create a
.env
file with the following variables:
DATABASE_URL=
OPENAI_API_KEY=
MINIO_ROOT_USER=
MINIO_ROOT_PASSWORD=
MINIO_ENDPOINT=
STRIPE_SECRET_KEY=
STRIPE_WEBHOOK_SECRET=
- Initialize the database:
pnpm db:push
Development
- Start the development environment:
docker-compose -f docker-compose.local.yml up -d
pnpm dev
- Run the setup script:
./scripts/setup.sh
Production Deployment
- Build the application:
pnpm build
- Deploy using Docker Compose:
docker-compose up -d
Project Structure
.
āāā src/
ā āāā app/ # Next.js app router
ā āāā components/ # React components
ā āāā lib/ # Utility functions
ā āāā server/ # Server-side code
ā āāā trpc/ # tRPC configurations
āāā drizzle/ # Database migrations
āāā public/ # Static assets
āāā scripts/ # Utility scripts
Features in Detail
Document Processing
- Automatic text extraction from PDFs
- Document chunking and embedding generation
- Vector storage in ChromaDB for efficient retrieval
Chat Interface
- Real-time streaming responses using tRPC SSE
- Context-aware document querying
- Intelligent follow-up question generation
- Chat history analysis for better context understanding
Authentication & Security
- User authentication and session management with Lucia
- Secure document access control
- Role-based permissions
Contributing
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
License
MIT License
Support
For support, please open an issue in the GitHub repository or contact the maintainers.
Built with ā¤ļø using Next.js.