# Templates

Templates are a series of cookiecutter templates used to generate new services.

These templates aim to reduce the amount of variance between services, and aim to save time scaffolding and setting up new services, as this tends to involve a lot of duplication of time and effort.

## Forewarning

These templates aren't intended to be perfect, or to generate code that works immediately. You may need to tweak things and shift things around slightly depending on your requirements, but the basic structure should be left intact for consistency across services.

If you find yourself changing the architecture, layout, or default libraries in any way, you should discuss with the team about changing the template, too.

These templates should be improved over time as we generate more services, and we're able to spot more common patterns which could be automated.

Please, please, pleae contribute to these templates, as they will save time for us all in the long run.

## Prerequisites

Install cookiecutter

```bash
$ brew install cookiecutter
```

## Templates

Currently, we have two main templates:

### gRPC

This creates a new gRPC service, which are to be used as internal services. I.e., they have no public access, no web interfaces and communicate only via service to service communication.

The gRPC service will create a buf config, a proto file and some basic service plumbing.

## Usage

From the root directory of this repo, run:

```bash
$ make new-service type=grpc
$ make new-serice type=web
```

Generated services will be places into the `services` directory, so that they will become applicable for CI/CD etc.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mediamagic.dev/product-docs/templates.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
