Skip to content
Draft
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
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Gemini AI API Key
GEMINI_API_KEY=your_api_key_here

# Database URL (SQLite for development)
DATABASE_URL=file:./dev.db

# App URL
NEXT_PUBLIC_APP_URL=http://localhost:3000
43 changes: 43 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local
.env

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# prisma
/prisma/dev.db
/prisma/dev.db-journal

# old files
style.css.old
174 changes: 173 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,173 @@
# rag7
# AI Workflow Automation Discovery Platform

A comprehensive AI-powered platform that helps founders and business owners discover hidden automation opportunities in their operations through systematic interviews and analysis.

## Features

### 🎯 Core Capabilities
- **Systematic Workflow Interviews**: Guided interview process to map daily operations, tasks, and bottlenecks
- **AI-Powered Analysis**: Gemini AI analyzes responses to identify top bottlenecks and automation opportunities
- **Prioritization Matrix**: Visual impact vs. effort matrix for decision-making
- **Implementation Roadmap**: Phased automation implementation plans with timelines
- **Context Engineering Studio**: Design optimized AI agent prompts with behavioral constraints
- **Security Scanning**: AI-powered vulnerability detection supporting multiple languages

### 🛠️ Technical Stack
- **Framework**: Next.js 14+ with App Router
- **Language**: TypeScript with strict type checking
- **Styling**: Tailwind CSS + shadcn/ui components
- **Database**: Prisma ORM with SQLite (dev) / PostgreSQL (production)
- **AI Integration**: Google Gemini AI API
- **Export**: PDF (jsPDF) and CSV formats

## Getting Started

### Prerequisites
- Node.js 18+
- npm or yarn
- Google Gemini API key

### Installation

1. Clone the repository:
```bash
git clone https://github.com/Stacey77/rag7.git
cd rag7
```

2. Install dependencies:
```bash
npm install
```

3. Set up environment variables:
```bash
cp .env.example .env
```

Edit `.env` and add your Gemini API key:
```
GEMINI_API_KEY=your_api_key_here
DATABASE_URL=file:./dev.db
NEXT_PUBLIC_APP_URL=http://localhost:3000
```

4. Initialize the database:
```bash
npx prisma db push
npx prisma generate
```

5. Run the development server:
```bash
npm run dev
```

6. Open [http://localhost:3000](http://localhost:3000) in your browser.

### Building for Production

```bash
npm run build
npm start
```

## Project Structure

```
rag7/
├── app/ # Next.js App Router pages
│ ├── api/ # API routes
│ │ ├── analysis/ # Analysis generation
│ │ ├── contexts/ # Context templates
│ │ ├── interviews/ # Interview CRUD
│ │ └── security/ # Security scanning
│ ├── analysis/ # Analysis page
│ ├── context-studio/ # Context engineering
│ ├── interview/ # Interview flow
│ ├── security/ # Security scan
│ ├── layout.tsx # Root layout
│ └── page.tsx # Dashboard
├── components/ # React components
│ ├── ui/ # shadcn/ui components
│ ├── Analysis.tsx # Analysis visualization
│ ├── ContextStudio.tsx # Context engineering
│ ├── Dashboard.tsx # Main dashboard
│ ├── Interview.tsx # Interview flow
│ ├── SecurityScan.tsx # Security scanner
│ └── Sidebar.tsx # Navigation
├── lib/ # Utilities and services
│ ├── db/ # Database client
│ ├── export/ # PDF/CSV export
│ ├── gemini/ # Gemini AI service
│ └── utils.ts # Helper functions
├── prisma/ # Database schema
├── types/ # TypeScript types
└── public/ # Static assets
```

## API Routes

### Interviews
- `GET /api/interviews` - List all interviews
- `POST /api/interviews` - Create new interview

### Analysis
- `POST /api/analysis` - Generate analysis from interview

### Security
- `POST /api/security` - Scan code for vulnerabilities

### Context Templates
- `GET /api/contexts` - List templates
- `POST /api/contexts` - Create template

## Database Schema

- **Interview**: Stores workflow interview data
- **Analysis**: AI-generated bottleneck and opportunity analysis
- **SecurityScan**: Vulnerability scan results
- **ContextTemplate**: Saved AI agent prompt templates

## Features in Detail

### Interview System
Systematic question flow covering:
- Daily workflow mapping
- Task frequency and duration
- Manual bottleneck identification
- Data entry patterns
- Approval processes
- Error correction workflows

### Analysis Engine
- **Bottleneck Visualization**: Top 3-5 workflow pain points with severity
- **Opportunity Matrix**: Impact vs. effort prioritization
- **Implementation Roadmap**: Phased automation plan

### Context Studio
- AI agent role and expertise configuration
- Output tone/style selection (Professional, Casual, Technical, Consultative, Executive)
- Behavioral constraints with quick-add examples
- Prompt generation and template saving

### Security Scanner
Multi-language vulnerability detection:
- SQL Injection, XSS, CSRF
- Hardcoded secrets
- Path traversal, Command injection
- Insecure deserialization
- OWASP Top 10 mapping
- Remediation suggestions with code examples

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

This project is licensed under the MIT License.

## Security

See [SECURITY.md](SECURITY.md) for reporting security vulnerabilities.
5 changes: 5 additions & 0 deletions app/analysis/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Analysis } from '@/components/Analysis';

