Skip to main content

ChaCC API - A modular FastAPI application for extensible APIs

Project description

ChaCC API

ChaCC API is a modular FastAPI application platform that allows you to build extensible APIs through pluggable modules.

What is ChaCC API

ChaCC API provides a flexible foundation for building modular applications. Instead of building a monolithic API, you can create separate modules that can be installed, enabled, disabled, and updated independently.

Key Features

  • Modular Architecture: Build your API as independent modules that can be added or removed without modifying the core
  • Automatic Database Migrations: Modules automatically create and update their database tables using the @register_model decorator
  • Dependency Management: ChaCC resolves module dependencies automatically before loading modules using Chacc Pip Acelerator Package
  • Hot Reload Support: Development mode supports automatic reloading when module files change
  • Module Packaging: Build modules as .chacc files for easy distribution and deployment

Use Cases

  • Building extensible SaaS platforms
  • Creating modular APIs with independently deployable components
  • Developing reusable API modules that can be shared across projects
  • Rapid prototyping with pluggable functionality

Installation

Prerequisites

  • Python 3.10 or higher
  • PostgreSQL (optional, SQLite works for development)
  • Fast API understanding

Install from PyPI

pip install chacc-api

Install from Source

git clone https://github.com/jonas1015/chacc-api
cd chacc-api
pip install -e .

Docker Installation

docker pull chacc-api:latest
docker run -d -p 8080:8080 chacc-api:latest

Or use Docker Compose:

docker-compose -f deployment/docker/docker-compose.yml up -d

Command Line Interface

The chacc command provides tools for module development and deployment.

Development Environment

# Create a new module
chacc create my_module

# Build a module into a .chacc package
chacc build plugins/my_module

# Deploy a module
chacc deploy mymodule.chacc

# Start development server with auto-reload
chacc run server --dev

# Start development server on custom port
chacc run server --host 127.0.0.1 --port 3000

Production Environment

# Start production server (runs tests first)
chacc run server

Deployment Commands

# Deploy a module to a remote server
chacc deploy my_module.chacc

Requires environment variables:

  • CHACC_DEPLOY_URL - URL of the remote ChaCC API server

Optional:

  • CHACC_DEPLOY_API_KEY - API key for authentication
  • CHACC_DEPLOY_TIMEOUT - Request timeout in seconds (default: 30)

Learning More

From Module Scaffolding

The easiest way to understand how modules work is to create one and explore the generated code:

chacc create my_module
ls -la plugins/my_module/

This creates a complete module with:

  • module_meta.json - Module configuration
  • module/main.py - Module entry point with setup_plugin function
  • module/models.py - Database models using @register_model
  • module/routes.py - API endpoints
  • module/tests/test_module.py - Unit tests

From Source Code

The source code is extensively documented. Key files to explore:

  • src/database.py - Database models, @register_model decorator, automatic migrations
  • src/core_services.py - BackboneContext class that provides services to modules
  • src/module_loader.py - Module loading and lifecycle management
  • chacc_cli/commands.py - CLI command implementations

Authentication Module Example

For a complete example of a working module, see the authentication module in chacc-authentication. It demonstrates:

  • Database model definition
  • API route creation
  • Service registration
  • Configuration handling
  • Authentication utilities

Environment Variables

Required Variables

Variable Description
SECRET_KEY Secret key for JWT token signing. Required in production. Must be 32+ characters.

Database Configuration

Variable Default Description
DATABASE_ENGINE sqlite Database type: sqlite or postgresql
DATABASE_NAME chaccapidb Database name
DATABASE_USER chacc Database username (PostgreSQL only)
DATABASE_PASSWORD (empty) Database password (PostgreSQL only)
DATABASE_HOST localhost Database host (PostgreSQL only)
DATABASE_PORT 5432 Database port (PostgreSQL only)

Module Configuration

Variable Default Description
MODULES_INSTALLED_DIR modules_installed Directory containing .chacc files
MODULES_LOADED_DIR .modules_loaded Directory for extracted modules
PLUGINS_DIR plugins Directory for development modules

Development Settings

Variable Default Description
ENABLE_PLUGIN_HOT_RELOAD True Auto-reload modules on file changes
PLUGIN_AUTO_DISCOVERY True Automatically discover plugins
ENABLE_PLUGIN_DEPENDENCY_RESOLUTION True Auto-resolve module dependencies

Migration Settings

Variable Default Description
MIGRATION_MODE auto Migration mode: auto, full, or preview
MIGRATION_BACKUP False Create backup before migration
MIGRATION_BACKUP_DIR backups Directory for backups
MIGRATION_AUTO_DROP False Allow destructive operations

Redis Configuration

Variable Default Description
REDIS_ENABLED False Enable Redis
REDIS_HOST localhost Redis host
REDIS_PORT 6379 Redis port
REDIS_DB 0 Redis database number
REDIS_PASSWORD (none) Redis password

Other Settings

Variable Default Description
LOG_LEVEL INFO Logging level
CHACC_DEPLOY_URL http://localhost:8080 Chacc CLI deploy URL

Quick Start

1. Install and Run

pip install chacc-api
chacc run server --dev

2. Access the API

3. Create a Module

chacc create my_module

This creates a new module in plugins/my_module/. Edit the files to add your functionality.

4. Build and Deploy

chacc build plugins/my_module
chacc deploy my_module.chacc

License

Licensed under the Apache License, Version 2.0. See LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chacc_api-1.0.0b3.tar.gz (53.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chacc_api-1.0.0b3-py3-none-any.whl (58.9 kB view details)

Uploaded Python 3

File details

Details for the file chacc_api-1.0.0b3.tar.gz.

File metadata

  • Download URL: chacc_api-1.0.0b3.tar.gz
  • Upload date:
  • Size: 53.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for chacc_api-1.0.0b3.tar.gz
Algorithm Hash digest
SHA256 77316d4b8345772ea2ce39fb77e219eaf0aff22eccfd5b389e0c559f0f70d91a
MD5 ddbfa4173dc2c923346ef845db34dee7
BLAKE2b-256 705e131d0ddb334b53d1ccd407c93d12e042a625594028e7c3de4f7f1ad525b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for chacc_api-1.0.0b3.tar.gz:

Publisher: release.yml on Jonas1015/chacc-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chacc_api-1.0.0b3-py3-none-any.whl.

File metadata

  • Download URL: chacc_api-1.0.0b3-py3-none-any.whl
  • Upload date:
  • Size: 58.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for chacc_api-1.0.0b3-py3-none-any.whl
Algorithm Hash digest
SHA256 24d5430894e779d6b34bbeb00769f6b577d862fe742da64eb8151e1eed54f581
MD5 a38cf7f340a19027a05de985632f0fff
BLAKE2b-256 e22bbf4c06d4f2b0e3d53be4f0f5e001d0ef3c1b14664d335b49dfe3d12d96ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for chacc_api-1.0.0b3-py3-none-any.whl:

Publisher: release.yml on Jonas1015/chacc-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page