An open API service indexing awesome lists of open source software.

https://github.com/logimos/catalyst

๐Ÿš€ Catalyst is an interactive, modular Phoenix project generator that sets up a complete development environment with everything you need for modern web development.
https://github.com/logimos/catalyst

elixir geenrator phoenix

Last synced: 8 months ago
JSON representation

๐Ÿš€ Catalyst is an interactive, modular Phoenix project generator that sets up a complete development environment with everything you need for modern web development.

Awesome Lists containing this project

README

          

# Catalyst - Modular Phoenix Project Generator

๐Ÿš€ **Catalyst** is an interactive, modular Phoenix project generator that sets up a complete development environment with everything you need for modern web development.

## Features

### Core Phoenix Setup
- โœ… Interactive project creation
- โœ… Database selection (Postgres, MySQL, SQLite)
- โœ… Tailwind CSS integration (built-in with Phoenix)
- โœ… Modern development environment

### Optional Modules
- ๐Ÿ”ง **Oban** - Background job processing with database schema and sample workers
- ๐Ÿ” **Authentication** - User registration and login with phx_gen_auth
- โšก **LiveView** - Real-time interactive examples and components
- ๐Ÿ›ก๏ธ **Bodyguard** - Authorization policies integrated with authentication
- ๐ŸŽฏ **Absinthe** - GraphQL API with schema and resolvers
- ๐Ÿ“ **Waffle** - File uploads with uploader and controller
- ๐ŸŒ **HTTPoison** - HTTP client for external API requests
- ๐Ÿ“ง **Swoosh** - Email functionality with mailer and templates
- ๐Ÿงช **ExMachina** - Test factories for reliable test data
- โœ… **Credo** - Code quality analysis and linting
- ๐Ÿ” **Dialyxir** - Static analysis and type checking
- โšก **Alpine.js** - Lightweight JavaScript framework for interactivity
- ๐Ÿณ **Docker** - Containerized development and deployment

## Installation

```bash
# Clone the repository
git clone https://github.com/your-username/catalyst.git
cd catalyst

# Install dependencies
mix deps.get

# Build the project
mix compile
```

## Usage

### Create a New Phoenix Project

```bash
# Run the interactive setup
mix catalyst.new
```

The setup will guide you through:

1. **Project Configuration**
- Project name (with validation)
- Database choice (Postgres/MySQL/SQLite)

2. **Module Selection**
- Choose which modules to include
- Each module adds specific functionality

3. **Automatic Setup**
- Creates Phoenix project with your choices
- Installs and configures selected modules
- Generates comprehensive documentation

### Example Workflow

```bash
$ mix catalyst.new
๐Ÿš€ Welcome to Catalyst - Modular Phoenix Setup!
Project name? my_awesome_app
Database [1] Postgres (default), [2] MySQL, [3] SQLite: 1
Include Oban (background jobs)? [Yn] y
Include Authentication (phx_gen_auth)? [Yn] y
Include LiveView with examples? [Yn] y
Include Bodyguard (authorization)? [Yn] y
Include Absinthe (GraphQL)? [Yn] y
Include Waffle (file uploads)? [Yn] y
Include HTTPoison (HTTP requests)? [Yn] y
Include Swoosh (email)? [Yn] y
Include ExMachina (test factories)? [Yn] y
Include Credo (code quality)? [Yn] y
Include Dialyxir (static analysis)? [Yn] y
Include Alpine.js? [Yn] y
Include Docker support? [Yn] n

โœ… Phoenix project created successfully!
โœ… Oban setup completed!
โœ… Auth setup completed!
โœ… LiveView setup completed!
โœ… Bodyguard setup completed!
โœ… Absinthe setup completed!
โœ… Waffle setup completed!
โœ… HTTPoison setup completed!
โœ… Swoosh setup completed!
โœ… ExMachina setup completed!
โœ… Credo setup completed!
โœ… Dialyxir setup completed!
โœ… Alpine setup completed!

๐ŸŽ‰ Catalyst setup is complete! Navigate to your project with:
cd my_awesome_app
mix setup
```

## Module Documentation

Each module includes comprehensive documentation in `docs/catalyst/`:

- ๐Ÿ“– **Oban** - Background job processing guide
- ๐Ÿ” **Authentication** - User auth setup and usage
- โšก **LiveView** - Real-time interactive components
- ๐Ÿ›ก๏ธ **Bodyguard** - Authorization policies and helpers
- ๐ŸŽฏ **Absinthe** - GraphQL API development
- ๐Ÿ“ **Waffle** - File upload handling
- ๐ŸŒ **HTTPoison** - HTTP client usage
- ๐Ÿ“ง **Swoosh** - Email functionality
- ๐Ÿงช **ExMachina** - Test factory patterns
- โœ… **Credo** - Code quality guidelines
- ๐Ÿ” **Dialyxir** - Static analysis setup
- โšก **Alpine.js** - Interactive components and directives
- ๐Ÿณ **Docker** - Containerization and deployment

