About ArchLens
A FastAPI web app, a REST API and a CLI that share one service layer, backed by the GitHub REST API and SQLite.
The problem it solves
Before you depend on a library or contribute to a project, you usually click around its repository for a while. Is there a license? Tests? CI? When was the last commit? How many issues are open?
ArchLens runs that checklist in one request, scores it out of 100 and explains every point, so the result is something you can check rather than take on trust. It is useful for choosing a dependency, sizing up a project before contributing, or finding the gaps in your own repository.
Architecture
GitHubService talks to GitHub,
and analyses are stored through RepositoryService. Dashed boxes are external systems.
Each user and system flow is written up, with diagrams, in
docs/process-flows.md.
Tech stack
| Language | Python 3.11+ |
|---|---|
| Web framework | FastAPI (async), server-rendered Jinja2 templates |
| GitHub client | httpx AsyncClient, calls run concurrently with asyncio.gather |
| Storage | SQLite by default (PostgreSQL optional) through SQLAlchemy 2, schema migrations with Alembic |
| Vulnerability data | OSV.dev (free, no key); if it cannot be reached the report says “couldn’t check” |
| Command line | Typer and Rich |
| Front end | Plain CSS, inline SVG charts and one vanilla JavaScript file; no build step |
| Quality | pytest with GitHub mocked, Ruff, Black, GitHub Actions |
| Deployment | Multi-stage Docker image running as a non-root user; Render Blueprint |
Key design decisions
-
One shared HTTP client
A single
httpx.AsyncClientis opened when the app starts and closed when it stops. The six GitHub requests of an analysis run concurrently and reuse its pooled connections instead of each paying for a new TLS handshake. -
Real progress, not a timer
The analysis reports each step to a callback.
POST /api/v1/analyze/streamforwards those events as newline-delimited JSON, and the home page lights up its “How it works” steps as each GitHub call finishes. A report’s “Analyze again” runs through the same steps. Without JavaScript the form still posts normally. -
Protecting the GitHub quota
Asking for the same repository and profile again within 60 minutes reuses the stored report, and that reuse is free. Each visitor can start 5 new analyses per 10 minutes (a sliding window keyed by IP); one that fails because GitHub is down or out of quota is given back. When one GitHub call fails, the others are cancelled. The badge never calls GitHub, and the compare page uses stored reports first.
-
Seeded example reports
The free hosting tier wipes the disk on every restart, which would greet visitors with an empty site. Real analyses captured earlier are bundled with the app and loaded into an empty database, labelled with the date they were captured.
-
Scoring rules as data
Every point value, threshold and file name is a named constant. The scorer applies them, the scoring page renders them, and each report lines its findings up with the same checks. Tests run the real scorer against both, so the explanation cannot drift from the code.
-
One error vocabulary
Each failure (bad input, unknown repository, empty repository, rate limits, GitHub outages) is an exception class with its own HTTP status and error code. The API returns them as JSON, the progress stream sends them as an error event, and the pages show the same message next to the form.
Limitations
- Metadata and dependency files only. ArchLens reads repository statistics, the root file listing and the dependency files in the root. It does not read source files, run tests or measure coverage.
- Heuristics, not ground truth. A file earns points by existing, whatever its quality, and stars are a weak proxy for health. Read a low score as a list of things to look at.
- Capped counts. Contributors and recent commits come from one page of GitHub results, so they stop at 100.
- Single instance. The rate limiter lives in memory, resets on restart and trusts the
X-Forwarded-Forheader, which a determined client can forge. - Renames are learned, not looked up. An old name of a renamed repository finds the new one’s reports only after someone has analyzed it under the old name once.
- Ephemeral demo storage. On the free host the SQLite file resets when the service restarts. Example reports come back; other reports, and the badges that point at them, return after someone analyzes the repository again.
- GitHub limits. Without a token GitHub allows 60 requests an hour, which is five to ten analyses (each uses six requests, plus one for each dependency file it finds).