diff --git a/docs/api_reference/index.md b/docs/api_reference/index.md index 0ac6fb3d..5d568e3c 100644 --- a/docs/api_reference/index.md +++ b/docs/api_reference/index.md @@ -1,111 +1,66 @@ --- title: API Reference -description: Complete API reference for all ArchiPy modules and packages. +description: Public ArchiPy APIs by package, including adapters, configuration, helpers, and models. --- # API Reference -Welcome to the ArchiPy API reference documentation. This section provides detailed information about all modules, -classes, and functions in ArchiPy. +Find public classes, functions, and types by package. For a working example, use the [Tutorials](../tutorials/index.md). ## Core Modules +
+
+ ### Adapters -The adapters module provides standardized interfaces to external systems: - -- [Adapters Overview](adapters/index.md) -- [Base SQLAlchemy](adapters/base.md) -- [Redis](adapters/redis.md) -- [PostgreSQL](adapters/postgres.md) -- [SQLite](adapters/sqlite.md) -- [StarRocks](adapters/starrocks.md) -- [Kafka](adapters/kafka.md) -- [Keycloak](adapters/keycloak.md) -- [MinIO](adapters/minio.md) -- [ScyllaDB](adapters/scylladb.md) -- [Elasticsearch](adapters/elasticsearch.md) -- [Temporal](adapters/temporal.md) -- [Email](adapters/email.md) -- [Payment Gateways](adapters/payment_gateways.md) +Ports and implementations for external services. + +- [Adapter overview](adapters/index.md) and [Base SQLAlchemy](adapters/base.md) +- [PostgreSQL](adapters/postgres.md), [MySQL](adapters/mysql.md), [SQLite](adapters/sqlite.md), [StarRocks](adapters/starrocks.md), [ScyllaDB](adapters/scylladb.md) +- [Redis](adapters/redis.md), [Elasticsearch](adapters/elasticsearch.md), [MinIO](adapters/minio.md) +- [Kafka](adapters/kafka.md), [Temporal](adapters/temporal.md), [Email](adapters/email.md) +- [Keycloak](adapters/keycloak.md), [Vault](adapters/vault.md), [Payment Gateways](adapters/payment_gateways.md) + +
+
### Configs -Configuration management and injection tools: +[Configuration classes](configs.md) for application settings and adapter connections. -- [Configs Documentation](configs.md) +
+
### Helpers -Utility functions and support classes: +[Helper overview](helpers/index.md) and APIs for common application concerns. + +- [Decorators](helpers/decorators.md), [Interceptors](helpers/interceptors.md), [Metaclasses](helpers/metaclasses.md) +- [Errors](helpers/errors.md) and [Utilities](helpers/utils.md) -- [Helpers Overview](helpers/index.md) -- [Decorators](helpers/decorators.md) -- [Interceptors](helpers/interceptors.md) -- [Metaclasses](helpers/metaclasses.md) -- [Utils](helpers/utils.md) +
+
### Models -Core data structures and types: +[Model overview](models/index.md) and types shared across application layers. -- [Models Overview](models/index.md) -- [DTOs](models/dtos.md) -- [Entities](models/entities.md) -- [Errors](models/errors.md) -- [Types](models/types.md) +- [DTOs](models/dtos.md), [Entities](models/entities.md), [Errors](models/errors.md), [Types](models/types.md) + +
+
## Source Code Organization -The ArchiPy source code is organized into the following structure: - -```text -archipy/ -├── adapters/ # External system integrations -│ ├── base/ # Base SQLAlchemy components -│ ├── elasticsearch/ # Elasticsearch adapter -│ ├── email/ # Email service adapter -│ ├── internet_payment_gateways/ # Payment gateway adapters -│ ├── kafka/ # Kafka message streaming adapter -│ ├── keycloak/ # Keycloak authentication adapter -│ ├── minio/ # MinIO object storage adapter -│ ├── postgres/ # PostgreSQL adapter -│ ├── redis/ # Redis adapter -│ ├── scylladb/ # ScyllaDB/Cassandra adapter -│ ├── sqlite/ # SQLite adapter -│ ├── starrocks/ # StarRocks adapter -│ └── temporal/ # Temporal workflow adapter -├── configs/ # Configuration management -│ ├── base_config.py -│ ├── config_template.py # Re-exports the config classes -│ ├── environment_type.py -│ └── sections/ # One module per config section -├── helpers/ # Utility functions and patterns -│ ├── decorators/ -│ ├── interceptors/ -│ ├── metaclasses/ -│ └── utils/ -└── models/ # Core data structures - ├── dtos/ - ├── entities/ - ├── errors/ - └── types/ -``` +Core APIs live in `archipy/`. Optional adapters live in workspace packages under `packages/` and use the +`archipy.adapters` namespace. See [Project Structure](../getting-started/project_structure.md) for the application layout. ## API Stability -ArchiPy follows semantic versioning and marks API stability as follows: - -- 🟢 **Stable**: Production-ready APIs, covered by semantic versioning -- 🟡 **Beta**: APIs that are stabilizing but may have breaking changes -- 🔴 **Alpha**: Experimental APIs that may change significantly - -See the [Changelog](../community/changelog/index.md) for version history and breaking changes. +ArchiPy follows semantic versioning. Stable APIs are covered by that policy. Beta APIs can change significantly and alpha +APIs are experimental. See the [Changelog](../community/changelog/index.md) for changes between versions. ## Contributing -For information about contributing to ArchiPy's development, please see: - -- [Contributing Guide](../community/contributing.md) -- [Development Guide](../community/contributing.md) -- [Documentation Guide](../community/contributing.md) +See the [Contributing Guide](../community/contributing.md) for development setup and documentation changes. diff --git a/docs/assets/stylesheets/404.css b/docs/assets/stylesheets/404.css index 4f511495..ee546368 100644 --- a/docs/assets/stylesheets/404.css +++ b/docs/assets/stylesheets/404.css @@ -8,22 +8,10 @@ } .docs-404 { - --md-typeset-a-color: color-mix(in srgb, var(--md-primary-fg-color) 65%, var(--md-default-fg-color)); max-width: 43rem; margin: clamp(1rem, 5vw, 3.5rem) auto; } -.docs-404__hero { - padding: clamp(1.2rem, 4vw, 2.5rem); - background: linear-gradient( - 145deg, - color-mix(in srgb, var(--md-primary-fg-color) 10%, var(--md-default-bg-color)), - var(--md-default-bg-color) - ); - border: 1px solid var(--md-default-fg-color--lightest); - border-radius: 0.8rem; -} - .md-typeset .docs-404__status { margin: 0 0 0.55rem; color: var(--md-default-fg-color--light); @@ -44,18 +32,6 @@ .docs-404__hero .md-button { margin-top: 0.35rem; - border-radius: 0.3rem; -} - -.md-typeset .docs-404 .md-button--primary { - color: var(--md-primary-bg-color); - background-color: var(--md-primary-fg-color--dark); - border-color: var(--md-primary-fg-color--dark); -} - -.docs-404 a:focus-visible { - outline: 2px solid var(--md-typeset-a-color); - outline-offset: 3px; } .md-typeset .docs-404 h2 { @@ -82,8 +58,8 @@ display: block; width: 100%; padding: 0.7rem 0.8rem; - border: 1px solid var(--md-default-fg-color--lightest); - border-radius: 0.4rem; + border: 1px solid var(--docs-border); + border-radius: 0.6rem; } .docs-404__links a:hover, diff --git a/docs/assets/stylesheets/docs.css b/docs/assets/stylesheets/docs.css new file mode 100644 index 00000000..ada8fcae --- /dev/null +++ b/docs/assets/stylesheets/docs.css @@ -0,0 +1,152 @@ +body[data-md-color-scheme] { + --md-text-font: system-ui; + --md-typeset-a-color: #1958a8; + --md-accent-fg-color: #164580; + --docs-surface: #f1f6fc; + --docs-border: #d6e0ed; + --docs-action: #1958a8; + --docs-action-hover: #164580; +} + +body[data-md-color-scheme="slate"] { + --md-typeset-a-color: #96c8ff; + --md-accent-fg-color: #c4e1ff; + --docs-surface: #252e3e; + --docs-border: #414c5e; + --docs-action: #1d5cae; +} + +.md-header__button.md-logo img { + border-radius: 0.2rem; +} + +.md-typeset h1 { + font-weight: 700; + letter-spacing: -0.035em; +} + +.md-typeset h2 { + font-weight: 650; + letter-spacing: -0.02em; +} + +.md-typeset a:focus-visible, +.md-header :is(a, button):focus-visible { + outline: 2px solid var(--md-typeset-a-color); + outline-offset: 3px; +} + +.md-typeset .md-button--primary { + color: #fff; + background-color: var(--docs-action); + border-color: var(--docs-action); + border-radius: 0.4rem; +} + +.md-typeset .md-button--primary:hover, +.md-typeset .md-button--primary:focus-visible { + color: #fff; + background-color: var(--docs-action-hover); + border-color: var(--docs-action-hover); +} + +.docs-home { + max-width: 57rem; + margin: 0 auto; +} + +.md-content__inner:has(> .docs-home) > .md-content__button { + display: none; +} + +.docs-home-hero, +.docs-404__hero { + padding: clamp(1.1rem, 4vw, 2.5rem); + background: linear-gradient(145deg, var(--docs-surface), var(--md-default-bg-color)); + border: 1px solid var(--docs-border); + border-radius: 0.85rem; +} + +.docs-home-hero { + display: grid; + gap: clamp(1rem, 4vw, 2.5rem); + align-items: center; +} + +@media (min-width: 44em) { + .docs-home-hero { + grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); + } +} + +.md-typeset .docs-home-hero h1 { + margin: 0; + font-size: clamp(1.65rem, 4vw, 3rem); + line-height: 1.08; +} + +.docs-home-hero h1 > .headerlink { + display: none; +} + +.docs-home-hero p:last-child { + margin-bottom: 0; +} + +.docs-home-install { + min-width: 0; + padding: clamp(0.75rem, 3vw, 1.25rem); + background: var(--md-default-bg-color); + border: 1px solid var(--docs-border); + border-radius: 0.6rem; +} + +.md-typeset .docs-home-install h2 { + margin: 0; + font-size: 1rem; +} + +.docs-home-install p { + margin: 0.45em 0; + font-size: 0.75rem; +} + +.docs-home-install .highlight { + margin: 0.6em 0 0; +} + +.docs-home-install .md-code__button[data-md-type="copy"] { + color: var(--md-typeset-a-color); +} + +.md-typeset .docs-entry-grid { + grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); + gap: 0.75rem; +} + +.md-typeset .docs-api-grid { + grid-template-columns: minmax(0, 1fr); +} + +@media (min-width: 48em) { + .md-typeset .docs-api-grid { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } + + .docs-api-grid > :first-child { + grid-column: 1 / -1; + } +} + +@media (min-width: 70em) { + .md-typeset .docs-api-grid { + grid-template-columns: repeat(3, minmax(0, 1fr)); + } +} + +.md-typeset .docs-entry-grid > .card, +.md-typeset .docs-entry-grid > ul > li { + padding: 0.9rem 1rem; + border: 1px solid var(--docs-border); + border-radius: 0.6rem; +} diff --git a/docs/index.md b/docs/index.md index ee83eb76..c8f80233 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,69 +1,57 @@ --- title: Get Started -description: Introduction to ArchiPy and installation guide for the framework and its optional dependencies. +description: Install ArchiPy, build your first Python service, and find examples and API reference. +hide: + - navigation + - toc --- -# Get Started +
-![ArchiPy Logo](assets/logo.jpg) +
+
-[![PyPI version](https://img.shields.io/pypi/v/archipy)](https://pypi.org/project/archipy/) -[![Python versions](https://img.shields.io/pypi/pyversions/archipy)](https://pypi.org/project/archipy/) -[![License](https://img.shields.io/pypi/l/archipy)](community/license.md) -[![Downloads](https://img.shields.io/pypi/dm/archipy)](https://pypi.org/project/archipy/) -[![CI](https://github.com/SyntaxArc/ArchiPy/actions/workflows/tests.yml/badge.svg)](https://github.com/SyntaxArc/ArchiPy/actions) -[![GitHub Stars](https://img.shields.io/github/stars/SyntaxArc/ArchiPy?style=social)](https://github.com/SyntaxArc/ArchiPy) +# Build with ArchiPy { #get-started } -ArchiPy is a Python framework that provides standardized, scalable building blocks for modern applications. -Built on Clean Architecture principles with Python 3.14+, it removes the boilerplate from wiring up databases, -caches, queues, and services — so you focus on business logic. +Typed adapters for databases, caches, and queues in Python services. -## In 30 Seconds +[Start the quickstart](getting-started/quickstart.md){ .md-button .md-button--primary } -Install and run a typed, cached service: +
+
-=== "uv" +## Install ArchiPy { #in-30-seconds } - ```bash - uv add "archipy[redis,cache]" - ``` +Python 3.14 or later -=== "pip" +```bash +uv add archipy +``` - ```bash - pip install "archipy[redis,cache]" - ``` +
+
-```python -from archipy.configs.base_config import BaseConfig -from archipy.adapters.redis.adapters import RedisAdapter -from archipy.helpers.decorators import ttl_cache +
-config = BaseConfig() -BaseConfig.set_global(config) -redis = RedisAdapter() +- **[Installation](getting-started/installation.md)** -@ttl_cache(ttl=60) -def get_user(user_id: str) -> dict: - return redis.get(f"user:{user_id}") -``` + Choose extras and set up your environment. + +- **[Tutorials](tutorials/index.md)** + + Connect an adapter or add an application feature. -That's it — typed config, live Redis adapter, and a TTL cache, all wired together. +- **[API Reference](api_reference/index.md)** + + Look up public classes, configuration, and helpers. + +
## Why Use ArchiPy? -- **Clean Architecture out of the box** — four strictly separated layers (models, configs, helpers, adapters) enforce - dependency rules automatically -- **Type-safe everything** — configurations, entities, DTOs, and errors all use Pydantic or SQLAlchemy with full type - hint support -- **Modular adapters** — install only what you need; each integration (PostgreSQL, Redis, Kafka, Keycloak…) is an - optional extra -- **Testability first** — every adapter ships with a `ports.py` interface; tests run against real services via - `testcontainers`, and Redis also ships a `mocks.py` test double for logic-only unit tests -- **One config system** — environment variables, `.env` files, and runtime overrides all flow through a single validated - `BaseConfig` -- **Python 3.14+ native** — uses `X | Y` unions, `list[str]` generics, and modern syntax throughout; no legacy - compatibility shims +- Install each integration as an optional extra. +- Validate environment variables, `.env` values, and runtime overrides with `BaseConfig`. +- Use adapter interfaces to keep your business logic independent of clients and test against real services with testcontainers. See [Concepts](getting-started/concepts.md) for a detailed comparison of ArchiPy against plain FastAPI and Django. @@ -99,10 +87,10 @@ See [Concepts](getting-started/concepts.md) for the full architectural breakdown ## Next Steps -- [Installation](getting-started/installation.md) — prerequisites, install methods, and optional extras - [Concepts](getting-started/concepts.md) — understand the Clean Architecture layers and design philosophy -- [Quickstart](getting-started/quickstart.md) — five-minute step-by-step guide -- [Tutorials](tutorials/index.md) — step-by-step guides for every adapter, helper, and feature -- [API Reference](api_reference/index.md) — full reference for all public classes and functions +- [Project Structure](getting-started/project_structure.md) — organize your application layers +- [Complete Example](getting-started/complete_user_example.md) — follow a feature through the stack - [FAQ](community/faq.md) — answers to common questions - [Contributing](community/contributing.md) — set up a dev environment and contribute to ArchiPy + +
diff --git a/docs/tutorials/index.md b/docs/tutorials/index.md index 005a44bb..138f2c59 100644 --- a/docs/tutorials/index.md +++ b/docs/tutorials/index.md @@ -1,100 +1,77 @@ --- title: Tutorials -description: Overview of all ArchiPy tutorials and usage guides. +description: Connect integrations, build application features, and operate ArchiPy services. --- # Tutorials -This section contains practical examples of using ArchiPy components with **Python 3.14 type hints**, **proper exception -handling patterns**, and **comprehensive error chaining**. +Find a guide for the service you want to connect or the feature you want to build. If you are setting up your first +ArchiPy project, start with the [Quickstart](../getting-started/quickstart.md). -All examples follow ArchiPy's coding standards: +## Integrations { #adapters } -- ✅ **Python 3.14 Type Hints**: Using `|` for unions, lowercase built-in types (`str`, `int`, `list`, `dict`) -- ✅ **Exception Chaining**: All exceptions use `raise ... from e` to preserve error context -- ✅ **Try-Except-Else Pattern**: Explicit `else` blocks with return statements for clear control flow -- ✅ **Proper Logging**: Using `logger` instead of `print()` statements throughout -- ✅ **Domain-Specific Errors**: ArchiPy custom exceptions instead of generic `ValueError` or `Exception` +### Databases and search -## Adapters +- [PostgreSQL](adapters/postgres.md), [MySQL](adapters/mysql.md), and [SQLite](adapters/sqlite.md) for relational data +- [SQLAlchemy Search Totals](adapters/sqlalchemy.md) for paginated results with total counts +- [StarRocks](adapters/starrocks.md) for analytics and [ScyllaDB](adapters/scylladb.md) for wide-column storage +- [Elasticsearch](adapters/elasticsearch.md) for indexing and [Elasticsearch patterns](adapters/elasticsearch_patterns.md) + for application-level search -Learn how to use ArchiPy's database, cache, messaging, and storage adapters with complete error handling: +### Caches, files, and secrets -- [PostgreSQL](adapters/postgres.md) - Database operations with SQLAlchemy and atomic transactions -- [MySQL](adapters/mysql.md) - Database operations with SQLAlchemy and atomic transactions -- [SQLite](adapters/sqlite.md) - Lightweight database adapter for local storage -- [SQLAlchemy Search Totals](adapters/sqlalchemy.md) - Search pagination with total counts for SQLAlchemy adapters -- [StarRocks](adapters/starrocks.md) - Analytics database adapter -- [ScyllaDB](adapters/scylladb.md) - NoSQL database adapter for ScyllaDB and Apache Cassandra -- [Redis](adapters/redis.md) - Cache operations, pub/sub, and testing with testcontainers -- [Elasticsearch](adapters/elasticsearch.md) - Search and indexing with the Elasticsearch adapter -- [Vault](adapters/vault.md) - Secrets management with HashiCorp Vault -- [Email](adapters/email.md) - Email sending with proper error handling -- [Keycloak](adapters/keycloak.md) - Authentication and authorization with proper exception chaining -- [MinIO](adapters/minio.md) - Object storage operations with presigned URLs -- [Kafka](adapters/kafka.md) - Message streaming with producer/consumer patterns -- [Temporal](adapters/temporal.md) - Workflow orchestration -- [Payment Gateways](adapters/payment_gateways.md) - Iranian payment gateway integration ( - [Parsian](https://github.com/SyntaxArc/ArchiPy/tree/master/packages/parsian-ipg), - [Saman](https://github.com/SyntaxArc/ArchiPy/tree/master/packages/saman-ipg)) +- [Redis](adapters/redis.md) for caching and pub/sub +- [MinIO](adapters/minio.md) for object storage and presigned URLs +- [Vault](adapters/vault.md) for application secrets -## Helpers +### Messaging, workflows, and external services -Utility functions and decorators following best practices: +- [Kafka](adapters/kafka.md) for event streams and [Temporal](adapters/temporal.md) for workflows +- [Keycloak](adapters/keycloak.md) for authentication and authorization +- [Email](adapters/email.md) for outbound messages +- [Payment Gateways](adapters/payment_gateways.md) for Parsian and Saman payments -- [Decorators](helpers/decorators.md) - Retry, timeout, caching, and transaction decorators with Python 3.14 types -- [Interceptors](helpers/interceptors.md) - gRPC and FastAPI interceptors for cross-cutting concerns -- [Metaclasses](helpers/metaclasses.md) - Singleton and registry metaclass patterns -- [Utils](helpers/utils.md) - Datetime, JWT, password, file, and validation utilities with proper error handling +## Application patterns -## Configuration +### Configuration -Type-safe configuration management: +[Configuration Management](config_management.md) covers environment variables and validated settings. -- [Configuration Management](config_management.md) - Environment-based configuration with Pydantic and security best - practices +### Dependency Injection -## Testing +[Dependency Injection](dependency_injection.md) shows how to wire adapters into application logic. -Behavior-Driven Development with Behave: +### Helpers -- [BDD Testing](testing_strategy.md) — Gherkin features, mock adapters, testcontainers, and the Ports & Adapters testing - pattern +- [Decorators](helpers/decorators.md) for retry, timeout, cache, and transaction behavior +- [Interceptors](helpers/interceptors.md) for cross-cutting behavior in gRPC and FastAPI +- [Metaclasses](helpers/metaclasses.md) for singleton and registry patterns +- [Utilities](helpers/utils.md) for dates, JWTs, passwords, and files -## Models +### Models -Data Transfer Objects and type-safe models: +[Protobuf DTOs](models/protobuf_dtos.md) shows how to convert between Pydantic and Protocol Buffers. -- [Protobuf DTOs](models/protobuf_dtos.md) - Converting between Pydantic DTOs and Protocol Buffers with Python 3.14 - syntax +### Error Handling -## Error Handling +[Error Handling](error_handling.md) covers domain exceptions and preserving underlying error context. -Comprehensive error handling patterns: +### Testing -- [Error Handling](error_handling.md) - Domain-specific exceptions, error recovery, and proper exception - chaining - -## Dependency Injection - -- [Dependency Injection](dependency_injection.md) - Wiring adapters and logics with dependency injection - -## Observability - -- [Observability](observability.md) - OpenTelemetry traces, metrics, and logs -- [Pydantic AI](pydantic_ai.md) - Pydantic AI agent telemetry through `BaseConfig.PYDANTIC_AI` +[BDD Testing](testing_strategy.md) pairs Behave scenarios with real services through testcontainers. ## Operations -- [Caching](cache.md) - In-process TTL caching with `ttl_cache` and the `cache` extra -- [Scheduler](scheduler.md) - Running APScheduler jobs with the `scheduler` extra -- [Health Checks and Shutdown](health_checks.md) - Readiness checks and graceful shutdown building blocks +- [Caching](cache.md) for in-process TTL caches +- [Scheduler](scheduler.md) for APScheduler jobs +- [Health Checks and Shutdown](health_checks.md) for readiness checks and graceful shutdown ---- +### Observability -> **Note**: Each adapter tutorial links to its BDD scenarios and API reference. +- [Observability](observability.md) for OpenTelemetry traces, metrics, and logs +- [Pydantic AI](pydantic_ai.md) for agent telemetry ## See Also -- [API Reference](../api_reference/index.md) - Full API documentation -- [Concepts](../getting-started/concepts.md) - ArchiPy architectural patterns +- [API Reference](../api_reference/index.md) for adapter and helper signatures +- [Concepts](../getting-started/concepts.md) for ArchiPy’s application layers and import rules diff --git a/zensical.toml b/zensical.toml index 505bdb69..cc609e79 100644 --- a/zensical.toml +++ b/zensical.toml @@ -7,10 +7,11 @@ repo_url = "https://github.com/SyntaxArc/ArchiPy" repo_name = "SyntaxArc/ArchiPy" edit_uri = "edit/master/docs/" copyright = "Copyright © 2025-2026 Hossein Nejati, Mehdi Einali" +extra_css = ["assets/stylesheets/docs.css"] nav = [ + { "Home" = "index.md" }, { "Get Started" = [ - { "Overview" = "index.md" }, { "Installation" = "getting-started/installation.md" }, { "Quickstart" = "getting-started/quickstart.md" }, { "Concepts" = "getting-started/concepts.md" }, @@ -116,11 +117,12 @@ nav = [ ] [project.theme] -variant = "classic" +variant = "modern" language = "en" custom_dir = "overrides" logo = "assets/logo.jpg" favicon = "assets/logo.jpg" +font = false features = [ "navigation.instant", "navigation.instant.prefetch", @@ -129,8 +131,8 @@ features = [ "navigation.tabs", "navigation.tabs.sticky", "navigation.sections", - "navigation.expand", "navigation.indexes", + "navigation.path", "toc.follow", "content.code.copy", "content.tabs.link",