docs: update README

This commit is contained in:
bipproduction
2025-10-08 07:46:06 +08:00
parent d8ed247022
commit 94a8d78fe3

View File

@@ -1,21 +1,78 @@
# bun-react-template
# Jenna MCP
To install dependencies:
Full-stack management console for Jenna that runs entirely on Bun. The app bundles a React dashboard (Mantine UI) with an Elysia API for managing JWT-secured API keys and service credentials backed by PostgreSQL via Prisma.
```bash
bun install
```
## Features
- Protected dashboard with JWT cookie/session handling and seeded demo account.
- API key lifecycle management (create, list, delete) with long-lived signed tokens.
- Credential vault for storing connection details required by downstream tools.
- Auto-generated OpenAPI & Swagger UI exposed at `/docs`.
- Prisma/PostgreSQL data layer with reusable seed script.
To start a development server:
## Tech Stack
- Bun ≥ 1.2.23 (runtime, bundler, and package manager)
- React 19, Vite-style Bun dev server, Mantine UI, SWR & Valtio
- Elysia 1.4 API framework with `@elysiajs/jwt` and Swagger plugin
- Prisma ORM targeting PostgreSQL
```bash
bun dev
```
## Getting Started
To run for production:
1. **Install dependencies**
```bash
bun install
```
```bash
bun start
```
2. **Create your environment file**
Copy the snippet below into `.env` (adjust values to your setup):
```bash
DATABASE_URL="postgresql://USER:PASSWORD@localhost:5432/jenna_mcp"
JWT_SECRET="replace-with-a-strong-secret"
BUN_PUBLIC_BASE_URL="http://localhost:3000"
```
This project was created using `bun init` in bun v1.2.23. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
3. **Apply the Prisma schema & generate the client**
```bash
bunx prisma migrate dev --name init
bunx prisma generate
```
4. **Seed demo data (optional but helpful for local logins)**
```bash
bun run seed
```
This creates a `bip@bip.com / bip` user.
5. **Start the app**
```bash
bun dev
```
The server listens on `http://localhost:3000` and serves both the API and React UI. Swagger docs are available at `http://localhost:3000/docs`.
6. **Production build**
```bash
bun run build
bun start
```
`bun run build` emits the browser bundle to `dist/` and `bun start` runs the API/UI in production mode.
## Useful Commands
- `bun run build` Bundle the client for production.
- `bun start` Run the API/UI in production mode.
- `bunx prisma studio` Inspect your database through Prisma Studio.
## Project Structure
- `src/index.tsx` Bun entry point that wires the Elysia server and serves the React app.
- `src/pages/**` React pages for auth, dashboard, API key & credential management.
- `src/server/**` Elysia routes, middlewares, and Prisma helpers.
- `prisma/schema.prisma` Database schema for users, API keys, and credentials.
- `prisma/seed.ts` Seed script for demo data.
## Authentication Notes
- The dashboard uses cookie-based JWTs issued by `/auth/login`.
- Programmatic requests can send `Authorization: Bearer <token>` or `x-token` headers.
- Protected API routes are nested under `/api/**`.
## Troubleshooting
- Ensure `JWT_SECRET` is set before starting the server; the API throws on startup if it is missing.
- If Prisma complains about missing client files, rerun `bunx prisma generate`.
- When updating the schema, rerun `bunx prisma migrate dev` followed by `bun run seed` if you need fresh fixtures.