Skip to content

Commit

Permalink
Added new documentation (#2970)
Browse files Browse the repository at this point in the history
* Updated to v3.7 docusaurus

* Added new documentation

* Added the intro page.

* Code Rabbit suggestions.

* Fixed typos.

* Fixed sidebar
  • Loading branch information
palisadoes authored Jan 27, 2025
1 parent 28859b2 commit 64e2efc
Show file tree
Hide file tree
Showing 8 changed files with 564 additions and 588 deletions.
31 changes: 31 additions & 0 deletions docs/docs/docs/developer-resources/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
id: introduction
title: Introduction
slug: /developer-resources/introduction
sidebar_position: 1
---

Welcome to the Talawa-API developer resources.

## Important Directories

Review these important locations before you start your coding journey.

| **Directory** | **Description** |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `devcontainer` | Contains the devcontainer configuration file. |
| `docker/` | Contains Docker configuration files. |
| `drizzle_migrations/` | Definitions that allow the the Drizzle ORM to modify the structure of a database schema by adding, removing, or changing columns in tables, essentially allowing you to update your database schema programmatically without writing raw SQL commands, ensuring that changes are tracked and can be applied consistently across different environments. |
| `envFiles/` | Contains `.env` files for production, development and CI/CD pipelines |
| `src/drizzle` | Contains drizzle-orm schema definitions for the postgres database. |
| `src/graphql` | Used for storing all pothos schema definitions used for Talawa-API's graphql implementation. |
| `src/graphql/enums` | Used for storing the schema definitions for the graphql inputs used in the Talawa-API's graphql implementation. |
| `src/graphql/inputs` | Used for storing the schema definitions for the graphql inputs used in the Talawa-API's graphql implementation. |
| `src/graphql/interfaces` | Used for storing the schema definitions for the graphql interfaces used in the Talawa-API's graphql implementation. |
| `src/graphql/scalars` | Used for storing the schema definitions for the graphql scalars used in the Talawa-API's graphql implementation. |
| `src/graphql/types` | Used for storing the schema definitions for the graphql types used in the Talawa-API's graphql implementation. |
| `src/graphql/unions` | Used for storing the schema definitions for the graphql unions used in the Talawa-API's graphql implementation. |
| `src/plugins` | Contains the fastify plugins used to extend the base functionality of the fastify instance either for usage in other plugins or for usage in the route plugins. |
| `src/routes` | Used for storing the schema definitions for the graphql enums used in the Talawa-API's graphql implementation. |
| `test` | Contains the code for performing api tests against Talawa-API. The tests in this directory must follow the practices of black box testing and most of them should be written to be able to run concurrently. |
| `test/routes/graphql` | Contains the code for performing api tests against Talawa-API. The tests in this directory must follow the practices of black box testing and most of them should be written to be able to run concurrently. |
Original file line number Diff line number Diff line change
@@ -1,42 +1,47 @@
# pnpm scripts
---
id: pnpm-scripts
title: PNPM Scripts
slug: /developer-resources/pnpm-scripts
sidebar_position: 2
---

The scripts listed below are used with pnpm for many different workflows of talawa api.

## pnpm apply_drizzle_migrations

This command is used to apply the sql migration files present in the `drizzle_migrations` directory to the postgres database being used by talawa api.

More information can be found at [this](https://orm.drizzle.team/kit-docs/commands#apply-migrations) link.
- More information can be found at [this](https://orm.drizzle.team/docs/kit-overview) link.

## pnpm apply_drizzle_test_migrations

This command is used to apply the sql migration files present in the `drizzle_migrations` directory to the postgres test database being used by talawa api.

More information can be found at [this](https://orm.drizzle.team/kit-docs/commands#apply-migrations) link.
- More information can be found at [this](https://orm.drizzle.team/docs/kit-overview) link.

## pnpm build_production

This command is used to create a production build of the talawa api codebase by transpiling the typescript code to javascript code and also getting rid of unncessary stuff not needed in production.
This command is used to create a production build of the talawa api codebase by transpiling the typescript code to javascript code and also getting rid of unnecessary stuff not needed in production.

More information can be found at [this](https://swc.rs/docs/usage/cli) link.
- More information can be found at [this](https://swc.rs/docs/usage/cli) link.

## pnpm check_code_quality

This command is used to check the linting and formatting issues in the codebase.

More information can be found at [this](https://biomejs.dev/reference/cli/#biome-check) link.
- More information can be found at [this](https://biomejs.dev/reference/cli/#biome-check) link.

## pnpm check_drizzle_migrations

This command is used to check for inconsistencies and collisions in the sql migration files in the `drizzle_migrations` directory that could arise because of many contributers contributing to the project.

More information can be found at [this](https://orm.drizzle.team/kit-docs/commands#check) link.
- More information can be found at [this](https://orm.drizzle.team/docs/kit-overview) link.

## pnpm check_type_errors

This command is used to check the type errors in the codebase using typescript compiler.

More information can be found at [this](https://www.typescriptlang.org/docs/handbook/compiler-options.html#using-the-cli) link.
- More information can be found at [this](https://www.typescriptlang.org/docs/handbook/compiler-options.html#using-the-cli) link.

## pnpm disable_git_hooks

Expand All @@ -48,7 +53,7 @@ More information can be found [this](https://evilmartians.github.io/lefthook/usa

This command is used to delete the existing sql migration files in the `drizzle_migrations` directory as their manual deletion would break drizzle-kit.

More information can be found at [this](https://orm.drizzle.team/kit-docs/commands#drop-migration) link.
- More information can be found at [this](https://orm.drizzle.team/docs/kit-overview) link.

## pnpm enable_git_hooks

Expand All @@ -60,13 +65,13 @@ More information can be found [this](https://evilmartians.github.io/lefthook/usa

This command is used to fix as many linting and formatting issues in the codebase as possible for being auto-fixed. Output of this command resulting in a failure means that there are some issues that need to be fixed manually.

More information can be found at [this](https://biomejs.dev/reference/cli/#biome-check) link.
- More information can be found at [this](https://biomejs.dev/reference/cli/#biome-check) link.

## pnpm generate_drizzle_migrations

This command is used to generate the sql migration files in the `drizzle_migrations` directory that reflect the latest state of the drizzle schema in the codebase.

More information can be found at [this](https://orm.drizzle.team/kit-docs/commands#generate-migrations) link.
- More information can be found at [this](https://orm.drizzle.team/docs/kit-overview) link.

## pnpm generate_graphql_sdl_file

Expand All @@ -85,19 +90,19 @@ More information can be found at these links:

This command is used to push the changes in the drizzle-orm schema in the codebase to the postgres database for rapid local development(prototyping) without having to handle generating and applying the drizzle migration files after each little change.

More information can be found at [this](https://orm.drizzle.team/kit-docs/commands#apply-migrations) link.
- More information can be found at [this](https://orm.drizzle.team/docs/kit-overview) link.

## pnpm push_drizzle_test_schema

This command is used to push the changes in the drizzle-orm schema in the codebase to the postgres test database for rapid local development(prototyping) without having to handle generating and applying the drizzle migration files after each little change.

More information can be found at [this](https://orm.drizzle.team/kit-docs/commands#apply-migrations) link.
- More information can be found at [this](https://orm.drizzle.team/docs/kit-overview) link.

## pnpm run_tests

This command is used to run the integration tests for talawa api.

More information can be found at [this](https://vitest.dev/) link.
- More information can be found at [this](https://vitest.dev/) link.

## pnpm start_development_server

Expand Down Expand Up @@ -129,4 +134,4 @@ More information at these links:

This command is used to keep the drizzle metadata in the `drizzle_migrations/_meta` directory up to date with the latest changes in drizzle-orm and drizzle-kit.

More information can be found at [this](https://orm.drizzle.team/kit-docs/commands#maintain-stale-metadata) link.
- More information can be found at [this](https://orm.drizzle.team/docs/kit-overview) link.
58 changes: 58 additions & 0 deletions docs/docs/docs/developer-resources/troubleshooting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
id: troubleshooting
title: Operation & Troubleshooting
slug: /developer-resources/troubleshooting
sidebar_position: 3
---

## Operation

This section covers how Talawa API operates

### Key Concepts

Before you begin, here are some important summaries of the technologies used.

#### Docker Development Containers (devcontainers)

Talawa API uses devcontainers for many features

Development containers, or devcontainers, are Docker containers that are specifically configured to provide a fully featured development environment. They can be used to run an application, to separate tools, libraries, or runtimes needed for working with a codebase, and to aid in continuous integration and testing. Dev containers can be run locally or remotely, in a private or public cloud, in a variety of supporting tools and editors.

The Development Container Specification seeks to find ways to enrich existing formats with common development specific settings, tools, and configuration while still providing a simplified, un-orchestrated single container option – so that they can be used as coding environments or for continuous integration and testing. Beyond the specification's core metadata, the spec also enables developers to quickly share and reuse container setup steps through Features and Templates.

- For more information visit [containers.dev](https://containers.dev/)

Regular Docker's core features are contrary to using it as a developer environment.

1. Each container has an isolated filesystem, so the container can't normally see code on the host system, and the host system can't see tools that are only installed in the container.
2. A container is based on an immutable image: you can't normally change the code a container is running without rebuilding the image and recreating the container. This is a familiar workflow for developers using compiled languages (C++, Java, Go, Rust), where even without Docker you still need to recompile and restart the application after every change.

Visit [this link](https://stackoverflow.com/questions/75652065/whats-the-difference-between-docker-compose-and-dev-containers) for further information on the differences between Containers and Dev Containers.

##### Talawa API Dev Containers

In Talawa API, the API devcontainer operates like a lightweight virtual machine which has network access available to the external containers services including:

1. `postgres`
1. `postgres-test`
1. `minio`
1. `minio-test`
1. `cloudbeaver`
1. `caddy`

The Talawa API git repository is mounted on it. After the Dev Container starts, the `node.js` development server runs on a port mapped to a port on your host system.

The API runs by default when the devcontainer starts, but only after the these compose services have already started.

**IMPORTANT NOTES**

1. Always keep your code up to date in your local branch because there may be changes not just to the code, but to the devcontainer configuration.
1. Make sure your `.env` file is up to date with the latest changes in `.env.devcontainer` and restart the containers when there are changes.
2. A `.env` file will be automatically created when the devcontainer starts, if doesn't previously exist.
3. Preexisting `.env` files are not automatically updated with remote changes, you have to do that yourself.
2. Healthchecks are skipped in the devcontainer, because if the healthcheck for it was running then the api devcontainer would never start.

### Startup Sequence

## Troubleshooting
Loading

0 comments on commit 64e2efc

Please sign in to comment.