Skip to content

AIandu/CorePat

Repository files navigation

CorePat: Conversational AI Backend & UI Toolkit

TypeScript Express.js React npm

Rapidly build intelligent interactive experiences with a robust AI chat API backend and a comprehensive modern UI component library.

CorePat is a foundational project designed to accelerate the development of conversational AI applications. It combines a powerful, plug-and-play AI chat API backend built with Express and TypeScript with a comprehensive suite of modern UI components, providing everything you need to quickly launch sophisticated interactive experiences.

Whether you're building custom AI assistants, customer service bots, or internal knowledge platforms, CorePat offers a modular and scalable solution to drastically cut down your development time.

Table of Contents

1. Key Features

CorePat is divided into two primary artifacts, each offering distinct functionalities:

Backend (api-server)

A robust Express.js and TypeScript API designed to handle core conversational AI logic.

  • TypeScript-first Development: Ensures type safety and improves maintainability.
  • Express.js Framework: Provides a fast, unopinionated, and minimalist web framework for Node.js.
  • Dedicated /chat Endpoint: A streamlined API endpoint for sending user messages and receiving AI-generated responses.
  • Integrated AI Client: Designed for seamless integration with various AI models (e.g., OpenAI, Anthropic, etc.) via a flexible client abstraction (src/lib/aiClient.ts).
  • Configurable System Prompt Logic: Easily define and manage AI persona, context, and instructions using src/lib/systemPrompt.ts.
  • Modular Architecture: Organized codebase facilitating easy extension and maintenance.

Frontend (mockup-sandbox)

A comprehensive and modern UI component library, likely built with React, providing a rich toolkit for building sophisticated frontend applications that consume the AI chat service.

  • Extensive Component Library: Includes a wide array of UI components (e.g., Button, Card, Dialog, Form, Input, Carousel, Chart, and many more) designed for modern web applications.
  • Reusable & Customizable: Components are built to be highly reusable and easily themeable or customizable to fit your brand.
  • Designed for Interactivity: Provides the necessary building blocks to create engaging and dynamic user interfaces for conversational AI.
  • Modern Development Workflow: Supports a typical frontend development workflow for rapid prototyping and application building.

2. Getting Started

Follow these instructions to set up and run CorePat on your local machine.

Prerequisites

Make sure you have the following installed:

  • Node.js (v18.x or higher recommended)
  • npm or Yarn (npm is used in examples)

Cloning the Repository

git clone https://github.com/AIandu/CorePat.git
cd CorePat

Backend Setup (artifacts/api-server)

  1. Navigate to the backend directory:

    cd artifacts/api-server
  2. Install dependencies:

    npm install
  3. Create a .env file for environment variables. You'll need to configure your AI provider API key and potentially the server port. A .env.example might be helpful if one exists, otherwise create it manually:

    # Example .env file content (replace with your actual values)
    PORT=3000
    AI_API_KEY=your_ai_provider_api_key_here
    # Add other environment variables as needed, e.g., AI_MODEL_NAME

    Note: The specific AI provider (e.g., OpenAI, Google Gemini, Anthropic) and related environment variables will depend on the implementation within src/lib/aiClient.ts.

  4. Start the API server:

    npm run build # if using `build.mjs` and need to compile first
    npm start     # or npm run dev for development with hot-reloading if configured

    The API server will typically run on http://localhost:3000 (or your configured PORT).

Frontend Setup (artifacts/mockup-sandbox)

  1. Navigate to the frontend directory from the root of the cloned repository:

    cd ../mockup-sandbox
  2. Install dependencies:

    npm install
  3. Start the development server:

    npm run dev # or npm start depending on the project configuration

    The UI component sandbox will typically open in your browser at http://localhost:5173 (or the address indicated in your terminal).

3. API Reference (artifacts/api-server)

The primary endpoint for AI chat interactions is /chat.

POST /chat

Handles incoming user messages and returns AI-generated responses.

  • URL: http://localhost:3000/chat (replace port if different)

  • Method: POST

  • Request Body (JSON):

    {
      "message": "What is the capital of France?"
    }
    • message (string, required): The user's input message to the AI.
  • Success Response (JSON):

    • Code: 200 OK
    • Body:
      {
        "reply": "The capital of France is Paris."
      }
      • reply (string): The AI's generated response.
  • Error Response (JSON):

    • Code: 500 Internal Server Error (or 400 Bad Request for validation errors)
    • Body:
      {
        "error": "An error occurred while processing your request."
      }

4. Using the UI Components (artifacts/mockup-sandbox)

The artifacts/mockup-sandbox directory contains a rich set of modern UI components. These components are designed to be imported and used within a React application (as indicated by .tsx files). You can explore them by running the mockup-sandbox locally.

To use a component, you would typically import it from src/components/ui/ within your React application.

import { Button } from '@/components/ui/button';
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card';

function MyChatApp() {
  return (
    <Card>
      <CardHeader>
        <CardTitle>AI Chat</CardTitle>
        <CardDescription>Start a conversation with our AI assistant.</CardDescription>
      </CardHeader>
      <CardContent>
        {/* Example: Display chat messages */}
        <p>User: Hello!</p>
        <p>AI: Hi there! How can I help you today?</p>
      </CardContent>
      <CardFooter>
        <input type="text" placeholder="Type your message..." />
        <Button>Send</Button>
      </CardFooter>
    </Card>
  );
}

export default MyChatApp;

Refer to the mockup-sandbox/src/App.tsx and the mockup-sandbox/src/components/ui/ directory for a full list and usage examples of the available components.

5. Project Structure

The repository is organized into artifacts containing the primary sub-projects:

CorePat/
├── artifacts/
│   ├── api-server/         # The Express.js TypeScript backend for AI chat functionality
│   │   ├── src/            # Source code for the API server
│   │   │   ├── lib/        # AI client, system prompt logic, utilities
│   │   │   └── routes/     # API endpoints (e.g., chat, health)
│   │   └── package.json    # Backend dependencies and scripts
│   │
│   └── mockup-sandbox/     # The comprehensive modern UI component library
│       ├── src/            # Source code for the UI sandbox and components
│       │   ├── App.tsx     # Main application for demonstrating UI components
│       │   └── components/ # UI components library
│       │       └── ui/     # Individual reusable UI components
│       └── package.json    # Frontend dependencies and scripts
├── .gitignore
├── .replit                 # Replit environment configuration
└── README.md

6. Roadmap & Future Enhancements

CorePat is designed for continuous improvement. Key areas for future development include:

  • Database Integration: Implementing a schema for chat history, user profiles, and AI configurations (see Issue #1).
  • Demo Integration: Providing a concrete example of mockup-sandbox components interacting with the /chat API (see Issue #2).
  • Enhanced AI Modularity: Expanding aiClient.ts to support more AI providers out-of-the-box.
  • Authentication & Authorization: Adding secure user management to the API.
  • Streaming Responses: Implementing server-sent events or WebSockets for real-time AI responses.
  • Comprehensive Documentation: Detailed API documentation (e.g., OpenAPI/Swagger) and component usage guides.

7. Contributing

We welcome contributions to CorePat! If you have suggestions, bug reports, or want to contribute code, please open an issue or submit a pull request.

8. License

This project is licensed under the MIT License - see the LICENSE file for details. (Note: A LICENSE file does not currently exist in the provided context, but it's good practice to include one.)

About

CorePat is a foundational conversational AI API backend with a comprehensive modern UI component library. Built with Express and TypeScript, it offers plug-and-play AI chat functionality and a robust toolkit for rapidly developing intelligent interactive applications like AI assistants, customer service bots, or internal knowledge platforms.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors