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:
Vectry
2026-02-09 15:22:50 +00:00
parent efdc282da5
commit 79dad6124f
72 changed files with 10132 additions and 136 deletions

View File

@@ -0,0 +1,51 @@
import type { LLMMessage, CodeStructure } from "@codeboard/shared";
export function buildArchitecturePrompt(
structure: CodeStructure
): LLMMessage[] {
const fileTree = structure.files
.map((f) => ` ${f.path} (${f.language}, ${f.functions.length} functions, ${f.classes.length} classes)`)
.join("\n");
const modules = structure.modules
.map((m) => ` ${m.name}/ (${m.files.length} files)`)
.join("\n");
const entryPoints = structure.entryPoints.join(", ") || "none detected";
return [
{
role: "system",
content: `You are an expert software architect analyzing a codebase. Generate a concise architecture overview and a Mermaid flowchart diagram.
Output format (use exactly these headers):
## Architecture Overview
[2-4 paragraphs describing the high-level architecture, key design decisions, and how components interact]
## Tech Stack
[comma-separated list of technologies detected]
## Mermaid Diagram
\`\`\`mermaid
[flowchart TD diagram showing modules and their relationships]
\`\`\``,
},
{
role: "user",
content: `Analyze this codebase structure:
FILE TREE:
${fileTree}
MODULES:
${modules}
ENTRY POINTS: ${entryPoints}
DEPENDENCIES (import edges):
${structure.dependencies.slice(0, 50).map((d) => ` ${d.source} -> ${d.target}`).join("\n")}
Generate the architecture overview with a Mermaid diagram.`,
},
];
}

View File

@@ -0,0 +1,43 @@
import type { LLMMessage, CodeStructure } from "@codeboard/shared";
export function buildGettingStartedPrompt(
structure: CodeStructure,
architectureOverview: string,
readmeContent?: string,
packageJsonContent?: string
): LLMMessage[] {
return [
{
role: "system",
content: `You are writing an onboarding guide for a new developer joining this project. Be specific and actionable.
Output format:
## Prerequisites
[list required tools, runtimes, and their versions]
## Setup Steps
[numbered list of concrete commands and actions to get the project running locally]
## Your First Task
[suggest a good first contribution — something small but meaningful that touches multiple parts of the codebase]`,
},
{
role: "user",
content: `Create an onboarding guide for this project.
ARCHITECTURE OVERVIEW:
${architectureOverview}
${readmeContent ? `README:\n${readmeContent.slice(0, 3000)}` : "README: not available"}
${packageJsonContent ? `PACKAGE.JSON:\n${packageJsonContent.slice(0, 2000)}` : ""}
LANGUAGES: ${[...new Set(structure.files.map((f) => f.language))].join(", ")}
ENTRY POINTS: ${structure.entryPoints.join(", ") || "none detected"}
TOTAL FILES: ${structure.files.length}
TOTAL MODULES: ${structure.modules.length}
Write a concrete, actionable onboarding guide.`,
},
];
}

View File

@@ -0,0 +1,42 @@
import type { LLMMessage, ModuleNode, FileNode } from "@codeboard/shared";
export function buildModuleSummaryPrompt(
module: ModuleNode,
files: FileNode[]
): LLMMessage[] {
const fileDetails = files
.map((f) => {
const fns = f.functions.map((fn) => ` ${fn.name}(${fn.params.join(", ")})`).join("\n");
const cls = f.classes.map((c) => ` class ${c.name}`).join("\n");
const exps = f.exports.map((e) => ` export ${e.isDefault ? "default " : ""}${e.name}`).join("\n");
return ` ${f.path}:\n${fns}\n${cls}\n${exps}`;
})
.join("\n\n");
return [
{
role: "system",
content: `You are analyzing a code module. Provide a concise summary.
Output format:
## Summary
[1-2 paragraphs explaining what this module does and its role in the project]
## Key Files
[list each important file with a one-line description]
## Public API
[list the main exported functions/classes and what they do]`,
},
{
role: "user",
content: `Module: ${module.name} (${module.path})
Files: ${module.files.length}
FILE DETAILS:
${fileDetails}
Summarize this module.`,
},
];
}

View File

@@ -0,0 +1,55 @@
import type { LLMMessage, CodeStructure } from "@codeboard/shared";
export function buildPatternsPrompt(structure: CodeStructure): LLMMessage[] {
const sampleFunctions = structure.files
.flatMap((f) => f.functions.map((fn) => `${f.path}: ${fn.name}(${fn.params.join(", ")})`))
.slice(0, 40)
.join("\n");
const sampleClasses = structure.files
.flatMap((f) => f.classes.map((c) => `${f.path}: class ${c.name} [${c.methods.map((m) => m.name).join(", ")}]`))
.slice(0, 20)
.join("\n");
const importSources = new Set<string>();
for (const f of structure.files) {
for (const imp of f.imports) {
importSources.add(imp.source);
}
}
return [
{
role: "system",
content: `You are a code reviewer identifying patterns and conventions in a codebase.
Output format:
## Coding Conventions
[list conventions like naming patterns, file organization, error handling approach]
## Design Patterns
[list design patterns detected: factory, singleton, observer, repository, etc.]
## Architectural Decisions
[list key architectural decisions: monorepo vs polyrepo, framework choices, state management, etc.]`,
},
{
role: "user",
content: `Analyze these code patterns:
FUNCTION SIGNATURES:
${sampleFunctions}
CLASS DEFINITIONS:
${sampleClasses}
EXTERNAL DEPENDENCIES:
${Array.from(importSources).filter((s) => !s.startsWith(".")).slice(0, 30).join(", ")}
DETECTED PATTERNS FROM AST:
${structure.patterns.map((p) => ` ${p.name}: ${p.description}`).join("\n") || " (none pre-detected)"}
Identify coding conventions, design patterns, and architectural decisions.`,
},
];
}