feat: initial CodeBoard monorepo scaffold
Turborepo monorepo with npm workspaces: - apps/web: Next.js 14 frontend with Tailwind v4, SSE progress, doc viewer - apps/worker: BullMQ job processor (clone → parse → LLM generate) - packages/shared: TypeScript types - packages/parser: Babel-based AST parser (JS/TS) + regex (Python) - packages/llm: OpenAI/Anthropic provider abstraction + prompt pipeline - packages/diagrams: Mermaid architecture & dependency graph generators - packages/database: Prisma schema (PostgreSQL) - Docker multi-stage build (web + worker targets) All packages compile successfully with tsc and next build.
This commit is contained in:
24
packages/shared/src/index.ts
Normal file
24
packages/shared/src/index.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
export type {
|
||||
CloneResult,
|
||||
CloneMetadata,
|
||||
FileNode,
|
||||
FunctionNode,
|
||||
ClassNode,
|
||||
ClassProperty,
|
||||
ImportNode,
|
||||
ExportNode,
|
||||
CodeStructure,
|
||||
ModuleNode,
|
||||
DetectedPattern,
|
||||
DependencyEdge,
|
||||
GeneratedDocs,
|
||||
DocsOverview,
|
||||
DocsModule,
|
||||
DocsPatterns,
|
||||
DocsGettingStarted,
|
||||
Generation,
|
||||
GenerationStatus,
|
||||
LLMMessage,
|
||||
LLMOptions,
|
||||
LLMProviderConfig,
|
||||
} from "./types.js";
|
||||
185
packages/shared/src/types.ts
Normal file
185
packages/shared/src/types.ts
Normal file
@@ -0,0 +1,185 @@
|
||||
// ── Repository Cloning ──────────────────────────────────────────────
|
||||
|
||||
export interface CloneMetadata {
|
||||
name: string;
|
||||
description: string;
|
||||
defaultBranch: string;
|
||||
languages: Record<string, number>;
|
||||
stars: number;
|
||||
lastCommit: string;
|
||||
totalFiles: number;
|
||||
totalLines: number;
|
||||
}
|
||||
|
||||
export interface CloneResult {
|
||||
localPath: string;
|
||||
metadata: CloneMetadata;
|
||||
}
|
||||
|
||||
// ── AST Parsing ─────────────────────────────────────────────────────
|
||||
|
||||
export interface FunctionNode {
|
||||
name: string;
|
||||
params: string[];
|
||||
returnType?: string;
|
||||
lineStart: number;
|
||||
lineEnd: number;
|
||||
docstring?: string;
|
||||
calls: string[];
|
||||
}
|
||||
|
||||
export interface ClassProperty {
|
||||
name: string;
|
||||
type?: string;
|
||||
}
|
||||
|
||||
export interface ClassNode {
|
||||
name: string;
|
||||
methods: FunctionNode[];
|
||||
properties: ClassProperty[];
|
||||
}
|
||||
|
||||
export interface ImportNode {
|
||||
source: string;
|
||||
specifiers: string[];
|
||||
}
|
||||
|
||||
export interface ExportNode {
|
||||
name: string;
|
||||
isDefault: boolean;
|
||||
}
|
||||
|
||||
export interface FileNode {
|
||||
path: string;
|
||||
language: string;
|
||||
size: number;
|
||||
functions: FunctionNode[];
|
||||
classes: ClassNode[];
|
||||
imports: ImportNode[];
|
||||
exports: ExportNode[];
|
||||
complexity: number;
|
||||
}
|
||||
|
||||
export interface ModuleNode {
|
||||
name: string;
|
||||
path: string;
|
||||
files: string[];
|
||||
summary?: string;
|
||||
}
|
||||
|
||||
export interface DetectedPattern {
|
||||
name: string;
|
||||
description: string;
|
||||
examples: string[];
|
||||
}
|
||||
|
||||
export interface DependencyEdge {
|
||||
source: string;
|
||||
target: string;
|
||||
type: "import" | "call" | "extends";
|
||||
}
|
||||
|
||||
export interface CodeStructure {
|
||||
files: FileNode[];
|
||||
modules: ModuleNode[];
|
||||
entryPoints: string[];
|
||||
exports: ExportNode[];
|
||||
dependencies: DependencyEdge[];
|
||||
patterns: DetectedPattern[];
|
||||
}
|
||||
|
||||
// ── Generated Documentation ─────────────────────────────────────────
|
||||
|
||||
export interface DocsOverview {
|
||||
title: string;
|
||||
description: string;
|
||||
architectureDiagram: string;
|
||||
techStack: string[];
|
||||
keyMetrics: {
|
||||
files: number;
|
||||
modules: number;
|
||||
languages: string[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface DocsModule {
|
||||
name: string;
|
||||
path: string;
|
||||
summary: string;
|
||||
keyFiles: Array<{ path: string; purpose: string }>;
|
||||
publicApi: string[];
|
||||
dependsOn: string[];
|
||||
dependedBy: string[];
|
||||
}
|
||||
|
||||
export interface DocsPatterns {
|
||||
conventions: string[];
|
||||
designPatterns: string[];
|
||||
architecturalDecisions: string[];
|
||||
}
|
||||
|
||||
export interface DocsGettingStarted {
|
||||
prerequisites: string[];
|
||||
setupSteps: string[];
|
||||
firstTask: string;
|
||||
}
|
||||
|
||||
export interface GeneratedDocs {
|
||||
id: string;
|
||||
repoUrl: string;
|
||||
repoName: string;
|
||||
generatedAt: string;
|
||||
sections: {
|
||||
overview: DocsOverview;
|
||||
modules: DocsModule[];
|
||||
patterns: DocsPatterns;
|
||||
gettingStarted: DocsGettingStarted;
|
||||
dependencyGraph: string;
|
||||
};
|
||||
}
|
||||
|
||||
// ── Generation State ────────────────────────────────────────────────
|
||||
|
||||
export type GenerationStatus =
|
||||
| "QUEUED"
|
||||
| "CLONING"
|
||||
| "PARSING"
|
||||
| "GENERATING"
|
||||
| "RENDERING"
|
||||
| "COMPLETED"
|
||||
| "FAILED";
|
||||
|
||||
export interface Generation {
|
||||
id: string;
|
||||
repoUrl: string;
|
||||
repoName: string;
|
||||
commitHash: string;
|
||||
status: GenerationStatus;
|
||||
progress: number;
|
||||
result: GeneratedDocs | null;
|
||||
error: string | null;
|
||||
costUsd: number | null;
|
||||
duration: number | null;
|
||||
createdAt: string;
|
||||
viewCount: number;
|
||||
}
|
||||
|
||||
// ── LLM Configuration ───────────────────────────────────────────────
|
||||
|
||||
export interface LLMMessage {
|
||||
role: "system" | "user" | "assistant";
|
||||
content: string;
|
||||
}
|
||||
|
||||
export interface LLMOptions {
|
||||
temperature?: number;
|
||||
maxTokens?: number;
|
||||
model?: string;
|
||||
}
|
||||
|
||||
export interface LLMProviderConfig {
|
||||
provider: "openai" | "anthropic";
|
||||
apiKey: string;
|
||||
model?: string;
|
||||
baseUrl?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user