{"id":50307825,"url":"https://github.com/rajinder1310/codesense-api","last_synced_at":"2026-05-28T18:01:20.262Z","repository":{"id":360891121,"uuid":"1252154277","full_name":"rajinder1310/codesense-api","owner":"rajinder1310","description":null,"archived":false,"fork":false,"pushed_at":"2026-05-28T09:07:48.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-28T10:26:25.189Z","etag":null,"topics":["ai-evaluation","benchmarking","code-analysis","fastapi","python","rest-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rajinder1310.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-28T08:37:51.000Z","updated_at":"2026-05-28T09:09:14.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/rajinder1310/codesense-api","commit_stats":null,"previous_names":["rajinder1310/codesense-api"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/rajinder1310/codesense-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rajinder1310%2Fcodesense-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rajinder1310%2Fcodesense-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rajinder1310%2Fcodesense-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rajinder1310%2Fcodesense-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rajinder1310","download_url":"https://codeload.github.com/rajinder1310/codesense-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rajinder1310%2Fcodesense-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33619972,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-evaluation","benchmarking","code-analysis","fastapi","python","rest-api"],"created_at":"2026-05-28T18:01:17.055Z","updated_at":"2026-05-28T18:01:20.247Z","avatar_url":"https://github.com/rajinder1310.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CodeSense — AI Code Evaluation Service\n\n\u003e A production-grade REST API that analyses Python code quality and benchmarks solutions against auto-generated test suites.\n\u003e \n\u003e 🔗 GitHub: https://github.com/rajinder1310/codesense-api\n\n---\n\n## Table of Contents\n\n- [Features](#features)\n- [Architecture](#architecture)\n- [Quick Start](#quick-start)\n- [API Reference](#api-reference)\n  - [Health Check](#get-health)\n  - [Analyze Code](#post-analyze)\n  - [Benchmark Solution](#post-benchmark)\n- [Running Tests](#running-tests)\n- [Project Structure](#project-structure)\n- [Configuration](#configuration)\n- [License](#license)\n\n---\n\n## Features\n\n| Capability | Description |\n|---|---|\n| **Static Analysis** | AST-based complexity scoring, quality rating (0–100), edge-case detection |\n| **Benchmarking** | Auto-generated test suites for common algorithms with timing |\n| **Production-ready** | Structured logging, CORS, global error handlers, Pydantic v2 validation |\n| **Interactive Docs** | Swagger UI at `/docs`, ReDoc at `/redoc` |\n| **Fully Tested** | pytest suite covering happy paths, error conditions, and edge cases |\n\n---\n\n## Architecture\n\n```\nClient ──► FastAPI App ──► Routers ──► Services\n               │                        ├── code_analyzer.py  (ast-based)\n               │                        └── benchmark_engine.py (exec + test suites)\n               ├── models/schemas.py    (Pydantic v2 models)\n               └── Middleware           (CORS, error handlers)\n```\n\n---\n\n## Quick Start\n\n### Prerequisites\n\n- Python 3.10+\n- pip\n\n### Installation\n\n```bash\n# Clone the repository\ncd codeSense\n\n# Create a virtual environment (recommended)\npython -m venv venv\nvenv\\Scripts\\activate        # Windows\n# source venv/bin/activate   # macOS / Linux\n\n# Install dependencies\npip install -r requirements.txt\n```\n\n### Run the Server\n\n```bash\n# Development (with auto-reload)\nuvicorn main:app --reload --port 8000\n\n# Production\nuvicorn main:app --host 0.0.0.0 --port 8000 --workers 4\n```\n\nThe API is now available at **http://localhost:8000**.\n\n- Swagger UI: [http://localhost:8000/docs](http://localhost:8000/docs)\n- ReDoc: [http://localhost:8000/redoc](http://localhost:8000/redoc)\n\n---\n\n## API Reference\n\n### `GET /health`\n\nReturns the service health status.\n\n**Response** `200 OK`\n\n```json\n{\n  \"status\": \"ok\",\n  \"version\": \"1.0.0\"\n}\n```\n\n---\n\n### `POST /analyze`\n\nAnalyse Python source code for complexity, quality, and potential issues.\n\n**Request Body**\n\n```json\n{\n  \"code\": \"def add(a, b):\\n    return a + b\",\n  \"language\": \"python\"\n}\n```\n\n| Field | Type | Required | Default | Description |\n|---|---|---|---|---|\n| `code` | string | ✅ | — | Python source code to analyse |\n| `language` | string | ❌ | `\"python\"` | Programming language (only `python` supported) |\n\n**Response** `200 OK`\n\n```json\n{\n  \"complexity_score\": 2,\n  \"edge_cases_missing\": [\n    \"Function 'add' accepts parameters but has no input validation or guard clauses\"\n  ],\n  \"quality_score\": 72,\n  \"suggestions\": [\n    \"Only 0/1 functions/classes have docstrings — aim for ≥ 80 % coverage\",\n    \"Add return-type annotations to your functions for better readability and tooling support\"\n  ],\n  \"lines_of_code\": 2\n}\n```\n\n**Error Responses**\n\n| Status | Condition |\n|---|---|\n| `400` | Unsupported language |\n| `422` | Syntax error in code or validation failure |\n| `500` | Internal server error |\n\n---\n\n### `POST /benchmark`\n\nEvaluate a candidate solution against auto-generated test cases.\n\n**Request Body**\n\n```json\n{\n  \"problem\": \"Write a function called 'factorial' that returns the factorial of a non-negative integer.\",\n  \"solution_code\": \"def factorial(n):\\n    if n \u003c= 1:\\n        return 1\\n    return n * factorial(n - 1)\"\n}\n```\n\n| Field | Type | Required | Description |\n|---|---|---|---|\n| `problem` | string | ✅ | Natural-language problem description |\n| `solution_code` | string | ✅ | Python solution code |\n\n**Supported Problem Types**\n\nThe benchmark engine recognises the following problem types by keyword or function name:\n\n- `factorial` — Factorial computation\n- `fibonacci` / `fib` — Fibonacci sequence\n- `is_palindrome` / `palindrome` — Palindrome checking\n- `reverse_string` / `reverse` — String reversal\n- `two_sum` / `twosum` — Two Sum problem\n- `is_prime` / `prime` — Primality test\n- `max_subarray` / `kadane` — Maximum subarray sum\n\n**Response** `200 OK`\n\n```json\n{\n  \"passed_tests\": 5,\n  \"failed_tests\": 0,\n  \"correctness_score\": 100,\n  \"edge_cases_handled\": true,\n  \"execution_time_ms\": 0.123,\n  \"feedback\": \"Excellent! All test cases passed. All edge cases were handled correctly.\"\n}\n```\n\n**Error Responses**\n\n| Status | Condition |\n|---|---|\n| `400` | No function definition found in solution |\n| `422` | Syntax error in solution or validation failure |\n| `500` | Internal server error |\n\n---\n\n## Running Tests\n\n```bash\n# Run all tests\npytest -v\n\n# Run only analyze tests\npytest tests/test_analyze.py -v\n\n# Run only benchmark tests\npytest tests/test_benchmark.py -v\n\n# Run with coverage\npytest --cov=. --cov-report=term-missing\n```\n\n---\n\n## Project Structure\n\n```\ncodeSense/\n├── main.py                    # FastAPI app entry point, middleware, error handlers\n├── routers/\n│   ├── __init__.py\n│   ├── analyze.py             # POST /analyze endpoint\n│   ├── benchmark.py           # POST /benchmark endpoint\n│   └── health.py              # GET /health endpoint\n├── services/\n│   ├── __init__.py\n│   ├── code_analyzer.py       # AST-based static analysis engine\n│   └── benchmark_engine.py    # Solution benchmarking engine\n├── models/\n│   ├── __init__.py\n│   └── schemas.py             # Pydantic request/response models\n├── tests/\n│   ├── __init__.py\n│   ├── test_analyze.py        # Tests for /analyze\n│   └── test_benchmark.py      # Tests for /benchmark\n├── requirements.txt           # Pinned dependencies\n└── README.md                  # This file\n```\n\n---\n\n## Configuration\n\n| Environment Variable | Default | Description |\n|---|---|---|\n| `HOST` | `127.0.0.1` | Server bind address |\n| `PORT` | `8000` | Server port |\n| `LOG_LEVEL` | `info` | Logging verbosity |\n| `WORKERS` | `1` | Number of uvicorn workers |\n\n---\n\n## License\n\nMIT © 2026\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frajinder1310%2Fcodesense-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frajinder1310%2Fcodesense-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frajinder1310%2Fcodesense-api/lists"}