export default function AnalysisPage() {
return <Analysis />;
}
70 changes: 70 additions & 0 deletions app/api/analysis/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { NextRequest, NextResponse } from 'next/server';
import { prisma } from '@/lib/db/prisma';
import { GeminiService } from '@/lib/gemini/service';

// POST /api/analysis - Generate analysis from interview
export async function POST(request: NextRequest) {
try {
const body = await request.json();
const { interviewId } = body;

if (!interviewId) {
return NextResponse.json(
{ error: 'Interview ID is required' },
{ status: 400 }
);
}

// Fetch interview
const interview = await prisma.interview.findUnique({
where: { id: interviewId },
});

if (!interview) {
return NextResponse.json(
{ error: 'Interview not found' },
{ status: 404 }
);
}

const responses = JSON.parse(interview.responses);

// Generate analysis using Gemini
const apiKey = process.env.GEMINI_API_KEY;
if (!apiKey) {
return NextResponse.json(
{ error: 'Gemini API key not configured' },
{ status: 500 }
);
}

const gemini = new GeminiService(apiKey);
const analysisResult = await gemini.analyzeWorkflow(responses);

// Generate roadmap
const roadmap = await gemini.generateRoadmap(analysisResult.opportunities);

// Save analysis
const analysis = await prisma.analysis.create({
data: {
interviewId,
bottlenecks: JSON.stringify(analysisResult.bottlenecks),
opportunities: JSON.stringify(analysisResult.opportunities),
roadmap: JSON.stringify(roadmap),
},
});

return NextResponse.json({
...analysis,
bottlenecks: JSON.parse(analysis.bottlenecks),
opportunities: JSON.parse(analysis.opportunities),
roadmap: JSON.parse(analysis.roadmap),
});
} catch (error) {
console.error('Error generating analysis:', error);
return NextResponse.json(
{ error: 'Failed to generate analysis' },
{ status: 500 }
);
}
}
55 changes: 55 additions & 0 deletions app/api/contexts/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { NextRequest, NextResponse } from 'next/server';
import { prisma } from '@/lib/db/prisma';

// GET /api/contexts - List all context templates
export async function GET(request: NextRequest) {
try {
const templates = await prisma.contextTemplate.findMany({
orderBy: { createdAt: 'desc' },
});

return NextResponse.json(templates);
} catch (error) {
console.error('Error fetching context templates:', error);
return NextResponse.json(
{ error: 'Failed to fetch templates' },
{ status: 500 }
);
}
}

// POST /api/contexts - Create new context template
export async function POST(request: NextRequest) {
try {
const body = await request.json();
const { name, description, role, domain, context, tone, constraints, userId } = body;

if (!name || !role || !domain || !context || !tone) {
return NextResponse.json(
{ error: 'Required fields are missing' },
{ status: 400 }
);
}

const template = await prisma.contextTemplate.create({
data: {
name,
description: description || '',
role,
domain,
context,
tone,
constraints: typeof constraints === 'string' ? constraints : JSON.stringify(constraints),
userId,
},
});

return NextResponse.json(template);
} catch (error) {
console.error('Error creating context template:', error);
return NextResponse.json(
{ error: 'Failed to create template' },
{ status: 500 }
);
}
}
Loading