Skip to main content

Advanced Toolkit for Application Management System - Universal toolkit for AURA projects

Project description

ATAMS - Advanced Toolkit for Application Management System

Version Python License

Universal toolkit untuk semua AURA (Atams Universal Runtime Architecture) projects.

Features

  • ๐Ÿš€ Instant CRUD Generation - Generate full boilerplate in seconds
  • ๐Ÿ—๏ธ Clean Architecture - Enforced separation of concerns
  • ๐Ÿ”’ Security by Default - Atlas SSO, encryption, RBAC
  • ๐Ÿ“ฆ Reusable Components - Database, middleware, logging, etc.
  • ๐ŸŽจ CLI Tool - Project initialization & code generation
  • ๐ŸŒ CORS Protection - Default to *.atamsindonesia.com

Installation

pip install atams

Quick Start

1. Initialize New Project

atams init my-app
cd my-app
cp .env.example .env
# Edit .env with your configuration
pip install -r requirements.txt
uvicorn app.main:app --reload

2. Generate CRUD

atams generate department

Generates:

  • โœ… Model (SQLAlchemy)
  • โœ… Schema (Pydantic)
  • โœ… Repository (data access)
  • โœ… Service (business logic)
  • โœ… Endpoint (API routes)
  • โœ… Auto-registered to api.py

3. Customize & Run

Edit generated files to add custom logic, then test:

# Access API docs
http://localhost:8000/docs

# Test endpoints
GET  /api/v1/departments
GET  /api/v1/departments/{id}
POST /api/v1/departments
PUT  /api/v1/departments/{id}
DELETE /api/v1/departments/{id}

Components

Core Components

  1. Database Layer - BaseRepository with ORM & Native SQL
  2. Atlas SSO - Authentication & authorization
  3. Response Encryption - AES-256 for GET endpoints
  4. Exception Handling - Standardized error responses
  5. Middleware - Request ID tracking, rate limiting
  6. Logging - Structured logging with JSON format
  7. Transaction Management - Context managers for complex operations
  8. Common Schemas - Response & pagination schemas

Configuration

ATAMS provides AtamsBaseSettings with sensible defaults:

from atams import AtamsBaseSettings

class Settings(AtamsBaseSettings):
    APP_NAME: str = "MyApp"
    APP_VERSION: str = "1.0.0"
    DEBUG: bool = True
    
    # App-specific encryption
    ENCRYPTION_KEY: str = "your-key-32-chars"
    ENCRYPTION_IV: str = "your-iv-16-char"

settings = Settings()

CORS Default: Hanya *.atamsindonesia.com + localhost (development)

Override via .env:

CORS_ORIGINS=["https://myapp.atamsindonesia.com"]

CLI Commands

atams init <project_name>

Initialize new AURA project with complete structure.

Options:

  • --app-name, -a - Application name (default: project_name)
  • --version, -v - Application version (default: 1.0.0)
  • --schema, -s - Database schema (default: aura)

Example:

atams init my-new-app

atams generate <resource>

Generate full CRUD boilerplate for a resource.

Options:

  • --schema, -s - Database schema (default: aura)
  • --skip-api - Skip auto-registration to api.py

Example:

atams generate department
atams generate user --schema=public

atams --version

Show toolkit version.

Project Structure

my-app/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ core/              # Configuration
โ”‚   โ”‚   โ””โ”€โ”€ config.py
โ”‚   โ”œโ”€โ”€ db/                # Database
โ”‚   โ”œโ”€โ”€ models/            # SQLAlchemy models
โ”‚   โ”œโ”€โ”€ schemas/           # Pydantic schemas
โ”‚   โ”œโ”€โ”€ repositories/      # Data access layer
โ”‚   โ”œโ”€โ”€ services/          # Business logic layer
โ”‚   โ””โ”€โ”€ api/               # API endpoints
โ”‚       โ””โ”€โ”€ v1/
โ”‚           โ”œโ”€โ”€ api.py
โ”‚           โ””โ”€โ”€ endpoints/
โ”œโ”€โ”€ tests/                 # Test files
โ”œโ”€โ”€ .env.example           # Environment template
โ”œโ”€โ”€ requirements.txt       # Dependencies
โ””โ”€โ”€ README.md

Usage Examples

Using BaseRepository

BaseRepository menyediakan 20+ methods untuk operasi database yang lengkap:

Basic CRUD Operations

Method Description
get(db, id) Get single record by ID
get_multi(db, skip, limit) Get multiple records with pagination
create(db, obj_in) Create new record
update(db, db_obj, obj_in) Update existing record
delete(db, id) Delete record by ID

Advanced Query Methods

Method Description
exists(db, id) Fast existence check (returns bool)
filter(db, filters, skip, limit, order_by) Dynamic filtering with pagination & ordering
first(db, filters, order_by) Get first matching record
count_filtered(db, filters) Count records with conditions
get_or_create(db, defaults, **filters) Get existing or create new (atomic)
update_or_create(db, filters, defaults) Update existing or create (upsert)

