Skip to content
Merged
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
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
> **Stop writing documentation. Start generating it.**

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md)

**The AI-powered documentation framework that lives inside your IDE.** Generate Architecture Decision Records, system diagrams, and onboarding guides with simple slash commands. No installations, no setup, no excuses.
Expand All @@ -30,6 +30,32 @@

**Result:** Professional documentation that would take hours to write, generated in seconds.

## πŸ“Έ **Visual Showcase**

### πŸ—οΈ System Architecture Documentation

Auto-generated architecture overview with intelligent component mapping:

![System Architecture Example](images/system-architecture-example.png)

### πŸš€ Onboarding Guide Generation

Context-aware onboarding documentation tailored to your project:

![Onboarding Doc Example](images/onboarding-doc-example.png)

### πŸ“‹ Advanced Onboarding Features

Comprehensive setup guides with framework-specific instructions:

![Onboarding Doc Example 2](images/onboarding-doc-example-2.png)

### πŸ—‚οΈ Data Model Generation

Professional ER diagrams and database schema documentation:

![Data Model Generation](images/data-model-generation.png)

---

## πŸš€ **Quick Start** *(2 minutes to awesome docs)*
Expand Down
118 changes: 114 additions & 4 deletions docs/architecture.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,117 @@
## System Architecture

The `ai-cursor-init` project is an AI-powered documentation framework designed to work seamlessly within Cursor IDE and as a standalone CLI tool.

### High-Level Architecture

```mermaid
graph TD
docs["Project documentation"]
cli["Command-line interface"]
templates["Template files"]
templates --> docs
A[Cursor IDE Integration] --> B[Slash Commands]
B --> C[AI Service Layer]
C --> D[Template Engine]
C --> E[Framework Detection]
C --> F[Diagram Generation]

G[CLI Tool] --> C

D --> H[Documentation Files]
E --> I[Project Analysis]
F --> J[Mermaid Diagrams]

C --> K[Multi-Provider AI]
K --> L[OpenAI]
K --> M[Anthropic]
K --> N[Gemini]

H --> O[Architecture Docs]
H --> P[ADRs]
H --> Q[Onboarding Guides]
H --> R[ER Diagrams]
```

### Core Components

#### 1. **AI Service Layer**

- **Purpose:** Centralized AI integration with multiple providers
- **Key Files:** `cli/cursor_init/ai_service.py`, `cli/cursor_init/ai_config.py`
- **Responsibilities:**
- Multi-provider AI support (OpenAI, Anthropic, Gemini)
- Context-aware documentation generation
- Intelligent code analysis and content updates

#### 2. **Framework Detection Engine**

- **Purpose:** Automatically detect project technologies and frameworks
- **Key Files:** `cli/cursor_init/detect_framework.py`
- **Capabilities:**
- Python framework detection (FastAPI, Django, Flask)
- JavaScript/TypeScript framework detection (React, Next.js)
- SQLAlchemy model detection for ER diagrams
- Project structure analysis

#### 3. **Template System**

- **Purpose:** Flexible, framework-aware documentation templates
- **Key Files:** Template files in `.cursor/templates/`
- **Features:**
- Multiple template variants per document type
- Framework-specific customization
- AI-powered content generation from templates

#### 4. **Diagram Generation**

- **Purpose:** Automated visual documentation creation
- **Key Files:** `cli/cursor_init/generate_diagrams.py`
- **Outputs:**
- ER diagrams from SQLAlchemy models
- Architecture diagrams from project structure
- Version-controlled Mermaid diagrams

#### 5. **CLI Interface**

- **Purpose:** Command-line tool for CI/CD integration
- **Key Files:** `cli/cursor_init/__main__.py`
- **Commands:**
- `init` - Initialize documentation structure
- `update` - AI-powered documentation updates
- `adr` - Create Architecture Decision Records
- `check-docs` - Validate documentation freshness

#### 6. **Cursor IDE Integration**

- **Purpose:** Seamless in-IDE documentation workflow
- **Key Files:** Rules in `.cursor/rules/`
- **Slash Commands:**
- `/init-docs` - Initialize project documentation
- `/update-docs` - Update existing documentation
- `/adr "Title"` - Create new ADRs
- `/gen-er-diagram` - Generate ER diagrams
- `/gen-arch-diagram` - Generate architecture diagrams

