create-bluecopa-react-app 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +162 -50
- package/bin/create-bluecopa-react-app.js +5 -5
- package/package.json +1 -1
- package/templates/latest/.env.example +14 -0
- package/templates/latest/.eslintrc.cjs +42 -0
- package/templates/latest/Agent.md +259 -0
- package/templates/latest/README.md +281 -0
- package/templates/latest/clean.sh +39 -0
- package/templates/latest/index.html +14 -0
- package/templates/{basic → latest}/package-lock.json +1099 -1084
- package/templates/latest/package.json +61 -0
- package/templates/{basic/postcss.config.js → latest/postcss.config.cjs} +1 -1
- package/templates/latest/public/bluecopa-logo.svg +30 -0
- package/templates/latest/public/favicon-32x32.png +0 -0
- package/templates/latest/public/favicon-96x96.png +0 -0
- package/templates/latest/public/favicon.ico +0 -0
- package/templates/latest/setup.sh +55 -0
- package/templates/latest/src/App.tsx +15 -0
- package/templates/latest/src/components/layout/dashboard-header.tsx +139 -0
- package/templates/latest/src/components/layout/dashboard-layout.tsx +29 -0
- package/templates/latest/src/components/layout/sidebar.tsx +54 -0
- package/templates/latest/src/components/page/dashboard.tsx +1506 -0
- package/templates/latest/src/components/page/navbar.tsx +104 -0
- package/templates/latest/src/components/tables/data-grid.tsx +439 -0
- package/templates/latest/src/components/ui/alert.tsx +59 -0
- package/templates/latest/src/components/ui/avatar.tsx +50 -0
- package/templates/latest/src/components/ui/badge.tsx +36 -0
- package/templates/latest/src/components/ui/bluecopa-logo.tsx +54 -0
- package/templates/{basic → latest}/src/components/ui/button.tsx +5 -11
- package/templates/latest/src/components/ui/dropdown-menu.tsx +200 -0
- package/templates/latest/src/components/ui/input.tsx +24 -0
- package/templates/latest/src/components/ui/label.tsx +23 -0
- package/templates/latest/src/components/ui/select.tsx +29 -0
- package/templates/latest/src/hooks/use-api.ts +55 -0
- package/templates/{basic → latest}/src/index.css +1 -1
- package/templates/{basic → latest}/src/main.tsx +6 -2
- package/templates/latest/src/pages/Dashboard.tsx +13 -0
- package/templates/latest/src/pages/Home.tsx +622 -0
- package/templates/latest/src/providers/query-provider.tsx +48 -0
- package/templates/latest/src/single-spa.tsx +105 -0
- package/templates/{basic/src/types/index.ts → latest/src/types/api.ts} +19 -35
- package/templates/latest/src/vite-env.d.ts +11 -0
- package/templates/{basic → latest}/tailwind.config.js +15 -4
- package/templates/{basic/tsconfig.json → latest/tsconfig.app.json} +5 -10
- package/templates/latest/tsconfig.json +19 -0
- package/templates/latest/vite.config.ts +64 -0
- package/templates/basic/.editorconfig +0 -12
- package/templates/basic/.env.example +0 -10
- package/templates/basic/README.md +0 -213
- package/templates/basic/index.html +0 -13
- package/templates/basic/package.json +0 -68
- package/templates/basic/setup.sh +0 -46
- package/templates/basic/src/App.tsx +0 -95
- package/templates/basic/src/components/dashboard/AdvancedAnalytics.tsx +0 -351
- package/templates/basic/src/components/dashboard/MetricsOverview.tsx +0 -150
- package/templates/basic/src/components/dashboard/TransactionCharts.tsx +0 -215
- package/templates/basic/src/components/dashboard/TransactionTable.tsx +0 -172
- package/templates/basic/src/components/ui/tabs.tsx +0 -53
- package/templates/basic/src/pages/Dashboard.tsx +0 -135
- package/templates/basic/vite.config.ts +0 -13
- /package/templates/{basic → latest}/src/components/ui/card.tsx +0 -0
- /package/templates/{basic → latest}/src/lib/utils.ts +0 -0
- /package/templates/{basic → latest}/tsconfig.node.json +0 -0
package/README.md
CHANGED
|
@@ -4,13 +4,15 @@ A CLI tool to bootstrap modern React applications for BlueCopa with built-in UI
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- 🚀 **Modern React Stack**: React 18, TypeScript, Vite
|
|
8
|
-
- 📊 **Data Visualization**:
|
|
9
|
-
- 🎨 **UI Components**:
|
|
10
|
-
- 📡 **BlueCopa React Components**: Pre-configured @bluecopa/react package
|
|
7
|
+
- 🚀 **Modern React Stack**: React 18, TypeScript, React Router v6, Vite
|
|
8
|
+
- 📊 **Data Visualization**: Recharts integration for charts and analytics
|
|
9
|
+
- 🎨 **UI Components**: Radix UI primitives with custom styling
|
|
10
|
+
- 📡 **BlueCopa React Components**: Pre-configured @bluecopa/react package with hooks
|
|
11
11
|
- 🎯 **Type Safety**: Full TypeScript support
|
|
12
|
-
- 📱 **Responsive Design**: Tailwind CSS with mobile-first approach
|
|
13
|
-
- 🛠️ **Development Tools**: ESLint, TypeScript checking, and
|
|
12
|
+
- 📱 **Responsive Design**: Tailwind CSS with mobile-first approach and BlueCopa design system
|
|
13
|
+
- 🛠️ **Development Tools**: ESLint, TypeScript checking, and Vite fast build system
|
|
14
|
+
- ⚡ **Fast Development**: Hot module replacement with Vite
|
|
15
|
+
- 🔄 **Client-side Routing**: React Router v6 for SPA navigation
|
|
14
16
|
|
|
15
17
|
## Quick Start
|
|
16
18
|
|
|
@@ -36,33 +38,41 @@ npm run dev
|
|
|
36
38
|
|
|
37
39
|
## Template Included
|
|
38
40
|
|
|
39
|
-
### BlueCopa
|
|
41
|
+
### BlueCopa React Router Template
|
|
40
42
|
|
|
41
43
|
A foundational template that provides:
|
|
42
44
|
|
|
43
|
-
- **Modern React Setup**: React 18 with TypeScript and Vite
|
|
44
|
-
- **BlueCopa Components**: Pre-configured @bluecopa/react component library
|
|
45
|
-
- **UI Foundation**:
|
|
46
|
-
- **
|
|
47
|
-
- **
|
|
45
|
+
- **Modern React Setup**: React 18 with TypeScript, React Router v6, and Vite
|
|
46
|
+
- **BlueCopa Components**: Pre-configured @bluecopa/react component library with hooks
|
|
47
|
+
- **UI Foundation**: Radix UI primitives with custom styling system
|
|
48
|
+
- **Data Visualization**: Recharts for charts and analytics
|
|
49
|
+
- **Styling System**: Tailwind CSS with BlueCopa design tokens and navy theme
|
|
50
|
+
- **Development Setup**: ESLint, TypeScript configuration, and Vite optimization
|
|
48
51
|
- **Environment Configuration**: Ready-to-use environment variable setup
|
|
52
|
+
- **Client-side Routing**: React Router v6 for smooth SPA navigation
|
|
49
53
|
|
|
50
54
|
#### Key Dependencies Included
|
|
51
55
|
|
|
52
56
|
```typescript
|
|
53
57
|
// Core BlueCopa and React ecosystem
|
|
54
58
|
"@bluecopa/react": "^0.1.3"
|
|
55
|
-
"react": "^18.
|
|
56
|
-
"
|
|
59
|
+
"react": "^18.3.0"
|
|
60
|
+
"react-dom": "^18.3.0"
|
|
61
|
+
"react-router-dom": "^6.26.0"
|
|
62
|
+
"typescript": "^5.6.0"
|
|
57
63
|
|
|
58
64
|
// UI and Styling
|
|
59
65
|
"@radix-ui/*": "Latest versions"
|
|
60
|
-
"tailwindcss": "^3.
|
|
61
|
-
"lucide-react": "^0.
|
|
66
|
+
"tailwindcss": "^3.4.17"
|
|
67
|
+
"lucide-react": "^0.445.0"
|
|
68
|
+
|
|
69
|
+
// Data Visualization
|
|
70
|
+
"recharts": "^2.12.0"
|
|
62
71
|
|
|
63
72
|
// Development and Build
|
|
64
|
-
"vite": "^
|
|
65
|
-
"
|
|
73
|
+
"vite": "^5.4.20"
|
|
74
|
+
"eslint": "^8.57.0"
|
|
75
|
+
"@vitejs/plugin-react": "^4.3.0"
|
|
66
76
|
```
|
|
67
77
|
|
|
68
78
|
## Project Structure
|
|
@@ -72,43 +82,80 @@ The generated project follows a clean, scalable structure:
|
|
|
72
82
|
```text
|
|
73
83
|
my-bluecopa-app/
|
|
74
84
|
├── src/
|
|
75
|
-
│ ├── components/
|
|
76
|
-
│ │
|
|
77
|
-
│
|
|
78
|
-
│ ├──
|
|
79
|
-
│
|
|
80
|
-
│ ├──
|
|
81
|
-
│ └──
|
|
82
|
-
├──
|
|
83
|
-
├── .
|
|
84
|
-
|
|
85
|
-
├──
|
|
86
|
-
|
|
87
|
-
├──
|
|
88
|
-
|
|
85
|
+
│ ├── components/ # Reusable UI components
|
|
86
|
+
│ │ ├── ui/ # Base UI components (buttons, cards, etc.)
|
|
87
|
+
│ │ └── navbar.tsx # Navigation component
|
|
88
|
+
│ ├── hooks/ # Custom React hooks
|
|
89
|
+
│ │ └── use-api.ts # Bluecopa API hooks
|
|
90
|
+
│ ├── lib/ # Utilities and helpers
|
|
91
|
+
│ │ └── utils.ts # Helper functions and utilities
|
|
92
|
+
│ ├── pages/ # Route components
|
|
93
|
+
│ │ ├── Home.tsx # Home page component
|
|
94
|
+
│ │ └── Dashboard.tsx # Dashboard page component
|
|
95
|
+
│ ├── providers/ # React context providers
|
|
96
|
+
│ │ └── query-provider.tsx # TanStack Query provider
|
|
97
|
+
│ ├── types/ # TypeScript type definitions
|
|
98
|
+
│ ├── App.tsx # Main app component with routing
|
|
99
|
+
│ ├── main.tsx # Application entry point
|
|
100
|
+
│ └── index.css # Global styles and Tailwind imports
|
|
101
|
+
├── public/ # Static assets
|
|
102
|
+
├── .env.example # Environment variables template
|
|
103
|
+
├── package.json # Dependencies and scripts
|
|
104
|
+
├── vite.config.ts # Vite configuration
|
|
105
|
+
├── tailwind.config.js # Tailwind CSS configuration
|
|
106
|
+
├── tsconfig.json # TypeScript configuration
|
|
107
|
+
├── postcss.config.js # PostCSS configuration
|
|
108
|
+
└── README.md # Project documentation
|
|
89
109
|
```
|
|
90
110
|
|
|
91
111
|
## Getting Started with Development
|
|
92
112
|
|
|
93
|
-
### Adding BlueCopa Components
|
|
113
|
+
### Adding BlueCopa Components and Hooks
|
|
94
114
|
|
|
95
|
-
The template includes @bluecopa/react components. Start building by importing and using them:
|
|
115
|
+
The template includes @bluecopa/react components and hooks. Start building by importing and using them:
|
|
96
116
|
|
|
97
117
|
```typescript
|
|
98
|
-
import {
|
|
118
|
+
import { useUserData, useMetricDataDemo, useDatasetDataDemo } from '@/hooks/use-api';
|
|
99
119
|
|
|
100
120
|
function MyComponent() {
|
|
121
|
+
const { data: userData, isLoading, error } = useUserData();
|
|
122
|
+
const { data: metrics } = useMetricDataDemo();
|
|
123
|
+
|
|
124
|
+
if (isLoading) return <div>Loading...</div>;
|
|
125
|
+
if (error) return <div>Error: {error.message}</div>;
|
|
126
|
+
|
|
101
127
|
return (
|
|
102
128
|
<div>
|
|
103
|
-
<
|
|
129
|
+
<h1>Welcome, {userData?.user?.firstName}!</h1>
|
|
104
130
|
</div>
|
|
105
131
|
);
|
|
106
132
|
}
|
|
107
133
|
```
|
|
108
134
|
|
|
135
|
+
### Adding Routes
|
|
136
|
+
|
|
137
|
+
Add new routes in `src/App.tsx`:
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
import { Routes, Route } from 'react-router-dom';
|
|
141
|
+
import NewPage from '@/pages/NewPage';
|
|
142
|
+
|
|
143
|
+
export default function App() {
|
|
144
|
+
return (
|
|
145
|
+
<QueryProvider>
|
|
146
|
+
<Routes>
|
|
147
|
+
<Route path="/" element={<Home />} />
|
|
148
|
+
<Route path="/dashboard" element={<Dashboard />} />
|
|
149
|
+
<Route path="/new-page" element={<NewPage />} />
|
|
150
|
+
</Routes>
|
|
151
|
+
</QueryProvider>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
109
156
|
### Adding UI Components
|
|
110
157
|
|
|
111
|
-
Use the included
|
|
158
|
+
Use the included Radix UI components with Tailwind styling:
|
|
112
159
|
|
|
113
160
|
```typescript
|
|
114
161
|
import { Button } from '@/components/ui/button';
|
|
@@ -128,24 +175,54 @@ function Dashboard() {
|
|
|
128
175
|
}
|
|
129
176
|
```
|
|
130
177
|
|
|
131
|
-
###
|
|
178
|
+
### Adding Charts and Data Visualization
|
|
179
|
+
|
|
180
|
+
Use Recharts for data visualization:
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts';
|
|
184
|
+
|
|
185
|
+
const data = [
|
|
186
|
+
{ name: 'Jan', value: 400 },
|
|
187
|
+
{ name: 'Feb', value: 300 },
|
|
188
|
+
{ name: 'Mar', value: 600 },
|
|
189
|
+
];
|
|
190
|
+
|
|
191
|
+
function ChartComponent() {
|
|
192
|
+
return (
|
|
193
|
+
<ResponsiveContainer width="100%" height={300}>
|
|
194
|
+
<LineChart data={data}>
|
|
195
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
196
|
+
<XAxis dataKey="name" />
|
|
197
|
+
<YAxis />
|
|
198
|
+
<Tooltip />
|
|
199
|
+
<Line type="monotone" dataKey="value" stroke="#8884d8" />
|
|
200
|
+
</LineChart>
|
|
201
|
+
</ResponsiveContainer>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
```
|
|
132
205
|
|
|
133
|
-
|
|
134
|
-
- Update CSS variables in `src/index.css` for theme customization
|
|
135
|
-
- All shadcn/ui components support dark/light mode automatically
|
|
206
|
+
### Environment Configuration
|
|
136
207
|
|
|
137
|
-
|
|
208
|
+
Create a `.env.local` file from the example:
|
|
138
209
|
|
|
139
|
-
|
|
210
|
+
```bash
|
|
211
|
+
cp .env.example .env.local
|
|
212
|
+
# Edit .env.local with your Bluecopa credentials from dashboard → Settings → API Tokens
|
|
213
|
+
```
|
|
140
214
|
|
|
215
|
+
Required environment variables:
|
|
141
216
|
```bash
|
|
142
|
-
|
|
217
|
+
VITE_BLUECOPA_API_TOKEN=your-bluecopa-api-token
|
|
218
|
+
VITE_BLUECOPA_API_URL=https://develop.bluecopa.com/api/v1
|
|
219
|
+
VITE_BLUECOPA_WORKSPACE_ID=your-workspace-id
|
|
143
220
|
```
|
|
144
221
|
|
|
145
222
|
## Available Scripts
|
|
146
223
|
|
|
147
|
-
- `npm run dev` - Start development server with hot reload
|
|
148
|
-
- `npm run build` - Build for production (TypeScript
|
|
224
|
+
- `npm run dev` - Start Vite development server with hot reload
|
|
225
|
+
- `npm run build` - Build for production (TypeScript + Vite optimization)
|
|
149
226
|
- `npm run preview` - Preview production build locally
|
|
150
227
|
- `npm run lint` - Run ESLint for code quality
|
|
151
228
|
- `npm run type-check` - Run TypeScript type checking without emitting files
|
|
@@ -153,10 +230,45 @@ cp .env.example .env
|
|
|
153
230
|
## Technologies Used
|
|
154
231
|
|
|
155
232
|
- **React 18** - Modern React with concurrent features
|
|
156
|
-
- **
|
|
233
|
+
- **React Router v6** - Declarative routing for React SPAs
|
|
157
234
|
- **Vite** - Fast build tool and development server
|
|
158
|
-
-
|
|
159
|
-
-
|
|
235
|
+
- **TypeScript** - Full type safety and developer experience
|
|
236
|
+
- **@bluecopa/react** - BlueCopa-specific React components and hooks
|
|
237
|
+
- **TanStack Query** - Powerful data synchronization for React
|
|
160
238
|
- **Radix UI** - Unstyled, accessible UI primitives
|
|
161
|
-
- **
|
|
239
|
+
- **Recharts** - Composable charting library for React
|
|
240
|
+
- **Tailwind CSS** - Utility-first CSS framework with BlueCopa design system
|
|
162
241
|
- **Lucide React** - Beautiful, customizable icons
|
|
242
|
+
|
|
243
|
+
## CLI Usage
|
|
244
|
+
|
|
245
|
+
The CLI will prompt you for project details and automatically:
|
|
246
|
+
|
|
247
|
+
- Create the project structure
|
|
248
|
+
- Copy template files
|
|
249
|
+
- Update package.json with your project name
|
|
250
|
+
- Install dependencies (unless `--skip-install` is used)
|
|
251
|
+
- Provide next steps for development
|
|
252
|
+
|
|
253
|
+
Example output:
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
✔ Creating project structure...
|
|
257
|
+
✔ Dependencies installed
|
|
258
|
+
✔ Success! Created my-dashboard at /path/to/my-dashboard
|
|
259
|
+
|
|
260
|
+
Inside that directory, you can run several commands:
|
|
261
|
+
|
|
262
|
+
npm run dev
|
|
263
|
+
Starts the development server.
|
|
264
|
+
|
|
265
|
+
npm run build
|
|
266
|
+
Bundles the app into static files for production.
|
|
267
|
+
|
|
268
|
+
We suggest that you begin by typing:
|
|
269
|
+
|
|
270
|
+
cd my-dashboard
|
|
271
|
+
npm run dev
|
|
272
|
+
|
|
273
|
+
Happy coding with Bluecopa! 🚀
|
|
274
|
+
```
|
|
@@ -100,19 +100,19 @@ async function createApp(projectName, options) {
|
|
|
100
100
|
console.log();
|
|
101
101
|
console.log('Inside that directory, you can run several commands:');
|
|
102
102
|
console.log();
|
|
103
|
-
console.log(chalk.cyan(' npm
|
|
103
|
+
console.log(chalk.cyan(' npm run dev'));
|
|
104
104
|
console.log(' Starts the development server.');
|
|
105
105
|
console.log();
|
|
106
106
|
console.log(chalk.cyan(' npm run build'));
|
|
107
107
|
console.log(' Bundles the app into static files for production.');
|
|
108
108
|
console.log();
|
|
109
|
-
console.log(chalk.cyan(' npm
|
|
110
|
-
console.log('
|
|
109
|
+
console.log(chalk.cyan(' npm run preview'));
|
|
110
|
+
console.log(' Preview the production build locally.');
|
|
111
111
|
console.log();
|
|
112
112
|
console.log('We suggest that you begin by typing:');
|
|
113
113
|
console.log();
|
|
114
114
|
console.log(chalk.cyan(' cd'), appName);
|
|
115
|
-
console.log(chalk.cyan(' npm
|
|
115
|
+
console.log(chalk.cyan(' npm run dev'));
|
|
116
116
|
console.log();
|
|
117
117
|
console.log('Happy coding with Bluecopa! 🚀');
|
|
118
118
|
|
|
@@ -123,7 +123,7 @@ async function createApp(projectName, options) {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
async function createProjectStructure(targetDir, appName, options) {
|
|
126
|
-
const templateDir = path.join(__dirname, '../templates/
|
|
126
|
+
const templateDir = path.join(__dirname, '../templates/latest');
|
|
127
127
|
|
|
128
128
|
// Create base directory
|
|
129
129
|
await fs.ensureDir(targetDir);
|
package/package.json
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Bluecopa API Configuration
|
|
2
|
+
# Copy this file to .env.local and update with your actual values
|
|
3
|
+
|
|
4
|
+
# Bluecopa API Authentication
|
|
5
|
+
# Get this from your Bluecopa dashboard -> Settings -> API Tokens
|
|
6
|
+
VITE_BLUECOPA_API_TOKEN=your-bluecopa-api-token-here
|
|
7
|
+
|
|
8
|
+
# Bluecopa API Base URL
|
|
9
|
+
# Use the develop environment for testing
|
|
10
|
+
VITE_BLUECOPA_API_URL=https://develop.bluecopa.com/api/v1
|
|
11
|
+
|
|
12
|
+
# Bluecopa Workspace ID
|
|
13
|
+
# Get this from your Bluecopa dashboard workspace settings
|
|
14
|
+
VITE_BLUECOPA_WORKSPACE_ID=your-workspace-id-here
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
env: {
|
|
4
|
+
browser: true,
|
|
5
|
+
es2020: true,
|
|
6
|
+
node: true
|
|
7
|
+
},
|
|
8
|
+
extends: [
|
|
9
|
+
'eslint:recommended',
|
|
10
|
+
],
|
|
11
|
+
ignorePatterns: ['dist', '.eslintrc.cjs'],
|
|
12
|
+
parserOptions: {
|
|
13
|
+
ecmaVersion: 'latest',
|
|
14
|
+
sourceType: 'module',
|
|
15
|
+
ecmaFeatures: {
|
|
16
|
+
jsx: true,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
plugins: ['react-refresh'],
|
|
20
|
+
rules: {
|
|
21
|
+
'react-refresh/only-export-components': [
|
|
22
|
+
'warn',
|
|
23
|
+
{ allowConstantExport: true },
|
|
24
|
+
],
|
|
25
|
+
'no-unused-vars': 'off', // Turned off for TypeScript
|
|
26
|
+
'no-undef': 'off', // TypeScript handles this
|
|
27
|
+
},
|
|
28
|
+
overrides: [
|
|
29
|
+
{
|
|
30
|
+
files: ['*.ts', '*.tsx'],
|
|
31
|
+
parser: '@typescript-eslint/parser',
|
|
32
|
+
plugins: ['@typescript-eslint'],
|
|
33
|
+
rules: {
|
|
34
|
+
'no-unused-vars': 'off',
|
|
35
|
+
// Basic TypeScript rules without extending the recommended config
|
|
36
|
+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
|
37
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
38
|
+
'@typescript-eslint/no-inferrable-types': 'warn',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
# Agent Development Guide - BlueCopa React Template
|
|
2
|
+
|
|
3
|
+
This document provides guidance for AI agents working with BlueCopa React applications built from this template.
|
|
4
|
+
|
|
5
|
+
## 🤖 Agent Overview
|
|
6
|
+
|
|
7
|
+
This template is designed to work seamlessly with AI coding assistants for rapid development of BlueCopa dashboard applications. The project structure and patterns are optimized for AI-assisted development.
|
|
8
|
+
|
|
9
|
+
## 📋 Project Context
|
|
10
|
+
|
|
11
|
+
### Technology Stack
|
|
12
|
+
- **Frontend**: React 18 + TypeScript + React Router v6
|
|
13
|
+
- **Build Tool**: Vite (fast HMR and building)
|
|
14
|
+
- **Styling**: TailwindCSS with BlueCopa design system
|
|
15
|
+
- **UI Components**: Radix UI primitives
|
|
16
|
+
- **Data Fetching**: TanStack Query with @bluecopa/react hooks
|
|
17
|
+
- **Charts**: Recharts for data visualization
|
|
18
|
+
- **Icons**: Lucide React
|
|
19
|
+
|
|
20
|
+
### Key Directories
|
|
21
|
+
```
|
|
22
|
+
src/
|
|
23
|
+
├── components/ui/ # Reusable UI components (Button, Card, etc.)
|
|
24
|
+
├── components/ # Business logic components (Navbar, etc.)
|
|
25
|
+
├── hooks/ # Custom React hooks and API integration
|
|
26
|
+
├── pages/ # Route components (Home, Dashboard)
|
|
27
|
+
├── providers/ # React context providers
|
|
28
|
+
├── lib/ # Utility functions and helpers
|
|
29
|
+
└── types/ # TypeScript type definitions
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 🔧 Development Patterns
|
|
33
|
+
|
|
34
|
+
### 1. Adding New Pages/Routes
|
|
35
|
+
|
|
36
|
+
When asked to create a new page:
|
|
37
|
+
|
|
38
|
+
1. **Create the page component** in `src/pages/NewPage.tsx`:
|
|
39
|
+
```tsx
|
|
40
|
+
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
|
41
|
+
|
|
42
|
+
export default function NewPage() {
|
|
43
|
+
return (
|
|
44
|
+
<div className="container mx-auto py-6">
|
|
45
|
+
<Card>
|
|
46
|
+
<CardHeader>
|
|
47
|
+
<CardTitle>New Page</CardTitle>
|
|
48
|
+
</CardHeader>
|
|
49
|
+
<CardContent>
|
|
50
|
+
{/* Page content */}
|
|
51
|
+
</CardContent>
|
|
52
|
+
</Card>
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
2. **Add the route** in `src/App.tsx`:
|
|
59
|
+
```tsx
|
|
60
|
+
import NewPage from '@/pages/NewPage';
|
|
61
|
+
|
|
62
|
+
// Add to Routes
|
|
63
|
+
<Route path="/new-page" element={<NewPage />} />
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
3. **Update navigation** in `src/components/navbar.tsx`:
|
|
67
|
+
```tsx
|
|
68
|
+
const navigation = [
|
|
69
|
+
// ... existing routes
|
|
70
|
+
{ name: 'New Page', href: '/new-page', icon: Settings },
|
|
71
|
+
];
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 2. Using BlueCopa API Hooks
|
|
75
|
+
|
|
76
|
+
Always use the pre-configured hooks from `@/hooks/use-api.ts`:
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
import { useUserData, useMetricDataDemo, useDatasetDataDemo } from '@/hooks/use-api';
|
|
80
|
+
|
|
81
|
+
function DataComponent() {
|
|
82
|
+
const { data: userData, isLoading, error } = useUserData();
|
|
83
|
+
const { data: metrics } = useMetricDataDemo();
|
|
84
|
+
|
|
85
|
+
if (isLoading) return <div>Loading...</div>;
|
|
86
|
+
if (error) return <div>Error: {error.message}</div>;
|
|
87
|
+
|
|
88
|
+
return <div>Data: {JSON.stringify(userData)}</div>;
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 3. UI Component Patterns
|
|
93
|
+
|
|
94
|
+
Use the existing UI components from `src/components/ui/`:
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import { Button } from '@/components/ui/button';
|
|
98
|
+
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
|
99
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
|
100
|
+
|
|
101
|
+
// Example usage
|
|
102
|
+
<Card>
|
|
103
|
+
<CardHeader>
|
|
104
|
+
<CardTitle>Dashboard</CardTitle>
|
|
105
|
+
</CardHeader>
|
|
106
|
+
<CardContent>
|
|
107
|
+
<Tabs defaultValue="overview">
|
|
108
|
+
<TabsList>
|
|
109
|
+
<TabsTrigger value="overview">Overview</TabsTrigger>
|
|
110
|
+
<TabsTrigger value="analytics">Analytics</TabsTrigger>
|
|
111
|
+
</TabsList>
|
|
112
|
+
<TabsContent value="overview">
|
|
113
|
+
<Button>Action</Button>
|
|
114
|
+
</TabsContent>
|
|
115
|
+
</Tabs>
|
|
116
|
+
</CardContent>
|
|
117
|
+
</Card>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### 4. Chart Integration
|
|
121
|
+
|
|
122
|
+
Use Recharts for data visualization:
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts';
|
|
126
|
+
|
|
127
|
+
function ChartComponent({ data }: { data: any[] }) {
|
|
128
|
+
return (
|
|
129
|
+
<Card>
|
|
130
|
+
<CardHeader>
|
|
131
|
+
<CardTitle>Analytics</CardTitle>
|
|
132
|
+
</CardHeader>
|
|
133
|
+
<CardContent>
|
|
134
|
+
<ResponsiveContainer width="100%" height={300}>
|
|
135
|
+
<LineChart data={data}>
|
|
136
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
137
|
+
<XAxis dataKey="name" />
|
|
138
|
+
<YAxis />
|
|
139
|
+
<Tooltip />
|
|
140
|
+
<Line type="monotone" dataKey="value" stroke="#041e42" />
|
|
141
|
+
</LineChart>
|
|
142
|
+
</ResponsiveContainer>
|
|
143
|
+
</CardContent>
|
|
144
|
+
</Card>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## 🎨 Design System Guidelines
|
|
150
|
+
|
|
151
|
+
### Colors
|
|
152
|
+
- **Primary**: Navy blue (`#041e42`) - BlueCopa brand color
|
|
153
|
+
- **Background**: Light gray (`bg-gray-50`)
|
|
154
|
+
- **Cards**: White with subtle shadow (`bg-white shadow-sm`)
|
|
155
|
+
- **Text**: Gray scale (`text-gray-900`, `text-gray-600`)
|
|
156
|
+
|
|
157
|
+
### Layout Patterns
|
|
158
|
+
- **Container**: `container mx-auto py-6` for page layouts
|
|
159
|
+
- **Grid**: `grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6` for responsive grids
|
|
160
|
+
- **Spacing**: Use Tailwind spacing scale (`p-4`, `mb-6`, etc.)
|
|
161
|
+
|
|
162
|
+
### Component Structure
|
|
163
|
+
```tsx
|
|
164
|
+
// Standard page layout
|
|
165
|
+
<div className="container mx-auto py-6">
|
|
166
|
+
<div className="mb-6">
|
|
167
|
+
<h1 className="text-2xl font-bold text-gray-900">Page Title</h1>
|
|
168
|
+
<p className="text-gray-600">Page description</p>
|
|
169
|
+
</div>
|
|
170
|
+
|
|
171
|
+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
|
172
|
+
{/* Cards or components */}
|
|
173
|
+
</div>
|
|
174
|
+
</div>
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## 🛠️ Common Tasks for Agents
|
|
178
|
+
|
|
179
|
+
### Adding a New Dashboard Card
|
|
180
|
+
1. Create component in appropriate location
|
|
181
|
+
2. Use Card component wrapper
|
|
182
|
+
3. Include loading and error states
|
|
183
|
+
4. Use BlueCopa hooks for data
|
|
184
|
+
|
|
185
|
+
### Creating Forms
|
|
186
|
+
1. Use Radix UI form components
|
|
187
|
+
2. Add TypeScript types for form data
|
|
188
|
+
3. Include validation and error handling
|
|
189
|
+
4. Follow BlueCopa styling patterns
|
|
190
|
+
|
|
191
|
+
### Adding Data Tables
|
|
192
|
+
1. Consider using AG Grid (@bluecopa/aggrid) for complex tables
|
|
193
|
+
2. For simple tables, use HTML table with Tailwind styling
|
|
194
|
+
3. Include sorting, filtering, and pagination as needed
|
|
195
|
+
|
|
196
|
+
### Implementing Search
|
|
197
|
+
1. Add search state management
|
|
198
|
+
2. Use debounced input for API calls
|
|
199
|
+
3. Show loading states during search
|
|
200
|
+
4. Handle empty states gracefully
|
|
201
|
+
|
|
202
|
+
## 🚨 Important Notes for Agents
|
|
203
|
+
|
|
204
|
+
### Environment Variables
|
|
205
|
+
Always reference environment variables correctly for Vite:
|
|
206
|
+
```tsx
|
|
207
|
+
const apiToken = import.meta.env.VITE_BLUECOPA_API_TOKEN;
|
|
208
|
+
const apiUrl = import.meta.env.VITE_BLUECOPA_API_URL;
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Imports
|
|
212
|
+
Use path aliases consistently:
|
|
213
|
+
```tsx
|
|
214
|
+
import { Button } from '@/components/ui/button';
|
|
215
|
+
import { useUserData } from '@/hooks/use-api';
|
|
216
|
+
import { cn } from '@/lib/utils';
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### TypeScript
|
|
220
|
+
Always include proper TypeScript types:
|
|
221
|
+
```tsx
|
|
222
|
+
interface ComponentProps {
|
|
223
|
+
data: UserData[];
|
|
224
|
+
onSelect: (id: string) => void;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function Component({ data, onSelect }: ComponentProps) {
|
|
228
|
+
// Component implementation
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Error Handling
|
|
233
|
+
Include proper error boundaries and loading states:
|
|
234
|
+
```tsx
|
|
235
|
+
if (isLoading) return <div className="p-4">Loading...</div>;
|
|
236
|
+
if (error) return <div className="p-4 text-red-600">Error: {error.message}</div>;
|
|
237
|
+
if (!data) return <div className="p-4 text-gray-500">No data available</div>;
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## 📚 Reference Links
|
|
241
|
+
|
|
242
|
+
- [React Router Documentation](https://reactrouter.com)
|
|
243
|
+
- [TailwindCSS Documentation](https://tailwindcss.com)
|
|
244
|
+
- [Radix UI Documentation](https://radix-ui.com)
|
|
245
|
+
- [Recharts Documentation](https://recharts.org)
|
|
246
|
+
- [TanStack Query Documentation](https://tanstack.com/query)
|
|
247
|
+
- [BlueCopa React Package](https://github.com/bluecopa/blui/packages/react)
|
|
248
|
+
|
|
249
|
+
## 🔄 Development Workflow
|
|
250
|
+
|
|
251
|
+
When working on this project:
|
|
252
|
+
|
|
253
|
+
1. **Start development server**: `npm run dev`
|
|
254
|
+
2. **Type checking**: `npm run type-check`
|
|
255
|
+
3. **Linting**: `npm run lint`
|
|
256
|
+
4. **Building**: `npm run build`
|
|
257
|
+
5. **Preview build**: `npm run preview`
|
|
258
|
+
|
|
259
|
+
The development server supports hot module replacement, so changes will be reflected immediately in the browser.
|