📖

README Principal

Audissey

✨ Your new, shiny Nx workspace is almost ready ✨.

Learn more about this workspace setup and its capabilities or run npx nx graph to visually explore what was created. Now, let's get you up to speed!

🐳 Quick Start with Docker

Para levantar o ambiente completo de desenvolvimento com Docker:

# Copiar arquivo de configuração
cp .env.example .env

# Levantar toda a stack (API + MongoDB)
docker compose up -d

# Ou usar o script de desenvolvimento
./docker-dev.sh start

Serviços disponíveis:

Para mais informações, consulte docker/README.md.

💻 Development Setup

Prerequisites

Environment Variables

A aplicação requer várias variáveis de ambiente para funcionar corretamente. Todas as variáveis estão documentadas no ficheiro .env.example.

Configuração Inicial

# Copiar o ficheiro de exemplo
cp .env.example .env

# Editar o .env e preencher as variáveis obrigatórias

Variáveis Obrigatórias

As seguintes variáveis devem estar definidas para a aplicação iniciar:

Variável Descrição Exemplo
MONGO_ROOT_USERNAME Username do MongoDB admin
MONGO_ROOT_PASSWORD Password do MongoDB admin123
MONGO_DATABASE Nome da base de dados audissey
JWT_SECRET Chave secreta para tokens JWT your_secret_key_change_in_production

Variáveis Opcionais (com defaults)

Variável Descrição Default
NODE_ENV Ambiente de execução development
API_PORT Porta da API 3000
MONGO_PORT Porta do MongoDB 27017
MONGO_HOST Host do MongoDB localhost
JWT_EXPIRES_IN Expiração do token JWT 24h
LOG_LEVEL Nível de logging info
CORS_ORIGINS Origens permitidas para CORS -

Validação de Variáveis

A aplicação valida automaticamente todas as variáveis de ambiente no arranque. Se alguma variável obrigatória estiver em falta ou inválida, a aplicação não inicia e apresenta uma mensagem clara de erro:

🚨 Environment variable validation failed!

The following environment variables are missing or invalid:

  ❌ JWT_SECRET: JWT_SECRET should not be empty
  ❌ MONGO_ROOT_PASSWORD: MONGO_ROOT_PASSWORD should not be empty

Please check your .env file and ensure all required variables are set.
See .env.example for a complete list of required variables.

Configuração por Ambiente

Development:

NODE_ENV=development
API_URL=http://localhost:3000
MONGO_HOST=localhost
LOG_LEVEL=debug
WORKER_API_KEY=<any-random-secret>   # shared between API and worker
ML_SERVICE_URL=http://localhost:5000 # ML service for HTML cleaning / schedule extraction

Staging:

NODE_ENV=staging
API_URL=https://staging-api.audissey.com
MONGO_HOST=mongodb
LOG_LEVEL=info

Production:

NODE_ENV=production
API_URL=https://api.audissey.com
MONGO_HOST=mongodb
LOG_LEVEL=warn
JWT_SECRET=<strong_random_secret>
MONGO_ROOT_PASSWORD=<strong_random_password>

Local Development

Para desenvolvimento local sem Docker (recomendado para hot reload):

# Instalar dependências
npm install

# Levantar apenas a base de dados
docker compose up -d mongodb

# Executar API em modo desenvolvimento
npx nx serve api

Finish your CI setup

Click here to finish setting up your workspace!

Run tasks

To run the dev server for your app, use:

npx nx serve api

To create a production bundle:

npx nx build api

To see all available targets to run for a project, run:

npx nx show project api

These targets are either inferred automatically or defined in the project.json or package.json files.

More about running tasks in the docs »

Add new projects

While you could add new projects to your workspace manually, you might want to leverage Nx plugins and their code generation feature.

Use the plugin's generator to create new projects.

To generate a new application, use:

npx nx g @nx/nest:app demo

To generate a new library, use:

npx nx g @nx/node:lib mylib

You can use npx nx list to get a list of installed plugins. Then, run npx nx list <plugin-name> to learn about more specific capabilities of a particular plugin. Alternatively, install Nx Console to browse plugins and generators in your IDE.

Learn more about Nx plugins » | Browse the plugin registry »

Learn more about Nx on CI

Install Nx Console

Nx Console is an editor extension that enriches your developer experience. It lets you run tasks, generate code, and improves code autocompletion in your IDE. It is available for VSCode and IntelliJ.

Install Nx Console »

Learn more:

And join the Nx community: