Coding Service - Infrastructure
Infrastructure setup
Databases
Uses Prisma with PostgreSQL.
Schema Location: services/coding/prisma/schema.prisma
docker compose -f 'docker-compose.yml' up -d --build 'databases'to stop:
docker compose -f 'docker-compose.yml' down 'databases'Prisma Commands
nx run coding:prisma:generate # generate types
nx run coding:prisma:reset # reset the database depending on the variable DATABASE_URLPerforming a Migration
- Modify the
schema.prismafile of the service you're working with - Trigger the nx command
migrate:dev:create, which will automatically generate the migration file within the/migrationsfolder. Check the result as this command can be dangerous to merge/roll back - Run the migration with the nx command
migrate:dev - Generate the schemas with the nx command
prisma:generate. - Obviously test your changes
You can then create your PR.
For deployment to the environments, you'll notice in the Dockerfile that a script entrypoint.sh is triggered. This script will automatically deploy your migration, meaning your migration will automatically be applied across the environments once the service starts.
Valkey (queues & event system)
docker compose -f 'docker-compose.yml' up -d --build 'valkey'to stop:
docker compose -f 'docker-compose.yml' down 'valkey'Running the Service
Install Dependencies
pnpm installEnvironment variables
- Add a
.env.devat the service root - Get the environment variables from 1password for the corresponding service
Commands
# Development
nx run coding:dev
# Build
nx run coding:build
# Test
nx run coding:test
# Lint
nx run coding:lint
# Run in Docker
docker compose -f 'docker-compose.yml' up -d --build 'coding'
# Check dependencies
nx show project coding
# Show affected projects (based on git changes)
nx affected:graphShared Packages
The shared packages (dto, models, utils) are automatically linked and can be imported in both backend and frontend applications. Any changes to these packages will trigger rebuilds in dependent applications.
These packages mostly contain global functions (like logger, utils, ...) shared among services, providing common functionality and ensuring consistency across the monorepo.
Available Packages
- dto - Data Transfer Objects
- models - Shared data models
- utils - Utility functions and helpers