Getting Started
This guide provides everything you need to set up a local development environment for Citadel.
Prerequisites
- Visual Studio Code
- Docker Desktop
- The VS Code Dev Containers extension
Local Setup
The fastest way to get started is with the provided Dev Container.
-
Clone the repository.
-
Set up local configuration: Copy the example configurations for the Dev Container and VS Code workspace. This provides the necessary settings for running and debugging services.
cp -r devcontainer-example .devcontainer
cp -r vscode-example .vscode -
Configure Backing Services: Open
.devcontainer/devcontainer.json. ThedockerComposeFilearray controls which services are started. To work on a specific service, you must enable its backing dependencies by uncommenting the relevantcompose.*.ymlfiles. For example, to work on theiam-service, you would uncomment its dependencies:// "compose.rauth.yml",
// "compose.keycloak.yml",
// "compose.mongo.yml",After uncommenting, your
dockerComposeFilearray would look like this:"dockerComposeFile": [
"compose.core.yml",
"compose.rauth.yml",
"compose.keycloak.yml",
"compose.mongo.yml",
// ... any other services you need
], -
Open the project in VS Code and click "Reopen in Container" when prompted.
That's it! The environment will build, and all services will be started automatically.
Verifying the Environment
Once the Dev Container is running, you can verify that all services have started correctly by checking the Docker containers.
Open a terminal in VS Code and run:
docker ps
You should see containers for iam-service, postgres, nats, and other core services.
Running Tests
The monorepo is managed by Turborepo, which makes running tests simple.
To run all tests for all services from the root of the project, use:
pnpm run test
To run tests for a specific service (e.g., iam-service):
pnpm run test --filter=iam-service
Debugging a Service
The Dev Container is configured for debugging. By copying the vscode-example directory, the pre-configured launch configurations are now available in the "Run and Debug" panel.
The process is similar for all services. For example, to debug the iam-service:
- Open a Go file in
citadel/apps/iam-service. - Set a breakpoint.
- Go to the "Run and Debug" panel in VS Code and select the "Debug iam-service" configuration.
- Press F5 to start debugging.
Making Your First API Call
With the services running, you can interact with them via their REST APIs. The API Gateway exposes all services under the http://localhost:1111/api/ path.
As an example, here is how you can create a new tenant in the iam-service using curl:
curl -X POST http://localhost:1111/api/iam/tenants \\
-H "Content-Type: application/json" \\
-d '{"name": "My First Tenant"}'
You should receive a 201 Created response with the details of the newly created tenant, including its unique ID. This confirms that the iam-service and the database are working correctly.