Skip to content

# Alpha core system

## Purpose

The core is used as a central point to manage various system:

- logging system
- database access
- api system
- dynamic configuration

## How to use

You could:

- Use the alphaz core and initiate it at the start of you project preferably in a file named core.py to be complient with this documentation:

      from alphaz.models.main import AlphaCore

      core = AlphaCore(__file__)
      DB, API, LOG = core.db, core.api, core.log # not required but recommanded

- Or create a core.py file at the root of your project containing at least:

      from alphaz.models.main import AlphaCore, singleton

      @singleton
      class Core(AlphaCore):

          def __init__(self,file:str):

              super().__init__(file)

      core = Core(__file__)
      DB, API, LOG = core.db, core.api, core.log # not required but recommanded

Note

This is the recommended way, so that you could custom the Core class

## Logging

    from core import core
    LOG = core.get_logger('name')
    LOG.info('message')

### Database

    from core import core
    DB = core.db

## API

    from core import core
    API = core.api

## Configuration

    from core import core
    CONFIG = core.config
    tmp_directory_path = CONFIG.get('directories/tmp')