## Module Details

### Oban (Background Jobs)
- Reliable background job processing with database schema
- Sample EmailWorker, ExampleWorker, and NotificationWorker templates
- Multiple queue configuration (default, emails, critical)
- Job scheduling and monitoring capabilities
- Automatic retry and error handling

### Authentication
- User registration and login with phx_gen_auth
- Password reset functionality
- Session management
- Route protection helpers

### LiveView
- Real-time interactive components
- Multiple example implementations
- Event handling and state management
- Smooth transitions and animations

### Bodyguard
- Authorization policies and helpers
- Integration with authentication
- Policy-based access control
- Plugs and helpers for controllers

### Absinthe (GraphQL)
- Complete GraphQL API setup
- Schema definitions and resolvers
- Query and mutation examples
- Router integration

### Waffle (File Uploads)
- File upload handling with uploader
- Controller and template integration
- Route configuration
- Upload validation and processing

### HTTPoison (HTTP Requests)
- HTTP client for external API calls
- GET, POST, PUT, DELETE, PATCH methods
- JSON encoding/decoding
- Error handling and response processing

### Swoosh (Email)
- Email functionality with mailer
- Welcome, password reset, and notification emails
- HTML and text email templates
- Background job integration

### ExMachina (Test Factories)
- Test factories for reliable test data
- User, post, comment, category, and tag factories
- Factory helpers and custom traits
- Build and insert functions

### Credo (Code Quality)
- Comprehensive code quality analysis
- Consistency, design, and readability checks
- Refactoring opportunities
- Warning detection

### Dialyxir (Static Analysis)
- Static type analysis and checking
- Dead code detection
- Race condition detection
- Specification checking

### Alpine.js
- Lightweight JavaScript framework
- Reactive components
- Event handling
- Smooth transitions

### Docker
- Multi-stage production builds
- Development environment with database
- Containerized deployment
- Environment configuration

## Development

### Project Structure

```
lib/
โ”œโ”€โ”€ catalyst/
โ”‚ โ”œโ”€โ”€ modules/
โ”‚ โ”‚ โ”œโ”€โ”€ oban/
โ”‚ โ”‚ โ”œโ”€โ”€ auth/
โ”‚ โ”‚ โ”œโ”€โ”€ liveview/
โ”‚ โ”‚ โ”œโ”€โ”€ bodyguard/
โ”‚ โ”‚ โ”œโ”€โ”€ absinthe/
โ”‚ โ”‚ โ”œโ”€โ”€ waffle/
โ”‚ โ”‚ โ”œโ”€โ”€ httpoison/
โ”‚ โ”‚ โ”œโ”€โ”€ swoosh/
โ”‚ โ”‚ โ”œโ”€โ”€ ex_machina/
โ”‚ โ”‚ โ”œโ”€โ”€ credo/
โ”‚ โ”‚ โ”œโ”€โ”€ dialyxir/
โ”‚ โ”‚ โ”œโ”€โ”€ alpine/
โ”‚ โ”‚ โ””โ”€โ”€ docker/
โ”‚ โ””โ”€โ”€ utils.ex
โ”œโ”€โ”€ mix/
โ”‚ โ””โ”€โ”€ tasks/
โ”‚ โ””โ”€โ”€ catalyst.new.ex
โ””โ”€โ”€ catalyst.ex
```

### Adding New Modules

1. Create a new module directory in `lib/catalyst/modules/`
2. Implement the `setup/1` function using the Utils module
3. Add comprehensive documentation
4. Update the module list in `catalyst.new.ex`

### Module Template

```elixir
defmodule Catalyst.Modules.YourModule do
@moduledoc """
Description of what this module does.
"""

import Catalyst.Modules.Utils, only: [
create_file_from_template: 3,
inject_dependency: 2,
create_documentation: 3
]

def setup(project_path) do
inject_dependency(project_path, {:your_dep, "~> 1.0"})
create_your_files(project_path)
create_documentation(project_path)
System.cmd("mix", ["deps.get"], cd: project_path)
:ok
rescue
e -> {:error, Exception.message(e)}
end
end
```

## Best Practices

### Module Development
- Use the Utils module for consistency
- Provide comprehensive documentation
- Include real-world examples
- Handle errors gracefully
- Test all functionality

### Code Quality
- Run Credo for code quality checks
- Use Dialyxir for static analysis
- Follow Elixir best practices
- Write comprehensive tests

### Testing
- Use ExMachina factories for test data
- Write integration tests
- Test error scenarios
- Maintain test coverage

## Contributing

1. Fork the repository
2. Create a feature branch
3. Add your module or improvement
4. Add tests and documentation
5. Submit a pull request

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Acknowledgments

- Phoenix Framework team for the excellent web framework
- Oban team for reliable background job processing
- Alpine.js team for lightweight JavaScript framework
- All the Elixir community for amazing tools and libraries

---

**Catalyst** - Building better Phoenix applications, one module at a time. ๐Ÿš€