{"id":38852308,"url":"https://github.com/codegen-sh/codebase-analytics","last_synced_at":"2026-01-17T14:13:41.796Z","repository":{"id":277613734,"uuid":"932457093","full_name":"codegen-sh/codebase-analytics","owner":"codegen-sh","description":"Analytics for codebase maintainability and complexity","archived":false,"fork":false,"pushed_at":"2025-02-25T22:31:02.000Z","size":157,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-25T23:27:29.449Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://codebase-analytics.vercel.app","language":"TypeScript","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/codegen-sh.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}},"created_at":"2025-02-14T00:06:49.000Z","updated_at":"2025-02-25T22:31:04.000Z","dependencies_parsed_at":"2025-02-14T23:26:45.103Z","dependency_job_id":"e4e5e273-ef22-42b9-8fb8-ca5e342918de","html_url":"https://github.com/codegen-sh/codebase-analytics","commit_stats":null,"previous_names":["codegen-sh/codebase-analytics"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/codegen-sh/codebase-analytics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codegen-sh%2Fcodebase-analytics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codegen-sh%2Fcodebase-analytics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codegen-sh%2Fcodebase-analytics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codegen-sh%2Fcodebase-analytics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codegen-sh","download_url":"https://codeload.github.com/codegen-sh/codebase-analytics/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codegen-sh%2Fcodebase-analytics/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28509941,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T13:38:16.342Z","status":"ssl_error","status_checked_at":"2026-01-17T13:37:44.060Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2026-01-17T14:13:41.388Z","updated_at":"2026-01-17T14:13:41.784Z","avatar_url":"https://github.com/codegen-sh.png","language":"TypeScript","readme":"# Codebase Analytics\n\nA web application that provides comprehensive analytics for GitHub repositories.  The project combines a Modal-based FastAPI backend with a Next.js frontend to provide efficient and beautiful codebase metrics.\n\nUsers submit a GitHub repository through the frontend. The Modal API processes the request using custom implementations of the metric calculations using the `codegen` library. Results are returned to the frontend for display.\n\n## How it Works\n\n### Backend (Modal API)\n\nThe backend is built using [Modal](https://modal.com/) and [FastAPI](https://fastapi.tiangolo.com/), providing a serverless API endpoint for code research.\n\nThere is a main API endpoint that handles codebase analysis requests. It uses the `codegen` library for these operations.\n\nThe following metrics are calculated:\n- `Maintainability Index`: Measures the maintainability of the codebase, on a scale of 0-100.\n- `Cyclomatic Complexity`: Measures the complexity of the codebase. Higher values indicate more complex code.\n- `Halstead Volume`: Quantifies the information content in the code based on operators and operands. Higher values indicate more complex code.\n- `Depth of Inheritance`: Measures the depth of inheritance of the codebase.\n- `Lines of Code (LOC, SLOC, LLOC)`: Measures the number of lines of code in the codebase. LOC, SLOC, and LLOC represent the total, source, and logical lines of code, respectively. \n- `Comment Density`: Measures the density of comments in the codebase, given as a percentage of the total lines of code. More comments can indicate better documentation.\n\n```python\ncomplexity = calculate_cyclomatic_complexity(func)\noperators, operands = get_operators_and_operands(func)\nvolume, _, _, _, _ = calculate_halstead_volume(operators, operands)\nloc = len(func.code_block.source.splitlines())\nmi_score = calculate_maintainability_index(volume, complexity, loc)\n```\n\nMonthly commit history is also pulled from the GitHub API and displayed in a chart.\n\nThe codebase is also graded on a scale of A-F for overall quality and maintainability. The complexity of the codebase is also given a qualitative rank.\n\n### Frontend (Next.js)\n\nThe frontend provides an interface for users to submit a GitHub repository and research query. The components come from the [shadcn/ui](https://ui.shadcn.com/) library. This triggers the Modal API to perform the code research and returns the results to the frontend.\n\n## Getting Started\n\n1. Set up environment variables in an `.env` file:\n   ```\n   OPENAI_API_KEY=your_key_here\n   ```\n\n2. Deploy or serve the Modal API:\n   ```bash\n   modal serve backend/api.py\n   ```\n   `modal serve` runs the API locally for development, creating a temporary endpoint that's active only while the command is running.\n   ```bash\n   modal deploy backend/api.py\n   ```\n   `modal deploy` creates a persistent Modal app and deploys the FastAPI app to it, generating a permanent API endpoint.\n   \n   After deployment, you'll need to update the API endpoint in the frontend configuration to point to your deployed Modal app URL.\n\n3. Run the Next.js frontend:\n   ```bash\n   cd frontend\n   npm install\n   npm run dev\n   ```\n\n## Learn More\n\nMore information about the `codegen` library can be found [here](https://codegen.com/).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodegen-sh%2Fcodebase-analytics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodegen-sh%2Fcodebase-analytics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodegen-sh%2Fcodebase-analytics/lists"}