This folder contains the backend API for Jardin Mental, built with Node.js, Express, and TypeScript. It provides endpoints and services for the application.
Important: In local development, only Postgres and Maildev run in Docker containers. The Node.js API runs directly on your machine (not in a container).
- Node.js (version 14 or higher)
- pnpm (version 8 or higher) – Only pnpm is supported
- Docker (for database and maildev services)
pnpm installNote: Make sure Docker is installed and running before executing this command.
From the api directory, run:
docker-compose up -dThis will start:
- Postgres (database) on port 5432
- Maildev (email testing) on ports 1080 (web UI) and 1025 (SMTP)
- For local development, copy
.env.stagingto.envif not already present:cp .env.staging .env
- Adjust values as needed for your environment.
- Development mode (with hot reload):
The API will be available at http://localhost:3000 by default.
pnpm dev
- Production mode:
pnpm build pnpm start
pnpm testThe cron job sends scheduled notifications. To run it manually:
From the api directory, run:
node reminderCronJobRunner.js- The provided
Dockerfileis intended for production builds and deployment. - For local development, use Docker only for the database and maildev via
docker-compose.yaml. - The API itself should be run locally with pnpm as described above.
- Deployment is managed by Kontinuous via the
.kontinuousdirectory. - The
Dockerfileis used in the CI/CD pipeline for building and deploying the API. - See
.kontinuous/for environment-specific configuration.
The following server resources are configured for the production environment (see .kontinuous/env/prod/values.yaml):
- CPU:
- Requests: 100m (0.1 core)
- Limits: 200m (0.2 core)
- Memory:
- Requests: 512Mi
- Limits: 768Mi
- Storage: 16Gi
- CPU:
- Requests: 1 core
- Limits: 1.5 cores (1500m)
- Memory:
- Requests: 2Gi
- Limits: 2Gi
These specifications represent the minimum resources needed to run the application in production. For development or staging environments, resources can be adjusted accordingly.
k9s is a terminal UI to interact with your Kubernetes clusters.
macOS:
brew install derailed/k9s/k9sLinux:
# Via snap
sudo snap install k9s
# Or download binary from GitHub releases
# https://github.com/derailed/k9s/releasesWindows:
# Via Chocolatey
choco install k9s
# Via Scoop
scoop install k9s-
Obtain kubeconfig files:
- Request the
ovh-prodandovh-devkubeconfig files from a team member with access - These files contain the credentials and configuration to access OVH Kubernetes clusters
- Request the
-
Copy kubeconfig files:
# Copy the files to your .kube directory cp ovh-prod ~/.kube/ovh-prod cp ovh-dev ~/.kube/ovh-dev
-
Launch k9s with multiple contexts:
KUBECONFIG=~/.kube/ovh-dev:~/.kube/ovh-prod k9s
This command loads both development and production contexts simultaneously.
- Press
:to enter command mode - Type
ctxand press Enter - Select the desired context (dev or prod) from the list
- Press
:and typensto switch to namespace view - Navigate to the desired namespace
- Press Enter to view resources
- Scroll to
secretsand press Enter - Select your application's secret
- Press
xto decode and view the secret content
Review environments are created automatically for each pull request. To access a review database:
-
Open k9s in dev context:
KUBECONFIG=~/.kube/ovh-dev k9s -
Navigate to review namespace:
- Press
:and typens - Find and select your review namespace (format:
jardinmental-task-<description>-<id>) - Example:
jardinmental-task-add-specific-message-4xyoo13t
- Press
-
Access PostgreSQL pod:
- Navigate to the
PGpod (PostgreSQL) - Press
sto open a shell in the pod
- Navigate to the
-
Connect to PostgreSQL:
psql -U postgresql
-
List databases:
\l
This displays all available databases.
-
Connect to your review database:
\c <database-name>
The database name typically matches your GitHub PR branch or title.
Useful PostgreSQL commands:
\l- List all databases\c <db>- Connect to a database\dt- List all tables in current database\d <table>- Describe a table structure\q- Quit psql
-
Open k9s in prod context:
KUBECONFIG=~/.kube/ovh-prod k9s -
Navigate to production namespace:
- Press
:and typens - Select the
jardinmentalproduction namespace
- Press
-
Access the PRIMARY PostgreSQL pod:
- Locate the
PGpods - IMPORTANT: Select the oldest PG pod (the two others are read replicas)
- You can identify the primary by checking the pod age
- Press
sto open a shell in the pod
- Locate the
-
Connect to PostgreSQL:
psql -U postgresql
-
List databases:
\l
You should see two databases:
postgres(system database)jardinmental(application database)
-
Connect to the application database:
\c jardinmental
-
Execute your SQL queries:
-- Example: View tables \dt -- Example: Query data SELECT * FROM users LIMIT 10;
- NEVER run
UPDATE,DELETE, orDROPcommands without explicit approval - ALWAYS use transactions (
BEGIN;...ROLLBACK;orCOMMIT;) for any write operations - TEST queries on review environments first
- BACKUP data before any destructive operations
- VERIFY the context indicator in k9s shows
ovh-prodbefore connecting - Only connect to the primary pod (oldest PG pod), not the replicas
- Never commit kubeconfig files to version control
- Keep production credentials secure
- Always verify which context you're in before making changes
- Only pnpm is supported for dependency management and scripts (see
package.json). - For any issues, check the documentation above or open an issue in the repository.