How aytzey/codetopromptgenerator works
Project Type and Purpose
• This is a full-stack application (“Code to Prompt Generator Tool”) whose frontend is built with Next.js/React/TypeScript and whose backend is a Python Flask API.
• Purpose: allow users to scan a local file tree, select/exclude files, compose meta-prompts, and bundle everything (including file contents) into a single payload for use with LLMs.
File Structure
• Top level
• Configuration: package.json, tsconfig.json, next.config.js, ports.ini, .env.local
• CI/CD: .github/workflows/ci.yml
• Scripts: start.js/.bat/.sh, postinstall.js, autotest.js
• Frontend
• pages/ → Next.js entrypoints (_app.tsx, index.tsx)
• components/ → reusable UI primitives (shadcn/ui wrappers, ErrorBoundary)
• views/ → higher-level screens and panels (FileTreeView, FolderPickerView, etc.)
• stores/ → Zustand stores for application state (useAppStore, useTodoStore, etc.)
• services/ → client-side API wrappers and React service hooks
• lib/ → shared utilities and custom React hooks (useDebounce, useHomePageLogic, etc.)
• styles/, tailwind.config.js → styling
• Backend (python_backend/)
• app.py → Flask app factory, routing setup
• controllers/ → REST endpoints (file scanning, todos, meta-prompts, projects, exclusions, etc.)
• services/ → business logic for each domain
• repositories/ → file‐system-based persistence
• models/ → request/response schemas and data models
• utils/ → helper modules (path_utils, response_utils)
• requirements.txt, virtual-env under python_backend/venv
• Testing & CI
• scripts/autotest.js → automated end-to-end smoke tests
• .github/workflows/ci.yml → runs tests on push/PR
README for Architectural Insights
• It confirms a REST API on Flask (CORS enabled) at port 5000, consumed by the Next.js frontend at port 3000.
• It outlines features that map directly to backend controllers and frontend views/service hooks.
• No external database—persistence is file-system or in-memory for to-dos; meta-prompts saved as text files.
a. Main Components
• Frontend Application (Next.js + React + Tailwind + shadcn/ui)
• Backend API Server (Flask + Flask-CORS)
• Local File System (scanned directories, meta-prompt files, exclusions config)
• State Management (Zustand stores)
• Client-side API Layer (services/apiService.ts + service hooks)
• CI Pipeline (GitHub Actions)
b. Relationships & Data Flows
1. User interacts with UI components (views, components)
2. Components dispatch actions to Zustand stores or call service hooks
3. Service hooks use apiService to send HTTP requests to Flask endpoints
4. Flask controllers delegate to services → repositories → file system
5. Responses return JSON payloads (directory tree, file contents, todos, etc.)
6. Frontend updates UI/store, renders new state
7. “Copy to Clipboard” aggregates store state and selected file contents purely on the client
8. CI pipeline triggers on push, runs autotest.js against running servers
c. Architectural Patterns & Principles
• MVC-style layering in backend (Controller → Service → Repository)
• Component-driven UI with atomic shadcn/ui primitives
• Hook-based data fetching (service hooks)
• Global state with lightweight stores (Zustand)
• Clear separation of concerns: UI vs API vs persistence
d. Key Technologies & Frameworks
• Next.js, React, TypeScript, Tailwind CSS, shadcn/ui
• Zustand for state
• Axios or fetch in apiService (services/apiService.ts)
• Flask + Flask-CORS in Python 3.7+
• GitHub Actions for CI
Detail Is Key
• Break out sub-components when they add clarity (e.g., split React Views vs Components vs Stores vs Service Hooks).
• Configuration files (ports.ini) as part of the startup flow.
• Script orchestration (start.js → spawns Next.js + Flask).
• Folder-scan flow separately from the todo/meta-prompt flow to demonstrate parallel features.