# ColdBrewNLP

ColdBrewNLP is an AI research hub for NLP and LLM systems.

Core direction:
- research -> datasets -> projects -> real-world experiments
- Vietnamese NLP as the main focus
- practical, system-oriented work instead of theory-only content
- experiment-driven workflows that combine data engineering and LLM systems

Core sections on the website:
- `Research`: LLMs, NLP tasks, and system design
- `Datasets`: Vietnamese, multilingual, and synthetic datasets with metadata
- `Projects`: real-world NLP and LLM systems with architecture and stack notes

MVP pages:
- `Home`
- `Research`
- `Datasets`
- `Projects`

Tagline:
- `From data to LLM systems.`

## Project Structure

ColdBrewNLP is structured as two separate applications:

- `fe/`: React + Vite frontend
- `be/`: Express backend

## Requirements

- Node.js 18+
- npm

If you are using PowerShell on Windows and hit execution policy issues with `npm`, use `npm.cmd` instead.

## Installation

Install frontend dependencies:

```powershell
npm.cmd --prefix fe install
```

Install backend dependencies:

```powershell
npm.cmd --prefix be install
```

Or install them from each folder manually:

```powershell
cd fe
npm.cmd install
cd ..
cd be
npm.cmd install
```

## Run In Development

Open two terminals.

Start the backend:

```powershell
npm.cmd run dev:be
```

Start the frontend:

```powershell
npm.cmd run dev:fe
```

Default local URLs:

- Frontend: `http://localhost:5173`
- Backend: `http://localhost:3000`

The frontend proxies `/api` requests to the backend in development.
If you need a different backend target, set `VITE_DEV_API_TARGET`.

## Build The Frontend

```powershell
npm.cmd run build
```

This builds the frontend into `fe/dist`.

After the build completes, the backend can serve the frontend bundle directly.

## Run In Production

Build the frontend first:

```powershell
npm.cmd run build
```

Then start the backend:

```powershell
npm.cmd run start
```

## Environment Variables

Create a `.env` file in the project root.

Example:

```env
NODE_ENV=production
PORT=3000
SITE_URL=https://coldbrewnlp.com
OPENAI_API_KEY=your_key_here
OPENAI_MODEL=gpt-4.1-mini
```

Notes:

- If `OPENAI_API_KEY` is not set, `/api/analyze` runs in demo mode.
- In production, the app redirects requests to the host defined by `SITE_URL`.
- For this project, production is expected to run at `https://coldbrewnlp.com`.

## Root Scripts

```powershell
npm.cmd run dev:fe
npm.cmd run dev:be
npm.cmd run build
npm.cmd run start
```

## API Endpoints

- `GET /api/health`
- `POST /api/analyze`
- `GET /api/blog/posts`
- `GET /api/blog/posts/:slug`
- `POST /api/blog/posts`

Example payload for `/api/analyze`:

```json
{
  "prompt": "Analyze this text"
}
```

## Deployment Note

If your hosting environment starts the root `server.js` file with CommonJS `require()`, this project is already configured to support that entrypoint. The actual backend app runs from `be/server.js`.



