@aicgen/aicgen 1.0.0-beta.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{.claude/guidelines → .agent/rules}/api-design.md +5 -1
- package/{.claude/guidelines → .agent/rules}/architecture.md +5 -1
- package/{.claude/guidelines → .agent/rules}/best-practices.md +5 -1
- package/{.claude/guidelines → .agent/rules}/code-style.md +5 -1
- package/{.claude/guidelines → .agent/rules}/design-patterns.md +5 -1
- package/{.claude/guidelines → .agent/rules}/devops.md +5 -1
- package/{.claude/guidelines → .agent/rules}/error-handling.md +5 -1
- package/.agent/rules/instructions.md +28 -0
- package/{.claude/guidelines → .agent/rules}/language.md +5 -1
- package/{.claude/guidelines → .agent/rules}/performance.md +5 -1
- package/{.claude/guidelines → .agent/rules}/security.md +5 -1
- package/{.claude/guidelines → .agent/rules}/testing.md +5 -1
- package/.agent/workflows/add-documentation.md +10 -0
- package/.agent/workflows/generate-integration-tests.md +10 -0
- package/.agent/workflows/generate-unit-tests.md +11 -0
- package/.agent/workflows/performance-audit.md +11 -0
- package/.agent/workflows/refactor-extract-module.md +12 -0
- package/.agent/workflows/security-audit.md +12 -0
- package/.gemini/instructions.md +4843 -0
- package/.vs/ProjectSettings.json +2 -2
- package/.vs/VSWorkspaceState.json +15 -15
- package/.vs/aicgen.slnx/v18/DocumentLayout.json +53 -53
- package/AGENTS.md +9 -11
- package/assets/icon.svg +33 -33
- package/bun.lock +734 -26
- package/{CLAUDE.md → claude.md} +2 -2
- package/config.example.yml +129 -0
- package/config.yml +38 -0
- package/data/architecture/microservices/api-gateway.md +56 -56
- package/data/devops/observability.md +73 -73
- package/data/guideline-mappings.yml +128 -0
- package/data/language/dart/async.md +289 -0
- package/data/language/dart/basics.md +280 -0
- package/data/language/dart/error-handling.md +355 -0
- package/data/language/dart/index.md +10 -0
- package/data/language/dart/testing.md +352 -0
- package/data/language/swift/basics.md +477 -0
- package/data/language/swift/concurrency.md +654 -0
- package/data/language/swift/error-handling.md +679 -0
- package/data/language/swift/swiftui-mvvm.md +795 -0
- package/data/language/swift/testing.md +708 -0
- package/data/version.json +10 -8
- package/dist/index.js +50153 -28959
- package/jest.config.js +46 -0
- package/package.json +14 -3
- package/.claude/agents/architecture-reviewer.md +0 -88
- package/.claude/agents/guideline-checker.md +0 -73
- package/.claude/agents/security-auditor.md +0 -108
- package/.claude/settings.json +0 -98
- package/.claude/settings.local.json +0 -8
- package/.eslintrc.json +0 -28
- package/.github/workflows/release.yml +0 -180
- package/.github/workflows/test.yml +0 -81
- package/CONTRIBUTING.md +0 -821
- package/dist/commands/init.d.ts +0 -8
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js +0 -46
- package/dist/commands/init.js.map +0 -1
- package/dist/config/profiles.d.ts +0 -4
- package/dist/config/profiles.d.ts.map +0 -1
- package/dist/config/profiles.js +0 -30
- package/dist/config/profiles.js.map +0 -1
- package/dist/config/settings.d.ts +0 -7
- package/dist/config/settings.d.ts.map +0 -1
- package/dist/config/settings.js +0 -7
- package/dist/config/settings.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/models/guideline.d.ts +0 -15
- package/dist/models/guideline.d.ts.map +0 -1
- package/dist/models/guideline.js +0 -2
- package/dist/models/guideline.js.map +0 -1
- package/dist/models/preference.d.ts +0 -9
- package/dist/models/preference.d.ts.map +0 -1
- package/dist/models/preference.js +0 -2
- package/dist/models/preference.js.map +0 -1
- package/dist/models/profile.d.ts +0 -9
- package/dist/models/profile.d.ts.map +0 -1
- package/dist/models/profile.js +0 -2
- package/dist/models/profile.js.map +0 -1
- package/dist/models/project.d.ts +0 -13
- package/dist/models/project.d.ts.map +0 -1
- package/dist/models/project.js +0 -2
- package/dist/models/project.js.map +0 -1
- package/dist/services/ai/anthropic.d.ts +0 -7
- package/dist/services/ai/anthropic.d.ts.map +0 -1
- package/dist/services/ai/anthropic.js +0 -39
- package/dist/services/ai/anthropic.js.map +0 -1
- package/dist/services/generator.d.ts +0 -2
- package/dist/services/generator.d.ts.map +0 -1
- package/dist/services/generator.js +0 -4
- package/dist/services/generator.js.map +0 -1
- package/dist/services/learner.d.ts +0 -2
- package/dist/services/learner.d.ts.map +0 -1
- package/dist/services/learner.js +0 -4
- package/dist/services/learner.js.map +0 -1
- package/dist/services/scanner.d.ts +0 -3
- package/dist/services/scanner.d.ts.map +0 -1
- package/dist/services/scanner.js +0 -54
- package/dist/services/scanner.js.map +0 -1
- package/dist/utils/errors.d.ts +0 -15
- package/dist/utils/errors.d.ts.map +0 -1
- package/dist/utils/errors.js +0 -27
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/file.d.ts +0 -7
- package/dist/utils/file.d.ts.map +0 -1
- package/dist/utils/file.js +0 -32
- package/dist/utils/file.js.map +0 -1
- package/dist/utils/logger.d.ts +0 -6
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js +0 -17
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/path.d.ts +0 -6
- package/dist/utils/path.d.ts.map +0 -1
- package/dist/utils/path.js +0 -14
- package/dist/utils/path.js.map +0 -1
- package/docs/planning/memory-lane.md +0 -83
- package/packaging/linux/aicgen.spec +0 -23
- package/packaging/linux/control +0 -9
- package/packaging/macos/scripts/postinstall +0 -12
- package/packaging/windows/setup.nsi +0 -92
- package/scripts/add-categories.ts +0 -87
- package/scripts/build-binary.ts +0 -46
- package/scripts/embed-data.ts +0 -105
- package/scripts/generate-version.ts +0 -150
- package/scripts/test-decompress.ts +0 -27
- package/scripts/test-extract.ts +0 -31
- package/src/__tests__/services/assistant-file-writer.test.ts +0 -400
- package/src/__tests__/services/guideline-loader.test.ts +0 -281
- package/src/__tests__/services/tarball-extraction.test.ts +0 -125
- package/src/commands/add-guideline.ts +0 -296
- package/src/commands/clear.ts +0 -61
- package/src/commands/guideline-selector.ts +0 -123
- package/src/commands/init.ts +0 -645
- package/src/commands/quick-add.ts +0 -586
- package/src/commands/remove-guideline.ts +0 -152
- package/src/commands/stats.ts +0 -49
- package/src/commands/update.ts +0 -240
- package/src/config.ts +0 -82
- package/src/embedded-data.ts +0 -1492
- package/src/index.ts +0 -67
- package/src/models/profile.ts +0 -24
- package/src/models/project.ts +0 -43
- package/src/services/assistant-file-writer.ts +0 -612
- package/src/services/config-generator.ts +0 -150
- package/src/services/config-manager.ts +0 -70
- package/src/services/data-source.ts +0 -248
- package/src/services/first-run-init.ts +0 -148
- package/src/services/guideline-loader.ts +0 -311
- package/src/services/hook-generator.ts +0 -178
- package/src/services/subagent-generator.ts +0 -310
- package/src/utils/banner.ts +0 -66
- package/src/utils/errors.ts +0 -27
- package/src/utils/file.ts +0 -67
- package/src/utils/formatting.ts +0 -172
- package/src/utils/logger.ts +0 -89
- package/src/utils/path.ts +0 -17
- package/src/utils/wizard-state.ts +0 -132
- package/tsconfig.json +0 -25
package/{CLAUDE.md → claude.md}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# my-project - Development Guidelines
|
|
2
2
|
|
|
3
3
|
**Role:** You are an expert software engineer specialized in typescript.
|
|
4
4
|
**User's Goal:** Build high-quality, maintainable software following strict project guidelines.
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
This project follows structured coding guidelines organized by category:
|
|
9
9
|
|
|
10
10
|
- **Language**: @.claude/guidelines/language.md
|
|
11
|
-
- **Architecture**: @.claude/guidelines/architecture.md
|
|
12
11
|
- **Testing**: @.claude/guidelines/testing.md
|
|
13
12
|
- **Security**: @.claude/guidelines/security.md
|
|
14
13
|
- **Performance**: @.claude/guidelines/performance.md
|
|
15
14
|
- **API Design**: @.claude/guidelines/api-design.md
|
|
16
15
|
- **Code Style**: @.claude/guidelines/code-style.md
|
|
17
16
|
- **Error Handling**: @.claude/guidelines/error-handling.md
|
|
17
|
+
- **Architecture**: @.claude/guidelines/architecture.md
|
|
18
18
|
- **DevOps**: @.claude/guidelines/devops.md
|
|
19
19
|
- **Best Practices**: @.claude/guidelines/best-practices.md
|
|
20
20
|
- **Design Patterns**: @.claude/guidelines/design-patterns.md
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Example AICGEN Configuration File
|
|
2
|
+
#
|
|
3
|
+
# LOCATION: This file should be placed at:
|
|
4
|
+
# - Windows: C:\Users\YourUsername\.aicgen\config.yml
|
|
5
|
+
# - Linux/Mac: ~/.aicgen/config.yml
|
|
6
|
+
#
|
|
7
|
+
# INSTALLATION:
|
|
8
|
+
# Windows:
|
|
9
|
+
# mkdir C:\Users\%USERNAME%\.aicgen
|
|
10
|
+
# copy config.example.yml C:\Users\%USERNAME%\.aicgen\config.yml
|
|
11
|
+
#
|
|
12
|
+
# Linux/Mac:
|
|
13
|
+
# mkdir -p ~/.aicgen
|
|
14
|
+
# cp config.example.yml ~/.aicgen/config.yml
|
|
15
|
+
#
|
|
16
|
+
# Configuration priority: Environment Variables > User Config > Defaults
|
|
17
|
+
|
|
18
|
+
# GitHub repository configuration
|
|
19
|
+
github:
|
|
20
|
+
owner: aicgen
|
|
21
|
+
repo: aicgen-data
|
|
22
|
+
|
|
23
|
+
# AI Provider Configuration
|
|
24
|
+
# Customize models, timeouts, and behavior for different AI providers
|
|
25
|
+
ai:
|
|
26
|
+
# Google Gemini Configuration
|
|
27
|
+
gemini:
|
|
28
|
+
# Model: Use latest Gemini 2.0 or 2.5 models
|
|
29
|
+
# See: https://ai.google.dev/gemini-api/docs/models
|
|
30
|
+
model: gemini-2.0-flash-exp
|
|
31
|
+
# Available models:
|
|
32
|
+
# - gemini-2.5-flash (latest, recommended)
|
|
33
|
+
# - gemini-2.5-pro (most capable, slower)
|
|
34
|
+
# - gemini-2.0-flash-exp (experimental, fast)
|
|
35
|
+
|
|
36
|
+
# Request timeout in milliseconds
|
|
37
|
+
timeout: 30000
|
|
38
|
+
|
|
39
|
+
# Maximum retry attempts for failed requests
|
|
40
|
+
maxRetries: 3
|
|
41
|
+
|
|
42
|
+
# Maximum output tokens
|
|
43
|
+
maxTokens: 8192
|
|
44
|
+
|
|
45
|
+
# Anthropic Claude Configuration
|
|
46
|
+
claude:
|
|
47
|
+
# Model: Use Claude 3.5 Sonnet or Opus
|
|
48
|
+
# See: https://docs.anthropic.com/en/docs/about-claude/models
|
|
49
|
+
model: claude-3-5-sonnet-20241022
|
|
50
|
+
# Available models:
|
|
51
|
+
# - claude-3-5-sonnet-20241022 (best balance, recommended)
|
|
52
|
+
# - claude-3-opus-20240229 (most capable, expensive)
|
|
53
|
+
# - claude-3-haiku-20240307 (fastest, cheapest)
|
|
54
|
+
|
|
55
|
+
# Request timeout in milliseconds
|
|
56
|
+
timeout: 30000
|
|
57
|
+
|
|
58
|
+
# Maximum retry attempts
|
|
59
|
+
maxRetries: 3
|
|
60
|
+
|
|
61
|
+
# Maximum output tokens
|
|
62
|
+
maxTokens: 8096
|
|
63
|
+
|
|
64
|
+
# Temperature (0-1): Lower = more focused, Higher = more creative
|
|
65
|
+
temperature: 0.7
|
|
66
|
+
|
|
67
|
+
# OpenAI Configuration
|
|
68
|
+
openai:
|
|
69
|
+
# Model: Use GPT-4o or GPT-4 Turbo
|
|
70
|
+
# See: https://platform.openai.com/docs/models
|
|
71
|
+
model: gpt-4o
|
|
72
|
+
# Available models:
|
|
73
|
+
# - gpt-4o (latest, recommended)
|
|
74
|
+
# - gpt-4-turbo (high capability)
|
|
75
|
+
# - gpt-4 (most capable, expensive)
|
|
76
|
+
# - gpt-3.5-turbo (fast, cheaper)
|
|
77
|
+
|
|
78
|
+
# Request timeout in milliseconds
|
|
79
|
+
timeout: 30000
|
|
80
|
+
|
|
81
|
+
# Maximum retry attempts
|
|
82
|
+
maxRetries: 3
|
|
83
|
+
|
|
84
|
+
# Maximum output tokens
|
|
85
|
+
maxTokens: 4096
|
|
86
|
+
|
|
87
|
+
# Temperature (0-2): Lower = more focused, Higher = more creative
|
|
88
|
+
temperature: 0.7
|
|
89
|
+
|
|
90
|
+
# Sub-Agent Configuration
|
|
91
|
+
# These are specialized agents for code review tasks
|
|
92
|
+
subAgents:
|
|
93
|
+
# Guideline Checker - Verifies code follows project guidelines
|
|
94
|
+
guidelineChecker:
|
|
95
|
+
model: claude-opus-4-5
|
|
96
|
+
# Use lower temperature for strict guideline checking
|
|
97
|
+
temperature: 0.3
|
|
98
|
+
|
|
99
|
+
# Architecture Reviewer - Reviews architectural decisions
|
|
100
|
+
architectureReviewer:
|
|
101
|
+
model: claude-sonnet-4-5
|
|
102
|
+
# Balanced temperature for architecture review
|
|
103
|
+
temperature: 0.5
|
|
104
|
+
|
|
105
|
+
# Security Auditor - Identifies security vulnerabilities
|
|
106
|
+
securityAuditor:
|
|
107
|
+
model: claude-opus-4-5
|
|
108
|
+
# Lower temperature for thorough security analysis
|
|
109
|
+
temperature: 0.3
|
|
110
|
+
|
|
111
|
+
# Alternative: Use environment variables instead
|
|
112
|
+
# Export these in your shell profile (.bashrc, .zshrc, etc.):
|
|
113
|
+
#
|
|
114
|
+
# # Gemini
|
|
115
|
+
# export AICGEN_GEMINI_MODEL=gemini-2.5-pro
|
|
116
|
+
# export AICGEN_GEMINI_TIMEOUT=60000
|
|
117
|
+
# export AICGEN_GEMINI_MAX_RETRIES=5
|
|
118
|
+
#
|
|
119
|
+
# # Claude
|
|
120
|
+
# export AICGEN_CLAUDE_MODEL=claude-3-opus-20240229
|
|
121
|
+
# export AICGEN_CLAUDE_TEMPERATURE=0.5
|
|
122
|
+
#
|
|
123
|
+
# # OpenAI
|
|
124
|
+
# export AICGEN_OPENAI_MODEL=gpt-4-turbo
|
|
125
|
+
# export AICGEN_OPENAI_TEMPERATURE=0.8
|
|
126
|
+
#
|
|
127
|
+
# # Sub-Agents
|
|
128
|
+
# export AICGEN_SUBAGENT_GUIDELINE_MODEL=claude-opus-4-5
|
|
129
|
+
# export AICGEN_SUBAGENT_GUIDELINE_TEMP=0.2
|
package/config.yml
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
github:
|
|
2
|
+
owner: aicgen
|
|
3
|
+
repo: aicgen-data
|
|
4
|
+
|
|
5
|
+
# AI Provider Configuration
|
|
6
|
+
ai:
|
|
7
|
+
gemini:
|
|
8
|
+
model: gemini-2.0-flash-exp
|
|
9
|
+
timeout: 30000
|
|
10
|
+
maxRetries: 3
|
|
11
|
+
maxTokens: 8192
|
|
12
|
+
|
|
13
|
+
claude:
|
|
14
|
+
model: claude-3-5-sonnet-20241022
|
|
15
|
+
timeout: 30000
|
|
16
|
+
maxRetries: 3
|
|
17
|
+
maxTokens: 8096
|
|
18
|
+
temperature: 0.7
|
|
19
|
+
|
|
20
|
+
openai:
|
|
21
|
+
model: gpt-4o
|
|
22
|
+
timeout: 30000
|
|
23
|
+
maxRetries: 3
|
|
24
|
+
maxTokens: 4096
|
|
25
|
+
temperature: 0.7
|
|
26
|
+
|
|
27
|
+
subAgents:
|
|
28
|
+
guidelineChecker:
|
|
29
|
+
model: claude-opus-4-5
|
|
30
|
+
temperature: 0.3
|
|
31
|
+
|
|
32
|
+
architectureReviewer:
|
|
33
|
+
model: claude-sonnet-4-5
|
|
34
|
+
temperature: 0.5
|
|
35
|
+
|
|
36
|
+
securityAuditor:
|
|
37
|
+
model: claude-opus-4-5
|
|
38
|
+
temperature: 0.3
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
# API Gateway
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
An API Gateway acts as a single entry point for a group of microservices. It handles cross-cutting concerns and routes requests to the appropriate backend services.
|
|
6
|
-
|
|
7
|
-
## Core Responsibilities
|
|
8
|
-
|
|
9
|
-
1. **Routing**: Forwarding requests to the correct service (e.g., `/api/users` -> User Service).
|
|
10
|
-
2. **Authentication & Authorization**: Verifying identity and permissions at the edge.
|
|
11
|
-
3. **Rate Limiting**: Protecting services from abuse.
|
|
12
|
-
4. **Protocol Translation**: Converting public HTTP/REST to internal gRPC or AMQP.
|
|
13
|
-
5. **Response Aggregation**: Combining data from multiple services into a single response.
|
|
14
|
-
|
|
15
|
-
## Patterns
|
|
16
|
-
|
|
17
|
-
### Backend for Frontend (BFF)
|
|
18
|
-
|
|
19
|
-
Create separate gateways for different client types (Mobile, Web, 3rd Party) to optimize the API for each consumer.
|
|
20
|
-
|
|
21
|
-
```mermaid
|
|
22
|
-
graph TD
|
|
23
|
-
Web[Web App] --> WebBFF[Web BFF]
|
|
24
|
-
Mobile[Mobile App] --> MobileBFF[Mobile BFF]
|
|
25
|
-
|
|
26
|
-
WebBFF --> SvcA[Service A]
|
|
27
|
-
WebBFF --> SvcB[Service B]
|
|
28
|
-
|
|
29
|
-
MobileBFF --> SvcA
|
|
30
|
-
MobileBFF --> SvcC[Service C]
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## Implementation
|
|
34
|
-
|
|
35
|
-
### Cross-Cutting Concerns
|
|
36
|
-
|
|
37
|
-
Handle these at the gateway to keep microservices focused on business logic:
|
|
38
|
-
|
|
39
|
-
- **SSL Termination**: Decrypt HTTPS at the gateway.
|
|
40
|
-
- **CORS**: Handle Cross-Origin Resource Sharing headers.
|
|
41
|
-
- **Request Validation**: Basic schema validation before hitting services.
|
|
42
|
-
- **Caching**: Cache common responses.
|
|
43
|
-
|
|
44
|
-
### When to Use
|
|
45
|
-
|
|
46
|
-
| Use API Gateway When... | Avoid API Gateway When... |
|
|
47
|
-
|-------------------------|---------------------------|
|
|
48
|
-
| You have multiple microservices | You have a monolithic application |
|
|
49
|
-
| You need centralized auth/security | You need ultra-low latency (extra hop) |
|
|
50
|
-
| You have diverse clients (Web, Mobile) | Your architecture is very simple |
|
|
51
|
-
|
|
52
|
-
## Best Practices
|
|
53
|
-
|
|
54
|
-
- **Keep it Logic-Free**: Don't put business logic in the gateway. It should be a router, not a processor.
|
|
55
|
-
- **High Availability**: The gateway is a single point of failure; deploy it in a cluster.
|
|
56
|
-
- **Observability**: Ensure the gateway generates trace IDs and logs all traffic.
|
|
1
|
+
# API Gateway
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
An API Gateway acts as a single entry point for a group of microservices. It handles cross-cutting concerns and routes requests to the appropriate backend services.
|
|
6
|
+
|
|
7
|
+
## Core Responsibilities
|
|
8
|
+
|
|
9
|
+
1. **Routing**: Forwarding requests to the correct service (e.g., `/api/users` -> User Service).
|
|
10
|
+
2. **Authentication & Authorization**: Verifying identity and permissions at the edge.
|
|
11
|
+
3. **Rate Limiting**: Protecting services from abuse.
|
|
12
|
+
4. **Protocol Translation**: Converting public HTTP/REST to internal gRPC or AMQP.
|
|
13
|
+
5. **Response Aggregation**: Combining data from multiple services into a single response.
|
|
14
|
+
|
|
15
|
+
## Patterns
|
|
16
|
+
|
|
17
|
+
### Backend for Frontend (BFF)
|
|
18
|
+
|
|
19
|
+
Create separate gateways for different client types (Mobile, Web, 3rd Party) to optimize the API for each consumer.
|
|
20
|
+
|
|
21
|
+
```mermaid
|
|
22
|
+
graph TD
|
|
23
|
+
Web[Web App] --> WebBFF[Web BFF]
|
|
24
|
+
Mobile[Mobile App] --> MobileBFF[Mobile BFF]
|
|
25
|
+
|
|
26
|
+
WebBFF --> SvcA[Service A]
|
|
27
|
+
WebBFF --> SvcB[Service B]
|
|
28
|
+
|
|
29
|
+
MobileBFF --> SvcA
|
|
30
|
+
MobileBFF --> SvcC[Service C]
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Implementation
|
|
34
|
+
|
|
35
|
+
### Cross-Cutting Concerns
|
|
36
|
+
|
|
37
|
+
Handle these at the gateway to keep microservices focused on business logic:
|
|
38
|
+
|
|
39
|
+
- **SSL Termination**: Decrypt HTTPS at the gateway.
|
|
40
|
+
- **CORS**: Handle Cross-Origin Resource Sharing headers.
|
|
41
|
+
- **Request Validation**: Basic schema validation before hitting services.
|
|
42
|
+
- **Caching**: Cache common responses.
|
|
43
|
+
|
|
44
|
+
### When to Use
|
|
45
|
+
|
|
46
|
+
| Use API Gateway When... | Avoid API Gateway When... |
|
|
47
|
+
|-------------------------|---------------------------|
|
|
48
|
+
| You have multiple microservices | You have a monolithic application |
|
|
49
|
+
| You need centralized auth/security | You need ultra-low latency (extra hop) |
|
|
50
|
+
| You have diverse clients (Web, Mobile) | Your architecture is very simple |
|
|
51
|
+
|
|
52
|
+
## Best Practices
|
|
53
|
+
|
|
54
|
+
- **Keep it Logic-Free**: Don't put business logic in the gateway. It should be a router, not a processor.
|
|
55
|
+
- **High Availability**: The gateway is a single point of failure; deploy it in a cluster.
|
|
56
|
+
- **Observability**: Ensure the gateway generates trace IDs and logs all traffic.
|
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
# Observability
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
Observability is the ability to understand the internal state of a system by examining its outputs. In modern distributed systems, it goes beyond simple monitoring to include logging, metrics, and tracing.
|
|
6
|
-
|
|
7
|
-
## Three Pillars
|
|
8
|
-
|
|
9
|
-
### 1. Structured Logging
|
|
10
|
-
|
|
11
|
-
Logs should be machine-readable (JSON) and contain context.
|
|
12
|
-
|
|
13
|
-
```json
|
|
14
|
-
// ✅ Good: Structured JSON logging
|
|
15
|
-
{
|
|
16
|
-
"level": "info",
|
|
17
|
-
"message": "Order processed",
|
|
18
|
-
"orderId": "ord_123",
|
|
19
|
-
"userId": "user_456",
|
|
20
|
-
"amount": 99.99,
|
|
21
|
-
"durationMs": 145,
|
|
22
|
-
"status": "success"
|
|
23
|
-
}
|
|
24
|
-
```
|
|
25
|
-
```text
|
|
26
|
-
// ❌ Bad: Unstructured text
|
|
27
|
-
"Order processed: ord_123 for user_456"
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### 2. Metrics
|
|
31
|
-
|
|
32
|
-
Aggregatable data points for identifying trends and health.
|
|
33
|
-
|
|
34
|
-
- **Counters**: Total requests, error counts (`http_requests_total`)
|
|
35
|
-
- **Gauges**: Queue depth, memory usage (`memory_usage_bytes`)
|
|
36
|
-
- **Histograms**: Request latency distribution (`http_request_duration_seconds`)
|
|
37
|
-
|
|
38
|
-
### 3. Distributed Tracing
|
|
39
|
-
|
|
40
|
-
Tracking requests as they propagate through services.
|
|
41
|
-
|
|
42
|
-
- **Trace ID**: Unique ID for the entire request chain
|
|
43
|
-
- **Span ID**: Unique ID for a specific operation
|
|
44
|
-
- **Context Propagation**: Passing IDs between services (e.g., W3C Trace Context)
|
|
45
|
-
|
|
46
|
-
## Implementation Strategy
|
|
47
|
-
|
|
48
|
-
### OpenTelemetry (OTel)
|
|
49
|
-
|
|
50
|
-
Use OpenTelemetry as the vendor-neutral standard for collecting telemetry data.
|
|
51
|
-
|
|
52
|
-
```text
|
|
53
|
-
# Initialize OpenTelemetry SDK
|
|
54
|
-
SDK.Configure({
|
|
55
|
-
TraceExporter: Console/OTLP,
|
|
56
|
-
Instrumentations: [Http, Database, Grpc]
|
|
57
|
-
})
|
|
58
|
-
SDK.Start()
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
### Health Checks
|
|
62
|
-
|
|
63
|
-
Expose standard health endpoints:
|
|
64
|
-
|
|
65
|
-
- `/health/live`: Is the process running? (Liveness)
|
|
66
|
-
- `/health/ready`: Can it accept traffic? (Readiness)
|
|
67
|
-
- `/health/startup`: Has it finished initializing? (Startup)
|
|
68
|
-
|
|
69
|
-
## Alerting Best Practices
|
|
70
|
-
|
|
71
|
-
- **Alert on Symptoms, not Causes**: "High Error Rate" (Symptom) vs "CPU High" (Cause).
|
|
72
|
-
- **Golden Signals**: Latency, Traffic, Errors, Saturation.
|
|
73
|
-
- **Actionable**: Every alert should require a specific human action.
|
|
1
|
+
# Observability
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Observability is the ability to understand the internal state of a system by examining its outputs. In modern distributed systems, it goes beyond simple monitoring to include logging, metrics, and tracing.
|
|
6
|
+
|
|
7
|
+
## Three Pillars
|
|
8
|
+
|
|
9
|
+
### 1. Structured Logging
|
|
10
|
+
|
|
11
|
+
Logs should be machine-readable (JSON) and contain context.
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
// ✅ Good: Structured JSON logging
|
|
15
|
+
{
|
|
16
|
+
"level": "info",
|
|
17
|
+
"message": "Order processed",
|
|
18
|
+
"orderId": "ord_123",
|
|
19
|
+
"userId": "user_456",
|
|
20
|
+
"amount": 99.99,
|
|
21
|
+
"durationMs": 145,
|
|
22
|
+
"status": "success"
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
```text
|
|
26
|
+
// ❌ Bad: Unstructured text
|
|
27
|
+
"Order processed: ord_123 for user_456"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### 2. Metrics
|
|
31
|
+
|
|
32
|
+
Aggregatable data points for identifying trends and health.
|
|
33
|
+
|
|
34
|
+
- **Counters**: Total requests, error counts (`http_requests_total`)
|
|
35
|
+
- **Gauges**: Queue depth, memory usage (`memory_usage_bytes`)
|
|
36
|
+
- **Histograms**: Request latency distribution (`http_request_duration_seconds`)
|
|
37
|
+
|
|
38
|
+
### 3. Distributed Tracing
|
|
39
|
+
|
|
40
|
+
Tracking requests as they propagate through services.
|
|
41
|
+
|
|
42
|
+
- **Trace ID**: Unique ID for the entire request chain
|
|
43
|
+
- **Span ID**: Unique ID for a specific operation
|
|
44
|
+
- **Context Propagation**: Passing IDs between services (e.g., W3C Trace Context)
|
|
45
|
+
|
|
46
|
+
## Implementation Strategy
|
|
47
|
+
|
|
48
|
+
### OpenTelemetry (OTel)
|
|
49
|
+
|
|
50
|
+
Use OpenTelemetry as the vendor-neutral standard for collecting telemetry data.
|
|
51
|
+
|
|
52
|
+
```text
|
|
53
|
+
# Initialize OpenTelemetry SDK
|
|
54
|
+
SDK.Configure({
|
|
55
|
+
TraceExporter: Console/OTLP,
|
|
56
|
+
Instrumentations: [Http, Database, Grpc]
|
|
57
|
+
})
|
|
58
|
+
SDK.Start()
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Health Checks
|
|
62
|
+
|
|
63
|
+
Expose standard health endpoints:
|
|
64
|
+
|
|
65
|
+
- `/health/live`: Is the process running? (Liveness)
|
|
66
|
+
- `/health/ready`: Can it accept traffic? (Readiness)
|
|
67
|
+
- `/health/startup`: Has it finished initializing? (Startup)
|
|
68
|
+
|
|
69
|
+
## Alerting Best Practices
|
|
70
|
+
|
|
71
|
+
- **Alert on Symptoms, not Causes**: "High Error Rate" (Symptom) vs "CPU High" (Cause).
|
|
72
|
+
- **Golden Signals**: Latency, Traffic, Errors, Saturation.
|
|
73
|
+
- **Actionable**: Every alert should require a specific human action.
|
|
@@ -332,6 +332,134 @@ javascript-testing:
|
|
|
332
332
|
- testing
|
|
333
333
|
- jest
|
|
334
334
|
category: Language
|
|
335
|
+
dart-basics:
|
|
336
|
+
path: language/dart/basics.md
|
|
337
|
+
languages:
|
|
338
|
+
- dart
|
|
339
|
+
levels:
|
|
340
|
+
- basic
|
|
341
|
+
- standard
|
|
342
|
+
- expert
|
|
343
|
+
- full
|
|
344
|
+
tags:
|
|
345
|
+
- dart
|
|
346
|
+
- fundamentals
|
|
347
|
+
- null-safety
|
|
348
|
+
category: Language
|
|
349
|
+
dart-async:
|
|
350
|
+
path: language/dart/async.md
|
|
351
|
+
languages:
|
|
352
|
+
- dart
|
|
353
|
+
levels:
|
|
354
|
+
- basic
|
|
355
|
+
- standard
|
|
356
|
+
- expert
|
|
357
|
+
- full
|
|
358
|
+
tags:
|
|
359
|
+
- dart
|
|
360
|
+
- async
|
|
361
|
+
- futures
|
|
362
|
+
- streams
|
|
363
|
+
category: Language
|
|
364
|
+
dart-error-handling:
|
|
365
|
+
path: language/dart/error-handling.md
|
|
366
|
+
languages:
|
|
367
|
+
- dart
|
|
368
|
+
levels:
|
|
369
|
+
- standard
|
|
370
|
+
- expert
|
|
371
|
+
- full
|
|
372
|
+
tags:
|
|
373
|
+
- dart
|
|
374
|
+
- errors
|
|
375
|
+
- exceptions
|
|
376
|
+
category: Language
|
|
377
|
+
dart-testing:
|
|
378
|
+
path: language/dart/testing.md
|
|
379
|
+
languages:
|
|
380
|
+
- dart
|
|
381
|
+
levels:
|
|
382
|
+
- standard
|
|
383
|
+
- expert
|
|
384
|
+
- full
|
|
385
|
+
tags:
|
|
386
|
+
- dart
|
|
387
|
+
- testing
|
|
388
|
+
- flutter
|
|
389
|
+
category: Language
|
|
390
|
+
swift-basics:
|
|
391
|
+
path: language/swift/basics.md
|
|
392
|
+
languages:
|
|
393
|
+
- swift
|
|
394
|
+
levels:
|
|
395
|
+
- basic
|
|
396
|
+
- standard
|
|
397
|
+
- expert
|
|
398
|
+
- full
|
|
399
|
+
tags:
|
|
400
|
+
- swift
|
|
401
|
+
- fundamentals
|
|
402
|
+
- optionals
|
|
403
|
+
- value-types
|
|
404
|
+
category: Language
|
|
405
|
+
swift-concurrency:
|
|
406
|
+
path: language/swift/concurrency.md
|
|
407
|
+
languages:
|
|
408
|
+
- swift
|
|
409
|
+
levels:
|
|
410
|
+
- standard
|
|
411
|
+
- expert
|
|
412
|
+
- full
|
|
413
|
+
tags:
|
|
414
|
+
- swift
|
|
415
|
+
- async
|
|
416
|
+
- actors
|
|
417
|
+
- structured-concurrency
|
|
418
|
+
- task
|
|
419
|
+
category: Language
|
|
420
|
+
swift-swiftui-mvvm:
|
|
421
|
+
path: language/swift/swiftui-mvvm.md
|
|
422
|
+
languages:
|
|
423
|
+
- swift
|
|
424
|
+
levels:
|
|
425
|
+
- standard
|
|
426
|
+
- expert
|
|
427
|
+
- full
|
|
428
|
+
tags:
|
|
429
|
+
- swift
|
|
430
|
+
- swiftui
|
|
431
|
+
- mvvm
|
|
432
|
+
- state-management
|
|
433
|
+
- combine
|
|
434
|
+
category: Language
|
|
435
|
+
swift-testing:
|
|
436
|
+
path: language/swift/testing.md
|
|
437
|
+
languages:
|
|
438
|
+
- swift
|
|
439
|
+
levels:
|
|
440
|
+
- standard
|
|
441
|
+
- expert
|
|
442
|
+
- full
|
|
443
|
+
tags:
|
|
444
|
+
- swift
|
|
445
|
+
- testing
|
|
446
|
+
- xctest
|
|
447
|
+
- swift-testing
|
|
448
|
+
category: Language
|
|
449
|
+
swift-error-handling:
|
|
450
|
+
path: language/swift/error-handling.md
|
|
451
|
+
languages:
|
|
452
|
+
- swift
|
|
453
|
+
levels:
|
|
454
|
+
- standard
|
|
455
|
+
- expert
|
|
456
|
+
- full
|
|
457
|
+
tags:
|
|
458
|
+
- swift
|
|
459
|
+
- errors
|
|
460
|
+
- throws
|
|
461
|
+
- result
|
|
462
|
+
category: Language
|
|
335
463
|
microservices-boundaries:
|
|
336
464
|
path: architecture/microservices/boundaries.md
|
|
337
465
|
architectures:
|