How pinak3748/nox-cli works
Project Type and Purpose
• Nox is a command-line application (written in Go) whose sole responsibility is to generate a boilerplate web project with React, TypeScript, Tailwind CSS, Redux Toolkit, and shadcn/ui.
• It also supports future extension points like dynamic component creation and OpenAI-powered features.
Main Architectural Components
a. CLI Frontend
• main.go + cmd/ folder: parses user flags (--page, --version, etc.) and routes commands to the core logic.
b. Core Engine (“Content” Layer)
• content/ package: holds the logic for generating pages, prompts, slices (Redux), types—basically the scaffolding recipes.
c. Helper/Support Packages
• packages/: handles auxiliary tasks—reading/writing config (OpenAI key), dynamic component logic, page management.
d. Template Assets & Binary Delivery
• binary/: prebuilt executables for distribution.
• buildBinary.sh: build scripts for generating those binaries.
e. External Services
• (Optional) OpenAI API: used when generating AI-driven components or playground.
Interactions and Data Flow
1. User invokes nox CLI with flags.
2. CLI Frontend parses input, then calls the appropriate function in the Core Engine (e.g., content/main.go).
3. Engine consults Helper Packages to fetch or store configuration (e.g., OpenAI key via packages/getOpenAIKey.go).
4. Engine uses templates and generation logic (content/*.go) to create new files and folders in the user’s project directory.
5. If an AI feature is requested, the engine makes HTTP calls to the OpenAI API, retrieves generated code snippets, then incorporates them into the scaffold.
6. The new boilerplate is written to disk; CLI reports success or errors to the user.
Architectural Patterns & Principles
• Modular Separation:
• cmd/ isolates CLI concerns (flag parsing and help text).
• content/ isolates domain logic (scaffold definitions).
• packages/ isolates cross-cutting concerns (config, dynamic components).
• Single Responsibility: Each package focuses on one aspect of generation.
• Extensibility Points: Clear package boundaries make it easy to add new commands (e.g., --dynamic-component) or services.
Detailed Steps to Sketch It Out
• Helper Modules (packages/)
• Build & Distribution (buildBinary.sh → binary/)