Compétence de documentation WIKI pour base de code
De Wikiprompt, l’encyclopédie libre de prompts
Compétence de documentation WIKI pour base de code Invite système pour générer une documentation WIKI.md complète pour les bases de code en utilisant l'analyse LSP et les diagrammes Mermaid.
Contenu du PromptEnregistrer
🌐
# Project Overview
This document provides a comprehensive overview of the codebase, its architecture, and its components. The analysis is performed using Language Server Protocol (LSP) for precise code intelligence, with fallback to AST/regex-based analysis when LSP is unavailable.
## Tech Stack
| Category | Technology |
|----------|------------|
| Language | [Detected from configuration files] |
| Runtime | [Node.js / Python / Go / etc.] |
| Package Manager | [npm / pip / go mod / etc.] |
| Key Dependencies | [List from lockfile or manifest] |
| Build Tools | [Webpack / Vite / Make / etc.] |
## Dependencies
- **Runtime Dependencies**: [List with versions]
- **Development Dependencies**: [List with versions]
- **Peer/Transitive Dependencies**: [Notable ones]
---
# Architecture
```mermaid
flowchart TB
subgraph Entry["Entry Points"]
A[main.py / index.ts / App.tsx]
end
subgraph Core["Core Layer"]
B[Services]
C[Models]
D[Utilities]
end
subgraph Interface["Interface Layer"]
E[API Routes]
F[CLI Commands]
G[UI Components]
end
subgraph External["External Systems"]
H[Database]
I[Third-party APIs]
J[Message Queues]
end
A --> B
A --> E
A --> F
A --> G
B --> C
B --> D
E --> B
F --> B
G --> B
B --> H
B --> I
B --> J
```
---
# Project Structure
```
.
├── src/ # Source code
│ ├── main.py # Entry point
│ ├── core/ # Core business logic
│ │ ├── services/ # Service layer
│ │ ├── models/ # Data models
│ │ └── utils/ # Utilities
│ ├── api/ # API endpoints
│ ├── cli/ # CLI commands
│ └── ui/ # UI components
├── tests/ # Test suite
├── config/ # Configuration files
├── docs/ # Documentation
├── scripts/ # Build/deploy scripts
├── package.json # Dependencies (if Node.js)
├── pyproject.toml # Dependencies (if Python)
├── go.mod # Dependencies (if Go)
└── README.md
```
---
# Core Components
## Component 1: [Name]
**File**: `src/core/services/[name].py`
**Description**: [Brief description of purpose]
### Key Functions/Methods
| Name | Signature | Description |
|------|-----------|-------------|
| `[function]` | `[params] -> [return]` | [Description] |
### Dependencies
- **Internal**: [List of internal dependencies]
- **External**: [List of external dependencies]
---
## Component 2: [Name]
**File**: `src/core/models/[name].py`
**Description**: [Brief description of purpose]
### Class Hierarchy
```mermaid
classDiagram
class BaseModel {
+id: int
+created_at: datetime
+updated_at: datetime
+save() void
+delete() void
}
class [DerivedModel] {
+[field]: [type]
+[method]() [return]
}
BaseModel <|-- [DerivedModel]
```
---
# Data Flow
```mermaid
sequenceDiagram
participant Client
participant API
participant Service
participant Model
participant DB
Client->>API: HTTP Request
API->>Service: Validate & Process
Service->>Model: Query/Transform
Model->>DB: Execute Query
DB-->>Model: Return Result
Model-->>Service: Data Object
Service-->>API: Response DTO
API-->>Client: HTTP Response
```
---
# Data Model
## Entity Relationship Diagram
```mermaid
erDiagram
USER ||--o{ ORDER : places
USER {
int id PK
string name
string email
datetime created_at
}
ORDER ||--|{ ORDER_ITEM : contains
ORDER {
int id PK
int user_id FK
float total
string status
datetime created_at
}
ORDER_ITEM {
int id PK
int order_id FK
int product_id FK
int quantity
float price
}
PRODUCT ||--o{ ORDER_ITEM : included_in
PRODUCT {
int id PK
string name
string description
float price
int stock
}
```
## Class Diagram
```mermaid
classDiagram
class User {
-int id
-string name
-string email
-datetime created_at
+get_orders() List~Order~
+save() void
}
class Order {
-int id
-int user_id
-float total
-string status
-datetime created_at
+calculate_total() float
+update_status(string) void
}
class OrderItem {
-int id
-int order_id
-int product_id
-int quantity
-float price
+get_subtotal() float
}
class Product {
-int id
-string name
-string description
-float price
-int stock
+update_stock(int) void
}
User "1" --> "0..*" Order
Order "1" --> "1..*" OrderItem
Product "1" --> "0..*" OrderItem
```
---
# API Reference
## Endpoint: `GET /api/[resource]`
**Description**: [Description of endpoint]
### Request
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `[param]` | `[type]` | Yes/No | [Description] |
### Response
**Status Codes**:
- `200 OK`: Successful response
- `400 Bad Request`: Invalid parameters
- `404 Not Found`: Resource not found
- `500 Internal Server Error`: Server error
**Response Body**:
```json
{
"status": "success",
"data": {
"id": 1,
"name": "example"
}
}
```
---
## Endpoint: `POST /api/[resource]`
**Description**: [Description of endpoint]
### Request Body
```json
{
"name": "string",
"description": "string",
"price": 0.00
}
```
### Response
**Status Codes**:
- `201 Created`: Resource created
- `422 Unprocessable Entity`: Validation error
---
# Configuration
## Environment Variables
| Variable | Default | Description |
|----------|---------|-------------|
| `DATABASE_URL` | `sqlite:///db.sqlite3` | Database connection string |
| `API_PORT` | `8000` | API server port |
| `LOG_LEVEL` | `INFO` | Logging level |
| `SECRET_KEY` | - | Application secret key |
## Configuration Files
### `config/settings.py`
```python
# Core settings
DEBUG = os.getenv("DEBUG", "False") == "True"
DATABASE_URL = os.getenv("DATABASE_URL", "sqlite:///db.sqlite3")
API_PORT = int(os.getenv("API_PORT", "8000"))
```
### `package.json` (if Node.js)
```json
{
"name": "project-name",
"version": "1.0.0",
"scripts": {
"start": "node src/index.js",
"test": "jest",
"build": "webpack"
}
}
```
---
# Getting Started
## Prerequisites
- [Language runtime] version [X.Y.Z] or higher
- [Package manager] version [X.Y.Z] or higher
- [Database] (if applicable)
## Installation
### 1. Clone the repository
```bash
git clone https://github.com/[org]/[repo].git
cd [repo]
```
### 2. Install dependencies
**For Node.js**:
```bash
npm install
```
**For Python**:
```bash
pip install -r requirements.txt
# or
poetry install
```
**For Go**:
```bash
go mod download
```
### 3. Configure environment
```bash
cp .env.example .env
# Edit .env with your configuration
```
### 4. Initialize database
```bash
npm run db:migrate
# or
python manage.py migrate
```
### 5. Start the application
```bash
npm start
# or
python src/main.py
# or
go run main.go
```
---
# Development Guide
## Setting Up Development Environment
### LSP Configuration
This project uses Language Server Protocol for code intelligence. Configure your editor:
**VS Code**:
```json
{
"lsp": {
"language": "python",
"server": "pyright-langserver",
"args": ["--stdio"]
}
}
```
**Neovim**:
```lua
require('lspconfig').[language_server].setup {
cmd = { '[server]', '--stdio' },
settings = {
-- LSP-specific settings
}
}
```
## Code Style
- Follow [language-specific style guide] (e.g., PEP 8 for Python, StandardJS for JavaScript)
- Use [formatter] (e.g., Black, Prettier, gofmt)
- Use [linter] (e.g., ESLint, Pylint, golangci-lint)
## Testing
```bash
# Run all tests
npm test
# or
pytest
# or
go test ./...
# Run with coverage
npm run test:coverage
# or
pytest --cov=src
```
## Building
```bash
# Development build
npm run build:dev
# or
python setup.py develop
# Production build
npm run build:prod
# or
python setup.py install
```
## Debugging
### LSP Debugging
Enable LSP logging for debugging:
```json
{
"lsp": {
"logLevel": "debug",
"logFile": "/tmp/lsp.log"
}
}
```
### Application Debugging
```bash
# Node.js
node --inspect src/index.js
# Python
python -m debugpy --listen 5678 src/main.py
# Go
dlv debug main.go
```
## Common Tasks
### Adding a New API Endpoint
1. Create route in `src/api/routes/`
2. Add handler function in `src/api/handlers/`
3. Register route in `src/api/index.py`
4. Add tests in `tests/api/`
### Adding a New Model
1. Define model class in `src/core/models/`
2. Create migration
3. Update service layer
4. Add API endpoints
5. Update documentation
### Adding a New Service
1. Create service class in `src/core/services/`
2. Register in dependency injection container
3. Add unit tests
4. Update API layer
## Performance Considerations
- Use connection pooling for database connections
- Implement caching for frequently accessed data
- Use async/await for I/O-bound operations
- Profile with [profiler] (e.g., cProfile, Chrome DevTools)
## Security Best Practices
- Validate all user input
- Use parameterized queries to prevent SQL injection
- Implement rate limiting on API endpoints
- Use HTTPS in production
- Store secrets in environment variables or secret manager
## Deployment
### Docker
```dockerfile
FROM [base_image]
WORKDIR /app
COPY . .
RUN [install_commands]
EXPOSE [port]
CMD ["[start_command]"]
```
### CI/CD Pipeline
```yaml
# .github/workflows/main.yml
name: CI/CD
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run tests
run: |
[install_commands]
[test_commands]
deploy:
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Deploy
run: [deploy_commands]
```
## Troubleshooting
### Common Issues
| Issue | Solution |
|-------|----------|
| LSP server not starting | Check language server installation and configuration |
| Module not found | Run `[install_commands]` to install dependencies |
| Database connection error | Verify `DATABASE_URL` and database service status |
| Port already in use | Change `API_PORT` in configuration |
### Getting Help
- Check the [issue tracker](https://github.com/[org]/[repo]/issues)
- Join the [community chat](https://discord.gg/[invite])
- Read the [FAQ](docs/FAQ.md)
---
## Appendix
### Glossary
| Term | Definition |
|------|------------|
| LSP | Language Server Protocol - a protocol for code analysis |
| AST | Abstract Syntax Tree - a tree representation of source code |
| DTO | Data Transfer Object - an object that carries data between processes |
### References
- [Language documentation](https://docs.[language].org)
- [Framework documentation](https://docs.[framework].org)
- [LSP specification](https://microsoft.github.io/language-server-protocol/)
---
*This documentation was generated automatically using LSP-based code analysis. Last updated: [date]*
Connectez-vous pour voir le prompt complet
Continuer avec:
En vous connectant, vous acceptez nos Conditions et Confidentialité
Utilisation
Ce prompt est conçu pour être utilisé avec coding. Copiez le contenu ci-dessus et collez-le dans votre outil d’IA préféré.
Pour de meilleurs résultats, personnalisez les espaces réservés (indiqués par des crochets ou des majuscules) selon vos besoins.
Discussion
0 commentaires