> For the complete documentation index, see [llms.txt](https://docs.keyshade.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.keyshade.io/contributing-to-keyshade/design-of-our-code/api.md).

# API

This document covers how we have developed our API, the stacks, and things you should know before you get started with it!

## Stack

Our API is developed using the following stack:

* **NestJS** as the base
* **Prisma** as the DDL and DML
* **Node Mailer** as the mail agent

## Structure

As per the NestJS convention, our API base is totally modularized, with each module catering to a particular part of our project. The general module structure is as follows:

* **controller**: Stores the APIs that the clients will be interacting with.
* **service**: Holds the business logic
* **misc**: Holds utility functions and classes localized to the particular module
* **dto**: Contains class objects for data intake from the clients
* **types:** Optionally, some modules have a \`\<module\_name>.types.ts\` file that holds the custom types it uses in the module.

## The common module

Just so that we can employ code reusability without much OOP hassle, we have clustered all of our usable components of the backend under the `common` module.

### The `prisma` module

This module deserves special attention since it deals with the data layer. Apart from the usual files, we have two other:

* `schema.prisma`: This contains the data definition
* `migrations`: This folder stores the migrations generated by running the `pnpm run db:generate-migrations` command. These migrations are the state that the current prisma database is in.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.keyshade.io/contributing-to-keyshade/design-of-our-code/api.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.
