A high-performance microservice for source code analysis, generating Abstract Syntax Trees (ASTs) and relationship maps from codebases.
- 🚀 AST generation for multiple programming languages
- 🔍 Code relationship mapping
- ⚡ High-performance processing with Node.js worker threads
- 🐳 Docker and Kubernetes ready
- 📊 Built-in health checks and metrics
- 🔒 Secure by default
- Node.js 22.14.0 or higher
- Yarn (recommended) or npm
- Docker (for containerized deployment)
- Git
-
Clone the repository
git clone https://github.com/kodustech/kodus-service-ast.git cd kodus-service-ast -
Install dependencies
yarn install # or npm install
# Development with hot-reload
yarn start:dev
# Build for production
yarn build
# Run in production mode locally
yarn start:prodIf you encounter RabbitMQ errors like "PRECONDITION_FAILED - inequivalent arg", it means queues are being declared with different arguments by different processes.
Solution:
- Stop all applications (API + Worker)
- Run the cleanup script:
./scripts/cleanup-rabbitmq.sh - Restart applications - queues will be recreated with correct configuration
This happens when:
- API and Worker modules declare the same queue with different
arguments - Previous deployments created queues with different configurations
@RabbitSubscribedecorators conflict with module-level queue declarations
# Development
make dev-build
# or
docker build -t kodus-ast:dev -f DockerFiles/Dockerfile.dev .
# Production (replace x.y.z with the release version)
docker build \
--build-arg RELEASE_VERSION=x.y.z \
-t kodus-ast:x.y.z \
-f DockerFiles/Dockerfile.prod .# Development
docker run -d \
--name kodus-ast-dev \
-p 3002:3002 \
-v $(pwd):/usr/src/app \
-v /usr/src/app/node_modules \
kodus-ast:dev
# Production (replace x.y.z with the desired version)
docker run -d \
--name kodus-ast \
-p 3002:3002 \
-e NODE_ENV=production \
-e LOG_LEVEL=info \
--memory="4g" \
--cpus="2" \
kodus-ast:x.y.zGET /health
POST /api/analyze # Analyze source code
GET /api/status/:id # Check analysis status
# Other endpoints...
Note: All API routes except
/healthare prefixed with/api/
| Variable | Default | Description |
|---|---|---|
NODE_ENV |
production | Runtime environment |
LOG_LEVEL |
info | Log level (error, warn, info, debug) |
API_PORT |
3002 | API port |
UV_THREADPOOL_SIZE |
Auto | Node.js thread pool size |
DB_URL |
- | Postgres connection string (takes precedence over host/port vars) |
DB_HOST |
localhost | Postgres host (used when DB_URL is not set) |
DB_PORT |
5432 | Postgres port |
DB_USER |
- | Postgres username |
DB_PASSWORD |
- | Postgres password |
DB_NAME |
- | Postgres database |
DB_SCHEMA |
kodus_workflow | Schema dedicated a armazenar workflows/tarefas compartilhados |
DB_SSL |
true | Enables TLS (set false only in trusted local setups) |
DB_SSL_REJECT_UNAUTHORIZED |
true | Reject self-signed/invalid certs (set false apenas se tiver CA interna conhecida) |
DB_POOL_MAX |
10 | Máximo de conexões simultâneas no pool |
DB_POOL_IDLE_TIMEOUT_MS |
30000 | Tempo para fechar conexões ociosas (ms) |
DB_POOL_CONNECTION_TIMEOUT_MS |
5000 | Timeout para adquirir conexão (ms) |
DB_STATEMENT_TIMEOUT_MS |
0 | Timeout por query (ms). 0 = ilimitado |
API_DATABASE_ENV |
production | Define se estamos em development/local (desativa TLS por padrão) |
Os campos
DB_*também aceitam as variáveis utilizadas pelos demais serviços (API_PG_DB_HOST,API_PG_DB_USERNAME, etc.) como fallback.
Observação: o serviço inicializa automaticamente o schema/tabelas (com
CREATE IF NOT EXISTS) na primeira execução. Para ambientes gerenciados, execute as DDLs do diretóriodocs/architectureantes do deploy.
# Run all tests
yarn test
# Run tests with coverage
yarn test:cov
# Run e2e tests
yarn test:e2eO deploy pode ser feito via pipelines CI/CD (GitHub Actions, Jenkins, etc.), gerando imagem container e aplicando-a na infraestrutura escolhida (ECS, Kubernetes, VMs, etc.).
# Build and push the production image
make release VERSION=x.y.z
# Deploy to your infrastructure
kubectl apply -f k8s/We welcome contributions! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For more detailed documentation, please refer to our documentation site.
Project Link: https://github.com/kodustech/kodus-service-ast
- Built with ❤️ by the Kodus Tech Team
- Thanks to all contributors who have helped shape this project
- Inspired by modern AST tooling and code analysis tools