### README.md Template for ContextID
# ContextID
## Introduction
ContextID is an Elixir package that provides a simple yet flexible way to generate custom, context-rich identifiers. It allows users to specify a custom prefix for IDs, enhancing readability and making them more meaningful in various applications, you get similar uniqueness to a uuidv4 but now with an element of context at the front given your prefix.
## Examples
Here are some sample IDs that your package could generate with various prefixes and lengths:
1. With prefix `acct` and a length of 8 bytes: `acct_9b545ad85399e20e`
2. With prefix `id` and a length of 16 bytes: `id_a53eb7a0ccfda31b1df4776ba1b11124`
3. With prefix `acct_number` and a length of 4 bytes: `acct_number_3b63b3bc`
These examples are simply meant to illustrate the flexibility and utility of the `ContextID` package in generating readable, context-specific identifiers.
## Features
- **Custom Prefixes for IDs**: Generate IDs with user-defined prefixes, enhancing readability and context awareness.
- **Configurable ID Length**: Tailor the length of your generated IDs to suit your specific requirements.
- **Streamlined Usage**: Offers a straightforward and user-friendly interface, making it easy to integrate and use in any Elixir project.
- **No External Dependencies**: Built exclusively using Elixir's standard library, ensuring a lightweight and efficient solution without the need for additional dependencies.
## Installation
Add `contextual_id` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:contextual_id, "~> 0.1.0"}
]
end
```
## Usage
Generating a custom ID is straightforward:
```elixir
# Using the main module
id = ContextID.generate_id("prefix", 16)
# Using the shortcut alias
id = Cid.generate_id("prefix", 16)
```
## Examples
Generate an ID with a custom prefix:
```elixir
ContextID.generate_id("user", 10)
# => "user_18165fe7c154341e861c"
```
Generate an ID with the default settings:
```elixir
Cid.generate_id()
# => "id_a53eb7a0ccfda31b1df4776ba1b11124"
```
## Configuration
`ContextID` allows for global configuration of default prefix and ID length, which can be set for your entire Elixir application. This means you can specify default values for these parameters, and `ContextID` will use them whenever you generate an ID without explicitly providing these arguments.
To set up global configuration, add the following lines to your application's configuration file (typically found at `config/config.exs`):
```elixir
# In config/config.exs
config :contextual_id, :default_prefix, "your_default_prefix"
config :contextual_id, :default_length, your_default_length
```
Replace `"your_default_prefix"` with the default prefix string you wish to use, and `your_default_length` with the default length (as an integer) for the IDs.
For example, setting:
```elixir
config :contextual_id, :default_prefix, "acct"
config :contextual_id, :default_length, 12
```
means that `ContextID.generate_id()` will produce IDs like `"acct_1a2b3c4d5e6f7a8b9c0d"` by default, unless you specify different arguments when calling the function.
This feature adds a layer of convenience and customization, allowing you to set and forget these defaults as per your application's needs.
## Contributing
Contributions are welcome! Please read our [Contributing Guidelines](CONTRIBUTING.md) for details on how to submit pull requests, file issues, and so on.
## Testing
Run the test suite with:
```shell
mix test
```
## License
ContextID is released under the [MIT License](LICENSE).
## Acknowledgments
- None yet
## Contact
For any questions or suggestions, please open an issue in the GitHub repository.