Skip to content

test-org-codity/test-repo

 
 

Repository files navigation

Polyglot Codebase - Multi-Language Code Review System

A sophisticated multi-language microservices application built with Go, Python, Ruby, and TypeScript that provides comprehensive code analysis, review, and metrics calculation.

Architecture

This project consists of four microservices:

  1. Go Service (go-service/) - Fast code parsing, diff analysis, and metrics calculation
  2. Python Service (python-service/) - AI-powered code review with pattern detection and quality scoring
  3. Ruby Service (ruby-service/) - Web API aggregator that orchestrates the other services
  4. JS/TS Service (js-service/) - API Gateway with request routing, rate limiting, and service health monitoring

Features

  • Code Parsing: Multi-language file parsing with language detection
  • Diff Analysis: Intelligent diff calculation between code versions
  • Code Metrics: Lines of code, complexity, functions, classes analysis
  • Code Review: Automated code review with issue detection
  • Quality Scoring: Overall code quality scoring based on multiple factors
  • RESTful APIs: Clean REST APIs for all services
  • CI/CD: Complete GitHub Actions workflows for all languages

Project Structure

polyglot-codebase/
├── go-service/          # Go microservice
│   ├── cmd/            # Application entry point
│   ├── internal/       # Internal packages
│   ├── api/            # HTTP handlers
│   └── go.mod          # Go dependencies
├── python-service/      # Python microservice
│   ├── src/            # Source code
│   ├── tests/          # Test files
│   └── requirements.txt
├── ruby-service/        # Ruby microservice
│   ├── app/            # Application code
│   ├── spec/           # RSpec tests
│   └── Gemfile
├── js-service/          # TypeScript API Gateway
│   ├── src/            # TypeScript source code
│   ├── package.json    # Node.js dependencies
│   └── tsconfig.json   # TypeScript configuration
├── .github/workflows/   # CI/CD pipelines
└── docker-compose.yml   # Docker orchestration

Quick Start

Prerequisites

  • Go 1.21+
  • Python 3.10+
  • Ruby 3.2+
  • Node.js 20+ and npm
  • Docker and Docker Compose (optional)

Local Development

  1. Clone and setup:
cd polyglot-codebase
make build
  1. Run all services:
make run-all
  1. Run tests:
make test
  1. Run linters:
make lint

Using Docker

docker-compose up --build

API Endpoints

Go Service (Port 8080)

  • GET /health - Health check
  • POST /parse - Parse code file
  • POST /diff - Analyze code differences
  • POST /metrics - Calculate code metrics

Python Service (Port 8081)

  • GET /health - Health check
  • POST /review - Review code quality
  • POST /review/function - Review specific function

Ruby Service (Port 8082)

  • GET /health - Health check
  • GET /status - Status of all services
  • POST /analyze - Full code analysis (aggregates Go + Python)
  • POST /diff - Diff analysis with review
  • POST /metrics - Metrics with quality score

JS/TS API Gateway (Port 8083)

  • GET / - API Gateway information and available endpoints
  • GET /health/health - Gateway health check
  • GET /health/status - Status of all microservices
  • GET /api/go/* - Proxy requests to Go service
  • GET /api/python/* - Proxy requests to Python service
  • GET /api/ruby/* - Proxy requests to Ruby service

Example Usage

Analyze Code

curl -X POST http://localhost:8082/analyze \
  -H "Content-Type: application/json" \
  -d '{
    "content": "def hello():\n    print(\"Hello, World!\")",
    "path": "hello.py"
  }'

Get Code Metrics

curl -X POST http://localhost:8082/metrics \
  -H "Content-Type: application/json" \
  -d '{
    "content": "package main\n\nfunc main() {\n    println(\"Hello\")\n}"
  }'

CI/CD

The project includes comprehensive CI workflows:

  • Go CI: Tests, builds, lints with golangci-lint
  • Python CI: Tests with pytest, linting with flake8/black/mypy
  • Ruby CI: Tests with RSpec, linting with RuboCop
  • Integration Tests: End-to-end service integration tests

All workflows run on push and pull requests.

Testing

Go Tests

cd go-service
go test -v ./...

Python Tests

cd python-service
pytest tests/ -v

Ruby Tests

cd ruby-service
bundle exec rspec spec/

Development

Adding New Features

  1. Go Service: Add new parsing logic in internal/parser/
  2. Python Service: Extend review rules in src/code_reviewer.py
  3. Ruby Service: Add new endpoints in app/app.rb

Code Style

  • Go: Follow standard Go conventions, use golangci-lint
  • Python: Follow PEP 8, use black for formatting
  • Ruby: Follow Ruby style guide, use rubocop
  • TypeScript: Follow TypeScript best practices, use eslint for linting

License

MIT License - feel free to use this project for learning and development.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Ensure all CI checks pass
  6. Submit a pull request

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Ruby 26.7%
  • Python 26.6%
  • Go 18.9%
  • TypeScript 18.5%
  • Makefile 5.1%
  • Dockerfile 4.2%