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

https://github.com/nikvince/ai-chat-interface

Privacy-first AI chat interface where users provide their own OpenAI API keys. Built with React + Vite frontend and Node.js/Express backend featuring secure API proxy, real-time messaging, and responsive design. No data stored on servers.
https://github.com/nikvince/ai-chat-interface

chat express javascript nodejs openai portfolio privacy react tailwind vite

Last synced: 3 months ago
JSON representation

Privacy-first AI chat interface where users provide their own OpenAI API keys. Built with React + Vite frontend and Node.js/Express backend featuring secure API proxy, real-time messaging, and responsive design. No data stored on servers.

Awesome Lists containing this project

README

          

# AI Chat Interface

[![University](https://img.shields.io/badge/University-IU%20International%20University-blue)](https://iu.org)
[![Course](https://img.shields.io/badge/Course-DLBCSPJWD01-green)](https://github.com/NikVince/ai-chat-interface)
[![Assignment](https://img.shields.io/badge/Assignment-Portfolio%20Project-orange)](https://github.com/NikVince/ai-chat-interface)
[![License](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
[![Phase](https://img.shields.io/badge/Development%20Phase-3%20of%203-green)](https://github.com/NikVince/ai-chat-interface)
[![Grade](https://img.shields.io/badge/Academic%20Grade-99%2F100-brightgreen)](https://github.com/NikVince/ai-chat-interface)

## ๐Ÿ“š Academic Context

This project was developed as part of the **Project Java and Web Development (DLBCSPJWD01)** portfolio assignment at **IU International University**. The assignment followed a structured three-phase approach designed to demonstrate comprehensive understanding of modern full-stack web development principles.

**๐ŸŽ“ Academic Achievement: 99/100 Grade**
This project successfully demonstrated mastery of full-stack web development, achieving the highest possible score in the course evaluation.

---

## ๐Ÿ—๏ธ Architecture Overview

```
ai-chat-interface/
โ”œโ”€โ”€ backend/ # Express API server
โ”‚ โ”œโ”€โ”€ middleware/ # Express middleware (e.g., validation)
โ”‚ โ”œโ”€โ”€ routes/ # API route definitions (e.g., chat.js)
โ”‚ โ”œโ”€โ”€ utils/ # Backend utilities (e.g., openai.js)
โ”‚ โ”œโ”€โ”€ test/ # Backend test helpers and route tests
โ”‚ โ”œโ”€โ”€ tests/ # (empty/reserved for future tests)
โ”‚ โ”œโ”€โ”€ node_modules/ # Backend dependencies
โ”‚ โ”œโ”€โ”€ package.json # Backend dependencies/config
โ”‚ โ””โ”€โ”€ server.js # Main server file
โ”œโ”€โ”€ frontend/ # React + Vite + Tailwind frontend
โ”‚ โ”œโ”€โ”€ src/
โ”‚ โ”‚ โ”œโ”€โ”€ components/ # React components (ChatInterface, MessageList, etc.)
โ”‚ โ”‚ โ”œโ”€โ”€ hooks/ # Custom React hooks (useChat.js)
โ”‚ โ”‚ โ”œโ”€โ”€ utils/ # Frontend utility functions
โ”‚ โ”‚ โ”œโ”€โ”€ assets/ # Static assets (e.g., react.svg)
โ”‚ โ”‚ โ”œโ”€โ”€ test/ # Frontend test setup
โ”‚ โ”‚ โ”œโ”€โ”€ App.jsx # Root component
โ”‚ โ”‚ โ”œโ”€โ”€ main.jsx # Vite entry point
โ”‚ โ”‚ โ”œโ”€โ”€ App.css # App-level styles (Tailwind only)
โ”‚ โ”‚ โ””โ”€โ”€ index.css # Tailwind base styles
โ”‚ โ”œโ”€โ”€ public/ # Static public assets (favicons, manifest, etc.)
โ”‚ โ”œโ”€โ”€ cypress/ # E2E test setup (fixtures, support, e2e)
โ”‚ โ”œโ”€โ”€ dist/ # Production build output
โ”‚ โ”œโ”€โ”€ node_modules/ # Frontend dependencies
โ”‚ โ”œโ”€โ”€ package.json # Frontend dependencies/config
โ”‚ โ”œโ”€โ”€ tailwind.config.js # Tailwind CSS config
โ”‚ โ”œโ”€โ”€ vite.config.js # Vite config
โ”‚ โ”œโ”€โ”€ vitest.config.js # Vitest config
โ”‚ โ”œโ”€โ”€ postcss.config.cjs # PostCSS config
โ”‚ โ””โ”€โ”€ README.md # Frontend-specific documentation
โ”œโ”€โ”€ docs/ # Project documentation (design, tests, deployment)
โ”œโ”€โ”€ docs_assignement/ # Assignment transcript and requirements
โ”œโ”€โ”€ docs_phase3/ # Phase 3 deliverables (abstract, screencast, etc.)
โ”œโ”€โ”€ instructions/ # Project instructions and checklists
โ”œโ”€โ”€ .github/ # GitHub workflows and templates
โ”œโ”€โ”€ .vercel/ # Vercel deployment config
โ”œโ”€โ”€ node_modules/ # Root dependencies (if any)
โ”œโ”€โ”€ package.json # Root dependencies/config
โ”œโ”€โ”€ package-lock.json # Root lockfile
โ”œโ”€โ”€ vercel.json # Vercel monorepo deployment config
โ”œโ”€โ”€ env.example # Example environment variables
โ”œโ”€โ”€ LICENSE # License file
โ””โ”€โ”€ README.md # Main project documentation
```

- **Backend:** Node.js, Express.js. RESTful API, modular middleware, secure proxy for OpenAI, input validation, and rate limiting. All API endpoints are defined in `backend/routes/`.
- **Frontend:** React 18, Vite, Tailwind CSS. Functional components, custom hooks, mobile-first responsive design, and all UI logic in `frontend/src/`.
- **Testing:**
- **Frontend:** Unit tests (Vitest), E2E structure (Cypress)
- **Backend:** API and route tests (Mocha, helpers)
- **Documentation:** All design, test, and deployment docs in `/docs`. Assignment and requirements in `/docs_assignement`. Phase 3 deliverables in `/docs_phase3`.
- **Deployment:** Monorepo setup for Vercel, with configuration in `vercel.json` and `.vercel/`.

> **For the architecture diagram and detailed design choices, see [docs/design_choices_and_changes.md](docs/design_choices_and_changes.md).**

---

## ๐Ÿ› ๏ธ Installation & Setup

### Prerequisites
- Node.js (v18 or higher)
- npm (v8 or higher)
- OpenAI API key (optional, demo mode available)

### Quick Start
1. Clone the repository:
```bash
git clone https://github.com/NikVince/ai-chat-interface.git
cd ai-chat-interface
```
2. Install dependencies:
```bash
npm install
cd frontend && npm install
cd ../backend && npm install
```
3. Create environment files:
```bash
# In backend directory
cp .env.example .env
# Edit .env with your configuration
```
4. Start development servers:
```bash
# From root directory
npm run dev
```
5. Access the application:
- Frontend: http://localhost:5173
- Backend: http://localhost:3000

### Environment Variables
Create a `.env` file in the backend directory with:
```env
PORT=3000
NODE_ENV=development
FRONTEND_URL=http://localhost:5173
```

---

## ๐Ÿš€ Features (Summary)

- Real-time chat interface with OpenAI integration
- Settings management (API key, model selection)
- **Demo mode** for evaluation without API key
- Responsive design (mobile-first)
- Secure API key handling (never exposed to frontend)
- Error handling and loading states
- Rate limiting and CORS protection
- **Export Chat Transcript** (dynamic frontend-backend feature)

> **For a full feature list and rationale, see [docs/design_choices_and_changes.md](docs/design_choices_and_changes.md).**

---

## ๐Ÿงช Testing (Summary)

- **Frontend:** Unit tests with Vitest & React Testing Library
```bash
cd frontend
npm run test
```
- **Backend:** API tests with Mocha & Sinon
```bash
cd backend
npm test
```
- **Manual Test Plan:** See [docs/test_cases.md](docs/test_cases.md) for comprehensive manual test cases covering all user actions, features, error cases, demo mode, settings, export, and accessibility.

---

## ๐Ÿง‘โ€๐Ÿ’ป Demo Mode

- **Purpose:** Allows full evaluation of the chat interface without an OpenAI API key.
- **How to Use:** Toggle "Demo Mode" in the settings panel. All chat features will work with simulated responses.
- **Note:** Demo mode always returns the same default response, regardless of the type of input message.

---

## โœ… Assignment Compliance Checklist

- [x] Two dynamic aspects: Real-time chat + **Export Chat transcript** (frontend-backend communication)
- [x] Responsive design: Mobile-first with Tailwind CSS
- [x] Frontend-backend communication: RESTful API
- [x] Functioning application: NOT mockups - actually works
- [x] Demo mode: Tutors can evaluate without API keys
- [x] GitHub repository: Professional, complete, public
- [x] Security: API keys never exposed to frontend
- [x] Documentation: JSDoc, README, architecture
- [x] Error handling: User-friendly messages, loading states
- [x] Quality gates: All core requirements tested and documented

> **For full compliance details and rationale, see [docs/design_choices_and_changes.md](docs/design_choices_and_changes.md).**

---

## ๐Ÿ“– Documentation & Further Reading

- [Design Choices & Changes to Proposal](docs/design_choices_and_changes.md)
- [Manual Test Cases](docs/test_cases.md)
- [Vercel Deployment Guide](docs/vercel_deployment_guide.md)

---

## ๐Ÿ“ฆ Submission & Finalization

- **Final submission (Phase 3) has been completed and includes:**
- This repository (all code, docs, and installation instructions)
- A 2-page abstract (available in `/docs_phase3`)
- A screencast video (available in `/docs_phase3`)
- Zipped folder structure as per assignment requirements

> **All Phase 3 deliverables have been successfully completed and submitted.**

---

---

## ๐Ÿ“ Academic Integrity

This project represents original work completed as part of the IU International University curriculum, achieving a 99/100 grade. All external resources, libraries, and references are properly documented and attributed according to academic standards.