@voilajsx/helix
Version:
A modern fullstack framework combining UIKit (React) and AppKit (Express) with Feature-Based Component Architecture (FBCA)
359 lines (269 loc) ⢠9.16 kB
Markdown
# š„ Helix Framework
A modern fullstack framework that combines **UIKit** (React frontend) and **AppKit** (Express backend) with Feature-Based Component Architecture (FBCA).
[](https://badge.fury.io/js/helix)
[](https://opensource.org/licenses/MIT)
## ⨠Features
- šÆ **Feature-Based Component Architecture (FBCA)** - Zero-config convention-based routing
- ā” **Fullstack Integration** - Seamless frontend-backend communication
- šØ **UIKit Components** - Production-ready React components with multiple themes
- š§ **AppKit Backend** - Express.js with structured logging and error handling
- š **Auto-Discovery Routing** - File-based routing similar to Next.js
- š **Hot Reload** - Fast development with Vite and nodemon
- š¦ **Zero Configuration** - Convention over configuration approach
- š **Multi-Theme Support** - Built-in theme system (base, elegant, metro, studio, vivid)
## š Quick Start
### Installation
```bash
npm install -g @voilajsx/helix
```
### Create New Project
```bash
# Create in new directory
helix create my-app
cd my-app
npm run dev
# Or install in current directory
mkdir my-project && cd my-project
helix create .
npm run dev
```
That's it! Your fullstack app is running with:
- Frontend: http://localhost:5173
- Backend: http://localhost:3000
- API: http://localhost:3000/api
## š Project Structure
```
my-app/
āāā src/
ā āāā api/ # Backend (AppKit)
ā ā āāā features/
ā ā ā āāā welcome/
ā ā ā āāā welcome.route.ts
ā ā ā āāā welcome.service.ts
ā ā āāā lib/
ā ā āāā server.ts
ā āāā web/ # Frontend (UIKit)
ā āāā features/
ā ā āāā main/
ā ā ā āāā pages/
ā ā ā āāā index.tsx # ā /
ā ā āāā gallery/
ā ā ā āāā pages/
ā ā ā āāā index.tsx # ā /gallery
ā ā āāā welcome/
ā ā āāā pages/
ā ā āāā index.tsx # ā /welcome
ā āāā shared/
ā āāā main.tsx
āāā dist/ # Production build
āāā package.json
āāā tsconfig.json
```
## šÆ Feature-Based Architecture
### Convention-Based Routing
Helix uses file-based routing where file paths automatically become routes:
```
src/web/features/main/pages/index.tsx ā /
src/web/features/gallery/pages/index.tsx ā /gallery
src/web/features/blog/pages/index.tsx ā /blog
src/web/features/blog/pages/[slug].tsx ā /blog/:slug
src/web/features/docs/pages/[...path].tsx ā /docs/*
```
### Creating a New Feature
1. Create feature directory:
```bash
mkdir -p src/web/features/products/pages
```
2. Add a page component:
```tsx
// src/web/features/products/pages/index.tsx
import React from 'react';
import { PageLayout } from '@voilajsx/uikit/page';
const ProductsPage: React.FC = () => {
return (
<PageLayout>
<PageLayout.Content>
<h1>Products</h1>
<p>Your products page content here</p>
</PageLayout.Content>
</PageLayout>
);
};
export default ProductsPage;
```
3. Route `/products` is automatically available!
## š§ Backend API Integration
### Built-in API Hooks
Helix includes generic API hooks that auto-detect your environment:
```tsx
import { useApi } from '@voilajsx/uikit/hooks';
const MyComponent = () => {
const { loading, error, get, post } = useApi();
const fetchData = async () => {
const result = await get('/api/welcome');
console.log(result);
};
return (
<button onClick={fetchData} disabled={loading}>
{loading ? 'Loading...' : 'Fetch Data'}
</button>
);
};
```
### Backend Status Checking
```tsx
import { useBackendStatus } from '@voilajsx/uikit/hooks';
const StatusCheck = () => {
const { isConnected, loading, checkStatus } = useBackendStatus();
return (
<div>
{isConnected ? 'ā
Backend Connected' : 'ā Backend Disconnected'}
</div>
);
};
```
## š Available Scripts
### Development Workflows
```bash
# Option 1: Separate development (recommended for most development)
npm run dev # API (3000) + Web (5173) - separate ports with colored logs
npm run dev:api # Backend only (Express on port 3000)
npm run dev:web # Frontend only (Vite on port 5173)
# Option 2: Unified development (for testing integration)
npm run dev:fullstack # Build frontend + serve through backend (single port)
```
### Production
```bash
npm run build # Build both frontend and backend
npm start # Start production server (checks build exists)
npm run preview # Build and preview
```
### Development Tips
- **npm run dev**: Best for regular development - API and Web run separately with clear labels
- **npm run dev:fullstack**: Use when testing full integration or APIs from frontend
- **npm start**: Now shows helpful error if you forgot to build first
### Linting
```bash
npm run lint # Lint everything
npm run lint:api # Lint backend only
npm run lint:web # Lint frontend only
```
## šØ Themes
Helix includes 5 built-in themes:
- **base** - Clean default configuration
- **elegant** - Fresh sky blue theme with clean design
- **metro** - Dark teal theme with bright yellow accents
- **studio** - Sophisticated neutral theme with golden accents
- **vivid** - Premium cursive theme with sophisticated typography
Change theme in your components:
```tsx
import { useTheme } from '@voilajsx/uikit/theme-provider';
const { theme, setTheme } = useTheme();
setTheme('elegant');
```
## š§ Configuration
### Environment Variables
Create `.env` file in your project root:
```env
# Backend Configuration
PORT=3000
NODE_ENV=development
VOILA_FRONTEND_KEY=your-secret-key
# API Configuration
VITE_API_URL=http://localhost:3000
```
### TypeScript Configuration
Helix includes optimized TypeScript configurations:
- `tsconfig.json` - Frontend configuration
- `tsconfig.api.json` - Backend configuration
## š Examples
### API Route (Backend)
```typescript
// src/api/features/products/products.route.ts
import express from 'express';
import { errorClass } from '@voilajsx/appkit/error';
import { loggerClass } from '@voilajsx/appkit/logger';
const router = express.Router();
const error = errorClass.get();
const logger = loggerClass.get('products');
router.get(
'/',
error.asyncRoute(async (req, res) => {
logger.info('Getting products');
const products = await getProducts();
res.json(products);
})
);
export default router;
```
### Page Component (Frontend)
```tsx
// src/web/features/products/pages/index.tsx
import React, { useEffect, useState } from 'react';
import { useApi } from '@voilajsx/uikit/hooks';
import { Button } from '@voilajsx/uikit/button';
import { Card } from '@voilajsx/uikit/card';
const ProductsPage = () => {
const [products, setProducts] = useState([]);
const { loading, get } = useApi();
useEffect(() => {
const loadProducts = async () => {
const data = await get('/api/products');
setProducts(data);
};
loadProducts();
}, []);
return (
<div className="space-y-4">
<h1>Products</h1>
{loading ? (
<p>Loading...</p>
) : (
products.map((product) => (
<Card key={product.id}>
<h2>{product.name}</h2>
<p>{product.description}</p>
</Card>
))
)}
</div>
);
};
export default ProductsPage;
```
## š Dependencies
### Core Dependencies
- `@voilajsx/uikit` - React component library with FBCA support
- `@voilajsx/appkit` - Express backend framework with structured logging
- `react` & `react-dom` - React framework
- `react-router-dom` - Client-side routing
- `express` - Backend framework
- `cors` - Cross-origin resource sharing
- `dotenv` - Environment variable loading
### Development Dependencies
- `vite` - Fast frontend build tool
- `typescript` - Type safety
- `nodemon` - Backend auto-reload
- `concurrently` - Run multiple commands
- `tsx` - TypeScript execution
- `eslint` - Code linting
## š¤ Contributing
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
## š License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## š Links
- [UIKit Documentation](https://github.com/voilajsx/uikit)
- [AppKit Documentation](https://github.com/voilajsx/appkit)
- [FBCA Guide](https://docs.voilajsx.com/fbca)
## š Support
If you like Helix Framework, please consider:
- ā Starring the repository
- š Reporting bugs and issues
- š” Contributing new features
- š Improving documentation
---
Made with ā¤ļø by the VoilaJSX team