### Data Flow

1. **User Interaction:** Via Cursor slash commands or CLI
2. **Project Analysis:** Framework detection and code analysis
3. **AI Processing:** Context-aware content generation
4. **Template Application:** Framework-specific template selection
5. **Content Generation:** AI-enhanced documentation creation
6. **File Management:** Automated file creation and updates

### Technology Stack

- **Language:** Python 3.12+
- **AI Providers:** OpenAI, Anthropic, Google Gemini
- **Diagram Format:** Mermaid (version-controlled, text-based)
- **Configuration:** YAML-based settings
- **IDE Integration:** Cursor rules and templates
- **Package Management:** pip/setuptools with pyproject.toml

### Design Principles

- **Documentation as Code:** Version-controlled alongside source code
- **AI-Enhanced:** Intelligent content generation and updates
- **Framework-Aware:** Automatic detection and customization
- **Zero-Installation:** Works out-of-the-box in Cursor IDE
- **CI-Friendly:** Automated validation and freshness checks
- **Multi-Provider:** Flexible AI backend support
91 changes: 79 additions & 12 deletions docs/data-model.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,87 @@
# Project Data Model

This document contains the Entity Relationship Diagram (ERD) for the project's data model.
This document describes the data structures and configuration models used by the AI-cursor-init framework.

## Configuration Data Model

The ai-cursor-init framework uses YAML-based configuration and dataclass models for managing settings and project metadata.

```mermaid
erDiagram
users {
id int
username string
email string
created_at datetime
AIConfig {
provider string "openai|anthropic|gemini"
api_key string
model string
base_url string
temperature float
max_tokens int
}

ProjectFrameworks {
languages set "python|typescript|javascript"
frameworks set "fastapi|django|react|nextjs|sqlalchemy"
root_directory string
}
orders {
id int
user_id int
total_amount int
created_at datetime

TemplateConfig {
template_paths dict
custom_template_paths dict
variant_preferences dict
}
orders ||--o{ users : references

DocumentationFile {
filepath string
content_type string "adr|architecture|onboarding|data-model"
last_updated datetime
template_used string
ai_generated boolean
}

AIConfig ||--|| ProjectFrameworks : "configures generation for"
TemplateConfig ||--o{ DocumentationFile : "templates generate"
ProjectFrameworks ||--o{ DocumentationFile : "influences content of"
```

## Key Data Structures

### AI Provider Configuration

- **Purpose:** Manages multi-provider AI integration settings
- **Location:** Stored in project-local `.ai-cursor-init.yaml` or user config
- **Supported Providers:** OpenAI, Anthropic Claude, Google Gemini

### Framework Detection Results

- **Purpose:** Stores detected project technologies and frameworks
- **Usage:** Influences template selection and content generation
- **Detection Sources:** File analysis, dependency scanning, structure patterns

### Template Metadata

- **Purpose:** Maps document types to available templates and variants
- **Customization:** Supports custom template paths and user preferences
- **Inheritance:** Default templates can be overridden by project-specific ones

### Documentation Tracking

- **Purpose:** Maintains metadata about generated documentation files
- **Features:** Tracks AI generation status, template usage, and freshness
- **Integration:** Used by `/check-docs` for validation and staleness detection

## File-Based Data Storage

This project primarily uses file-based storage rather than traditional databases:

- **Configuration Files:** YAML format for settings and preferences
- **Documentation Files:** Markdown format with embedded Mermaid diagrams
- **Template Files:** Jinja2-style templates with framework-specific variants
- **Metadata:** Embedded in file headers and configuration sections

## Data Flow Pattern

1. **Configuration Loading:** Read user/project AI and template settings
2. **Project Analysis:** Scan codebase to detect frameworks and structure
3. **Template Selection:** Choose appropriate templates based on detected frameworks
4. **AI Context Building:** Aggregate project information for AI providers
5. **Content Generation:** Generate documentation using AI + templates
6. **File Management:** Write/update documentation files with metadata tracking
Loading
Loading