Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copy this file to server/.env (or export the variables) before running the Node service.
OPENAI_API_KEY=replace-with-your-openai-api-key
# Optional overrides
# OPENAI_MODEL=gpt-4.1-mini
# OPENAI_FALLBACK_MODEL=gpt-4o-mini
PORT=5001
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules/
client/node_modules/
server/node_modules/
dist/
client/dist/
server/dist/
.env
server/.env
.DS_Store
134 changes: 133 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,133 @@
# beta
# Insight Nexus CRM

Insight Nexus CRM is an immersive, local-first Vite + React command center for predictive revenue intelligence.
It fuses data management, forecasting, risk analysis, AI advisory, and deep comparison workflows into one cinematic
experience powered by your private OpenAI key.

## Architecture

```
root
├── client # Vite + React + Tailwind front-end (TypeScript)
└── server # Node/Express API broker that talks to OpenAI Responses
```

The UI runs on Vite (port 5173) and proxies API calls to the Node service (port 5001 by default). All OpenAI traffic
is handled server-side so your key never touches the browser.

## Features

- **Data fabric ops** – upload CRM CSV/JSON/TXT intelligence, track freshness, and surface AI-generated coverage maps.
- **Prediction studio** – craft multi-dimensional business scenarios, attach documents, and receive structured forecasts,
risk posture, CRM plays, and AI advisory in one response.
- **Risk command** – monitor Atlas-generated risk matrices, mitigation sprints, and telemetry streams in a premium glassmorphism UI.
- **AI advisor** – chat with Atlas, the revenue copilot, for executive-ready guidance that remembers context across turns.
- **Collaboration hub** – upload two intelligence files for deep delta analysis with suggested actions, automation plays, and executive summaries.

## Prerequisites

- Node.js 18+
- npm 9+
- An OpenAI API key with access to the Responses API (e.g., `gpt-4.1-mini`). The server automatically falls back to
Chat Completions (default `gpt-4o-mini`) if the Responses API is unavailable.

## Setup

### Windows quick-start

Windows 11 users get both classic `.bat` wrappers and richer PowerShell automation under `scripts/windows`.

1. **Install dependencies**
- Double-click `install.bat` (or run `scripts\windows\install.ps1`) to confirm Node 18+/npm 9+ are in `PATH` and install
dependencies for both the server and the Vite client. The installer now uses PowerShell for clearer error handling,
automatic retry prompts, and works reliably from directories that contain spaces.
2. **Provide credentials**
- Copy `server/.env.example` to `server/.env` and set `OPENAI_API_KEY=<your key>`.
- Optionally override `OPENAI_MODEL` or `OPENAI_FALLBACK_MODEL` if your account requires different model names.
3. **Launch the stack**
- Double-click `run.bat` (or run `scripts\windows\run.ps1`) to start the API broker and Vite workspace in their own terminals.
The runner re-validates prerequisites, installs missing modules automatically, and warns if your `.env` file is absent.

> **Important:** If you previously ran the legacy Flask build, close any `python` or `flask` terminals first. Those old processes
> continue listening on port 5000 and will block the new Node server. You can terminate them quickly with
> `taskkill /IM python.exe /F` in an elevated Command Prompt.
>
> **Execution policy tip:** If PowerShell warns about script execution being disabled, open PowerShell as Administrator and run
> `Set-ExecutionPolicy -Scope CurrentUser RemoteSigned` once, then re-run the installer/runner.

### Manual setup

1. **Install dependencies**

```bash
cd server && npm install
cd ../client && npm install
```

2. **Configure environment variables**

```bash
cp server/.env.example server/.env
# edit server/.env and set OPENAI_API_KEY=<your key>
```

The server respects `PORT` (default `5001`). Ensure it matches the proxy target in `client/vite.config.ts` if changed.
You can also set `OPENAI_MODEL` or `OPENAI_FALLBACK_MODEL` to align with the tiers your account supports.

3. **Run the Node API broker**

```bash
cd server
npm run dev
```

4. **Run the Vite client**

In a second terminal:

```bash
cd client
npm run dev
```

5. Navigate to [http://localhost:5173](http://localhost:5173) to experience the Insight Nexus CRM suite.

### Auto-runner behaviour

- `run.bat` delegates to `scripts/windows/run.ps1`, which opens two dedicated terminals named **Insight Nexus CRM - API** and
**Insight Nexus CRM - Client**. Close those windows (or press `CTRL+C` inside each) to stop the services.
- The runner only reinstalls dependencies when `node_modules` is missing. Pass `-SkipInstall` to `run.ps1` if you want to skip the
check entirely.
- Both the installer and runner surface actionable PowerShell errors (for example, missing Node, blocked execution policy, or failed
npm installs) so Windows issues are easier to diagnose.

## Usage workflow

- Start in **Command Center** to review real-time telemetry and AI advisories.
- Head to **Data Management** to ingest supporting docs and monitor Atlas automations.
- Launch predictions in **Predictive Strategy**; attach up to four documents to enrich outcomes.
- Use **Risk Command** to understand threat vectors and mitigation plays.
- Chat with **AI Advisor** for curated actions, then compare intelligence files inside **Collaboration Hub** for deep delta insights.

## Testing & linting

- Front-end lint: `cd client && npm run lint`
- Front-end build: `cd client && npm run build`
- Server lint: `cd server && npm run lint`

Both projects are TypeScript/ESM aware. Adjust scripts or integrate additional tooling as needed. The build step ensures
the Vite bundle compiles with the current configuration (esbuild JSX transform + Tailwind).

## Security

- Never expose your OpenAI key to the browser. Keep it in `server/.env` or your preferred secret manager.
- Do not commit `.env` files. Keys listed here are placeholders only.
- Consider adding request authentication before deploying beyond localhost.

## Troubleshooting

- If you encounter `Unable to generate insights` or `Unable to compare documents`, confirm the server console is running and that
`OPENAI_API_KEY` is valid.
- Update the `model` in `server/src/index.js` to match the tier available to your account if `gpt-4.1-mini` is unavailable.

Enjoy orchestrating a next-generation CRM experience powered by Atlas.
26 changes: 26 additions & 0 deletions client/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: [
'eslint:recommended',
'plugin:react-hooks/recommended',
'plugin:@typescript-eslint/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: { jsx: true },
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: ['@typescript-eslint'],
settings: {
react: {
version: 'detect',
},
},
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
};
13 changes: 13 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en" class="dark">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Insight Nexus CRM</title>
</head>
<body class="bg-canvas text-white">
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Loading