Metadata-Version: 2.4
Name: fastlayer
Version: 0.1.1
Summary: A FastAPI Clean Architecture project generator
Project-URL: Homepage, https://github.com/ulrich/fastlayer
Project-URL: Repository, https://github.com/ulrich/fastlayer
Project-URL: Documentation, https://github.com/ulrich/fastlayer#readme
Author-email: Ulrich <your.email@example.com>
License: MIT
License-File: LICENSE
Keywords: clean-architecture,fastapi,generator,project-generator,template
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: FastAPI
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Code Generators
Requires-Python: >=3.9
Requires-Dist: click>=8.1.0
Requires-Dist: copier>=9.0.0
Requires-Dist: pyyaml>=6.0
Provides-Extra: dev
Requires-Dist: black>=23.0.0; extra == 'dev'
Requires-Dist: mypy>=1.5.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
Requires-Dist: pytest>=7.4.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Description-Content-Type: text/markdown

# fastlayer


A FastAPI Clean Architecture (or Layered) project generator.

## Features

* **Clean Architecture**: Layered structure (Domain, Application, Infrastructure, Presentation)
* **Layered Architecture**: Presentation, Core, DB, Models, Repositories, Services, API layers for simpler projects
* **FastAPI**: Modern and high-performance web framework
* **Docker**: Optional Docker and Docker Compose configuration
* **Databases**: Support for SQLAlchemy, MongoDB, or no database
* **Authentication**: Templates for JWT, OAuth2, or no authentication
* **Testing**: Pytest configuration with fixtures and examples
* **CI/CD**: GitHub Actions or GitLab CI templates
* **Update**: Ability to update projects with new template versions

## Installation

### From PyPI

```bash
pip install fastlayer
```

### From source

```bash
git clone https://github.com/Ulrich75/fastlayer.git
cd fastlayer
pip install -e .
```

## Usage

### Create a new project

Interactive mode (recommended):

```bash
fastlayer create my-api
```

Non-interactive mode with options:

```bash
fastlayer create my-api \
  --database sqlalchemy \
  --auth jwt \
  --docker \
  --cicd github \
  --arch clean \
  --no-interactive
```

### Available options

* `--database, -d`: Database type (`sqlalchemy`, `mongodb`, `none`)
* `--auth, -a`: Authentication method (`jwt`, `oauth2`, `none`)
* `--docker/--no-docker`: Include Docker configuration
* `--cicd, -c`: CI/CD provider (`github`, `gitlab`, `none`)
* `--output-dir, -o`: Custom output directory
* `--interactive/--no-interactive, -i/-n`: Interactive mode
* `--arch, -r`: Architecture type (`clean`, `layered`)

### Update an existing project

```bash
cd my-api
fastlayer update
```

### Show version

```bash
fastlayer --version
```

### Show help

```bash
fastlayer --help
fastlayer create --help
```

## Generated project structures

### 1. Clean Architecture

```
my-api/
├── src/
│   └── my_api/
│       ├── domain/
│       │   ├── entities/
│       │   ├── repositories/
│       │   └── exceptions.py
│       ├── application/
│       │   ├── use_cases/
│       │   └── dto/
│       ├── infrastructure/
│       │   ├── repositories/
│       │   ├── database.py
│       │   └── config.py
│       ├── presentation/
│       │   └── api/
│       │       ├── routes/
│       │       ├── schemas/
│       │       └── dependencies.py
│       └── main.py
├── tests/
├── pyproject.toml
├── README.md
├── .env.example
├── Dockerfile
├── docker-compose.yml
└── .github/workflows/
```

### 2. Layered Architecture

```
my-api/
├── src/
│   └── my-api/
│       ├── api/
│       │   ├── deps.py
│       │   ├── __init__.py
│       │   └── v1/
│       ├── core/
│       │   ├── config.py
│       │   ├── exceptions.py
│       │   └── __init__.py
│       ├── db/
│       │   ├── __init__.py
│       │   ├── migrations/
│       │   └── session.py
│       ├── __init__.py
│       ├── main.py
│       ├── models/
│       │   └── __init__.py
│       ├── repositories/
│       │   └── __init__.py
│       ├── schemas/
│       │   └── __init__.py
│       └── services/
│           └── __init__.py
└── tests/
|   ├── conftest.py
|   └── test_api.py
├── README.md
├── pyproject.toml
├── Dockerfile
├── docker-compose.yml
```

## Clean Architecture Principles

### Domain Layer

* **Entities**: Pure business objects with no external dependencies
* **Repositories**: Abstract interfaces for persistence
* **Exceptions**: Custom business exceptions

### Application Layer

* **Use Cases**: Application logic and orchestration
* **DTOs**: Data transfer objects

### Infrastructure Layer

* **Repositories**: Concrete implementations of interfaces
* **Database**: Configuration and database connection
* **Config**: Configuration management

### Presentation Layer

* **Routes**: FastAPI endpoints
* **Schemas**: Pydantic validation
* **Dependencies**: FastAPI dependency injection

## Development

### Install in development mode

```bash
git clone https://github.com/Ulrich75/fastlayer.git
cd fastlayer
pip install -e ".[dev]"
```

### Run tests

```bash
pytest
```

### Linter and formatting

```bash
ruff check src/ tests/
black src/ tests/
mypy src/
```

## License

MIT License - see the [LICENSE](LICENSE) file for details.

## Contribution

Contributions are welcome! Feel free to open an issue or a pull request.

## Resources

* [FastAPI Documentation](https://fastapi.tiangolo.com/)
* [Clean Architecture by Uncle Bob](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html)
* [Copier Documentation](https://copier.readthedocs.io/)