Bulk Operations (High Performance)

Method Description
bulk_create(db, objects) Batch insert (100x faster than loop)
bulk_update(db, objects) Batch update multiple records
delete_many(db, ids) Batch delete by IDs
partial_update(db, id, data) Update without fetching first

Soft Delete Pattern

Method Description
soft_delete(db, id, deleted_at_field) Logical deletion with timestamp
restore(db, id, deleted_at_field) Restore soft-deleted record

Native SQL Execution

Method Description
execute_raw_sql(db, query, params) Execute raw SQL, returns result
execute_raw_sql_dict(db, query, params) Execute SQL, returns list of dicts
execute_raw_sql_commit(db, query, params) Execute SQL with auto-commit

Example Usage:

from atams import BaseRepository
from app.models.user import User

class UserRepository(BaseRepository[User]):
    def __init__(self):
        super().__init__(User)

    def example_usage(self, db):
        # Basic CRUD
        user = self.get(db, id=1)
        users = self.get_multi(db, skip=0, limit=10)
        new_user = self.create(db, {"name": "John", "email": "john@example.com"})

        # Advanced queries
        if self.exists(db, id=1):
            print("User exists!")

        active_users = self.filter(db,
            filters={"status": "active"},
            skip=0, limit=50,
            order_by="-created_at"  # descending
        )

        first_admin = self.first(db,
            filters={"role": "admin"},
            order_by="created_at"
        )

        total = self.count_filtered(db, {"status": "active"})

        # Get or create pattern
        user, created = self.get_or_create(db,
            defaults={"status": "pending"},
            email="new@example.com"
        )

        # Bulk operations (very fast!)
        users_data = [
            {"name": "User1", "email": "user1@example.com"},
            {"name": "User2", "email": "user2@example.com"},
        ]
        self.bulk_create(db, users_data)

        # Soft delete
        self.soft_delete(db, id=1, deleted_at_field="deleted_at")
        self.restore(db, id=1, deleted_at_field="deleted_at")

        # Native SQL
        query = "SELECT * FROM users WHERE status = :status"
        active_users = self.execute_raw_sql_dict(db, query, {"status": "active"})

Using Atlas SSO

Configure Atlas SSO in .env:

ATLAS_SSO_URL=https://api.atlas-microapi.atamsindonesia.com/api/v1
ATLAS_APP_CODE=your_app_code
ATLAS_ENCRYPTION_KEY=your_encryption_key
ATLAS_ENCRYPTION_IV=your_encryption_iv

Then use in endpoints:

from atams.sso import require_auth, require_min_role_level

@router.get("/admin", dependencies=[Depends(require_min_role_level(50))])
async def admin_dashboard(current_user: dict = Depends(require_auth)):
    # Only users with role level >= 50 can access
    return {"user": current_user}

Using Response Encryption

from atams.encryption import encrypt_response_data
from atams.schemas import DataResponse

@router.get("/users/{user_id}")
async def get_user(user_id: int):
    user = get_user_from_db(user_id)
    response = DataResponse(
        success=True,
        message="User retrieved",
        data=user
    )
    # Auto-encrypt if ENCRYPTION_ENABLED=true
    return encrypt_response_data(response)

Development

Setup

git clone https://github.com/GratiaManullang03/atams.git
cd atams
pip install -e ".[dev]"

Run Tests

pytest tests/ -v
pytest tests/ --cov=atams --cov-report=html

Build Package

python -m build

Versioning

ATAMS follows Semantic Versioning:

  • MAJOR version for incompatible API changes
  • MINOR version for new functionality (backwards compatible)
  • PATCH version for bug fixes

Current version: 1.1.0

Contributing

Contributions welcome! Please read CONTRIBUTING.md first.

License

MIT License - see LICENSE file for details.

Links

Support

For support, email support@gratiamanullang03@gmail.com or open an issue on GitHub.

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

atams-1.1.1.tar.gz (45.9 kB view details)

Uploaded Source

Built Distribution

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

atams-1.1.1-py3-none-any.whl (52.2 kB view details)

Uploaded Python 3

File details

Details for the file atams-1.1.1.tar.gz.

File metadata

  • Download URL: atams-1.1.1.tar.gz
  • Upload date:
  • Size: 45.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for atams-1.1.1.tar.gz
Algorithm Hash digest
SHA256 0523f894260f8e7452151773a4f28e8662a188c2265b33d8a4512561f05018ef
MD5 0bca05d18253e66f46d12d73423a779e
BLAKE2b-256 1b1971afe4289b1e05e471bb41edc7275b33b4601cf138dcd38526ca6d692748

See more details on using hashes here.

File details

Details for the file atams-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: atams-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 52.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for atams-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2d3322f26c5714fcc45eedc898d0af94222bb3a2542b530988293f45fe7a1e2b
MD5 093fa4f6b8c9aca79353e1ee3294f679
BLAKE2b-256 78053e563b462fe706ed743042edfa3bc5d24fcccf75e74e51c01fd7d2c4180e

See more details on using hashes here.

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