# teach-hack/intern-intel architecture

> Architecture diagram of the GitHub repository teach-hack/intern-intel, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/teach-hack/intern-intel
- Repository: https://github.com/teach-hack/intern-intel

## Overview

1. **What this system is**
   - InternIntel is an internship-ingestion platform, not just an API. Its main job is to discover internships from company career pages, normalize them, store them, and notify users.

2. **Top-level execution surfaces**
   - There are three main entry points: the **HTTP API** (`app/api`), the **CLI/runtime commands** (`app/cli.py`, `app/runner.py`), and the **scheduler** (`app/scheduler.py`).
   - This suggests the app can be used both interactively through endpoints and autonomously as a background scraping pipeline.

3. **Core ingestion pipeline**
   - The central flow appears to be: **scheduler/runner → pipeline_service → scraper_service → mapper_service → dedup_service → database_service/repositories**.
   - `pipeline_service.py` likely orchestrates the whole run, while `scraper_service.py` executes company scrapers, `mapper_service.py` converts scraped payloads into internal internship models, and `dedup_service.py` prevents duplicate records.

4. **Scraping architecture**
   - `app/core/base_scraper.py` defines the shared scraper contract, and `app/scrapers/` contains one implementation per ATS/platform: Ashby, Greenhouse, iCIMS, Lever, Oracle, SmartRecruiters, SuccessFactors, and Workday.
   - This is a clear boundary between a shared scraping engine and platform-specific adapters. The repo is structured to add more company/ATS scrapers without changing the pipeline core.

5. **Shared HTTP and reliability layer**
   - `app/core/http_client.py`, `retry.py`, `retry_policy.py`, and `rate_limiter.py` indicate that scraping is network-heavy and protected against failures, throttling, and transient errors.
   - That layer is part of the infrastructure boundary: it shields scrapers from unstable external career sites.

6. **Configuration and company metadata**
   - Configuration comes from YAML and env files (`app/config/settings.yaml`, `companies.yaml`, `keywords.yaml`, `.env.example`), which matches the repository rules.
   - `app/constants/keywords.py`, `company_types.py`, and `status.py` suggest company classification and keyword-based filtering/status tracking are part of the normalization logic.
   - `app/registry.py` likely maps configured companies to the correct scraper implementation.

7. **Persistence layer**
   - Persistence is SQLAlchemy-based (`app/models`, `app/database`) with Alembic migrations (`alembic/`).
   - The domain model includes at least **users**, **refresh tokens**, and **internships**. Repositories exist for users and refresh tokens, which indicates the database layer is accessed through repository abstractions rather than directly from API routes.
   - The README rule about unique URLs aligns with deduplication at the data model or repository boundary.

8. **API layer**
   - The API is organized by router: `auth`, `health`, `internships`, `notifications`, and `pipeline`.
   - `schemas/` contains request/response DTOs, `dependencies.py` wires shared request-time concerns, and `exception_handlers.py` centralizes API error translation.
   - This layer is likely read/write over the database and may also expose operational controls for triggering or observing the pipeline.

9. **Authentication and security**
   - Auth is implemented with `users`, `refresh_tokens`, `tokens`, `pwd_context`, and `throttle`.
   - This implies a token-based auth flow with password hashing and rate limiting for sensitive endpoints.
   - The API auth subsystem is separate from the scraping pipeline, which is a useful architectural boundary.

10. **Notifications**
   - `notification_service.py`, `message_builder.py`, and `telegram.py` show a dedicated outbound notification subsystem.
   - The likely flow is: new or relevant internships are detected in the pipeline, formatted into human-readable messages, then sent through Telegram.
   - This is an external integration boundary distinct from scraping and storage.

11. **Startup and operational wiring**
   - `app/core/startup.py`, `app/core/settings.py`, `config.py`, and `config_validator.py` suggest a structured boot process that validates configuration before the app starts.
   - `app/database/session.py` and `database.py` manage connection/session lifecycle, while `app/core/logger.py` provides centralized logging via Loguru.

12. **Testing and quality gates**
   - The repo has strong test coverage across API, scrapers, services, retries, scheduler, startup, and migrations.
   - This indicates the architecture is intentionally modular: each major subsystem has isolated tests, which is consistent with the repository’s single-responsibility layout.

13. **How to draw the architecture**
   - A good diagram would place **external career platforms** on the left, feeding into **platform-specific scrapers** and the **shared HTTP/retry/rate-limit core**.
   - In the center, show the **pipeline services** performing mapping, deduplication, and persistence.
   - On the right, show **PostgreSQL/SQLAlchemy-backed storage** and a separate **Telegram notification path**.
   - Above or alongside that, show the **FastAPI API** for auth, internships, health, notifications, and pipeline control, with **CLI/scheduler** as alternate entry points into the same business logic.

14. **Key architectural constraint**
   - The repo is built around avoiding duplicated business logic: web requests, background jobs, and scrapers are all meant to reuse the same core services and repositories rather than implement their own data flow.

Main entry points: [`app/services/pipeline_service.py`](https://github.com/teach-hack/intern-intel/blob/main/app/services/pipeline_service.py) (Pipeline), [`app/api/app.py`](https://github.com/teach-hack/intern-intel/blob/main/app/api/app.py) (API app), [`app/services/scraper_service.py`](https://github.com/teach-hack/intern-intel/blob/main/app/services/scraper_service.py) (Scraping), [`app/database/repository.py`](https://github.com/teach-hack/intern-intel/blob/main/app/database/repository.py) (Repositories)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entrypoints["Entry points"]
  node_cli["CLI<br/>command entry<br/>[cli.py]"]
  node_runner["Runner<br/>runtime command<br/>[runner.py]"]
  node_scheduler["Scheduler<br/>job runner<br/>[scheduler.py]"]
end

subgraph group_ingestion["Ingestion pipeline"]
  node_pipeline_service["Pipeline<br/>orchestration service"]
  node_scraper_service["Scraping<br/>orchestration service<br/>[scraper_service.py]"]
  node_mapper_service["Mapping<br/>transform service<br/>[mapper_service.py]"]
  node_dedup_service["Deduplication<br/>domain service<br/>[dedup_service.py]"]
  node_database_service["Persistence<br/>domain service"]
end

subgraph group_scraping["Scraping adapters"]
  node_base_scraper["Scraper base<br/>scraper contract<br/>[base_scraper.py]"]
  node_ats_scrapers["ATS scrapers<br/>platform adapters<br/>[ashby.py]"]
  node_http_retry["HTTP reliability<br/>infra layer<br/>[http_client.py]"]
end

subgraph group_api["HTTP API"]
  node_api_app["API app<br/>[app.py]"]
  node_auth_router["Auth<br/>API router<br/>[auth.py]"]
  node_internships_router["Internships<br/>API router<br/>[internships.py]"]
  node_pipeline_router["Pipeline<br/>API router<br/>[pipeline.py]"]
  node_notification_router["Notifications<br/>API router<br/>[notifications.py]"]
end

subgraph group_storage["Storage"]
  node_database[("Database<br/>SQLAlchemy + repos<br/>[database.py]")]
  node_models["Domain models<br/>ORM models<br/>[internship.py]"]
  node_repositories["Repositories<br/>data access<br/>[repository.py]"]
end

subgraph group_ops["Ops and integration"]
  node_notification_service["Notifications<br/>outbound service"]
  node_telegram["Telegram<br/>integration<br/>[telegram.py]"]
  node_startup_config["Startup config<br/>boot and config<br/>[startup.py]"]
  node_security["Security<br/>auth support<br/>[tokens.py]"]
end

node_cli -->|"run"| node_pipeline_service
node_runner -->|"execute"| node_pipeline_service
node_scheduler -->|"schedule"| node_pipeline_service
node_pipeline_router -->|"control"| node_pipeline_service
node_pipeline_service -->|"collect"| node_scraper_service
node_scraper_service -->|"contract"| node_base_scraper
node_scraper_service -->|"adapters"| node_ats_scrapers
node_ats_scrapers -->|"fetch"| node_http_retry
node_pipeline_service -->|"normalize"| node_mapper_service
node_pipeline_service -->|"filter"| node_dedup_service
node_pipeline_service -->|"persist"| node_database_service
node_database_service -->|"access"| node_repositories
node_repositories -->|"store"| node_database
node_database -->|"map"| node_models
node_api_app -->|"mount"| node_auth_router
node_api_app -->|"mount"| node_internships_router
node_api_app -->|"mount"| node_pipeline_router
node_api_app -->|"mount"| node_notification_router
node_auth_router -->|"protect"| node_security
node_internships_router -->|"query"| node_repositories
node_notification_service -->|"send"| node_telegram
node_pipeline_service -->|"alert"| node_notification_service
node_startup_config -->|"boot"| node_api_app
node_startup_config -->|"boot"| node_scheduler

click node_api_app "https://github.com/teach-hack/intern-intel/blob/main/app/api/app.py"
click node_auth_router "https://github.com/teach-hack/intern-intel/blob/main/app/api/routers/auth.py"
click node_internships_router "https://github.com/teach-hack/intern-intel/blob/main/app/api/routers/internships.py"
click node_pipeline_router "https://github.com/teach-hack/intern-intel/blob/main/app/api/routers/pipeline.py"
click node_notification_router "https://github.com/teach-hack/intern-intel/blob/main/app/api/routers/notifications.py"
click node_cli "https://github.com/teach-hack/intern-intel/blob/main/app/cli.py"
click node_runner "https://github.com/teach-hack/intern-intel/blob/main/app/runner.py"
click node_scheduler "https://github.com/teach-hack/intern-intel/blob/main/app/scheduler.py"
click node_pipeline_service "https://github.com/teach-hack/intern-intel/blob/main/app/services/pipeline_service.py"
click node_scraper_service "https://github.com/teach-hack/intern-intel/blob/main/app/services/scraper_service.py"
click node_mapper_service "https://github.com/teach-hack/intern-intel/blob/main/app/services/mapper_service.py"
click node_dedup_service "https://github.com/teach-hack/intern-intel/blob/main/app/services/dedup_service.py"
click node_database_service "https://github.com/teach-hack/intern-intel/blob/main/app/services/database_service.py"
click node_base_scraper "https://github.com/teach-hack/intern-intel/blob/main/app/core/base_scraper.py"
click node_ats_scrapers "https://github.com/teach-hack/intern-intel/blob/main/app/scrapers/ashby.py"
click node_http_retry "https://github.com/teach-hack/intern-intel/blob/main/app/core/http_client.py"
click node_database "https://github.com/teach-hack/intern-intel/blob/main/app/database/database.py"
click node_models "https://github.com/teach-hack/intern-intel/blob/main/app/models/internship.py"
click node_repositories "https://github.com/teach-hack/intern-intel/blob/main/app/database/repository.py"
click node_notification_service "https://github.com/teach-hack/intern-intel/blob/main/app/notifications/notification_service.py"
click node_telegram "https://github.com/teach-hack/intern-intel/blob/main/app/notifications/telegram.py"
click node_startup_config "https://github.com/teach-hack/intern-intel/blob/main/app/core/startup.py"
click node_security "https://github.com/teach-hack/intern-intel/blob/main/app/security/tokens.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_runner,node_scheduler toneBlue
class node_pipeline_service,node_scraper_service,node_mapper_service,node_dedup_service,node_database_service toneAmber
class node_base_scraper,node_ats_scrapers,node_http_retry toneMint
class node_api_app,node_auth_router,node_internships_router,node_pipeline_router,node_notification_router toneRose
class node_database,node_models,node_repositories toneIndigo
class node_notification_service,node_telegram,node_startup_config,node_security toneTeal
```

## Components

### Entry points

Ways the system starts or is triggered.

- [CLI](https://github.com/teach-hack/intern-intel/blob/main/app/cli.py): command entry · Command-line entry point for manual execution. · `app/cli.py`
- [Runner](https://github.com/teach-hack/intern-intel/blob/main/app/runner.py): runtime command · Background execution entry that drives the pipeline. · `app/runner.py`
- [Scheduler](https://github.com/teach-hack/intern-intel/blob/main/app/scheduler.py): job runner · Automated trigger for recurring pipeline runs. · `app/scheduler.py`

### Ingestion pipeline

Shared services that discover, normalize, deduplicate, and persist internships.

- [Pipeline](https://github.com/teach-hack/intern-intel/blob/main/app/services/pipeline_service.py): orchestration service · Coordinates scraping, mapping, deduplication, persistence, and downstream actions. · `app/services/pipeline_service.py`
- [Scraping](https://github.com/teach-hack/intern-intel/blob/main/app/services/scraper_service.py): orchestration service · Selects and executes the configured scraper implementations. · `app/services/scraper_service.py`
- [Mapping](https://github.com/teach-hack/intern-intel/blob/main/app/services/mapper_service.py): transform service · Converts scraped payloads into normalized internship records. · `app/services/mapper_service.py`
- [Deduplication](https://github.com/teach-hack/intern-intel/blob/main/app/services/dedup_service.py): domain service · Prevents duplicate internship records from entering storage. · `app/services/dedup_service.py`
- [Persistence](https://github.com/teach-hack/intern-intel/blob/main/app/services/database_service.py): domain service · Writes normalized data through repositories and session-backed storage. · `app/services/database_service.py`

### Scraping adapters

Shared scraper base plus ATS/platform-specific implementations.

- [Scraper base](https://github.com/teach-hack/intern-intel/blob/main/app/core/base_scraper.py): scraper contract · Shared interface and common scraper behavior. · `app/core/base_scraper.py`
- [ATS scrapers](https://github.com/teach-hack/intern-intel/blob/main/app/scrapers/ashby.py): platform adapters · Company-platform implementations for Ashby, Greenhouse, iCIMS, Lever, Oracle, SmartRecruiters, SuccessFactors, and Workday. · `app/scrapers/ashby.py`
- [HTTP reliability](https://github.com/teach-hack/intern-intel/blob/main/app/core/http_client.py): infra layer · HTTP client, retries, retry policy, and rate limiting for resilient scraping. · `app/core/http_client.py`

### HTTP API

FastAPI routers, schemas, and request-time wiring.

- [API app](https://github.com/teach-hack/intern-intel/blob/main/app/api/app.py): FastAPI app · Application wiring for the HTTP server and router registration. · `app/api/app.py`
- [Auth](https://github.com/teach-hack/intern-intel/blob/main/app/api/routers/auth.py): API router · Authentication endpoints and token-based access control. · `app/api/routers/auth.py`
- [Internships](https://github.com/teach-hack/intern-intel/blob/main/app/api/routers/internships.py): API router · Read/write internship endpoints over the domain model. · `app/api/routers/internships.py`
- [Pipeline](https://github.com/teach-hack/intern-intel/blob/main/app/api/routers/pipeline.py): API router · Operational endpoints for triggering or observing ingestion. · `app/api/routers/pipeline.py`
- [Notifications](https://github.com/teach-hack/intern-intel/blob/main/app/api/routers/notifications.py): API router · Endpoints related to outbound notification behavior. · `app/api/routers/notifications.py`

### Storage

Database models, repositories, sessions, and migrations.

- [Database](https://github.com/teach-hack/intern-intel/blob/main/app/database/database.py): SQLAlchemy + repos · Models, repositories, sessions, and migration-managed persistence. · `app/database/database.py`
- [Domain models](https://github.com/teach-hack/intern-intel/blob/main/app/models/internship.py): ORM models · Internship, user, and refresh token entities. · `app/models/internship.py`
- [Repositories](https://github.com/teach-hack/intern-intel/blob/main/app/database/repository.py): data access · User and refresh-token repository abstractions over the database. · `app/database/repository.py`

### Ops and integration

Startup, config, logging, security, and outbound notifications.

- [Notifications](https://github.com/teach-hack/intern-intel/blob/main/app/notifications/notification_service.py): outbound service · Formats and sends internship alerts. · `app/notifications/notification_service.py`
- [Telegram](https://github.com/teach-hack/intern-intel/blob/main/app/notifications/telegram.py): integration · External messaging delivery channel for alerts. · `app/notifications/telegram.py`
- [Startup config](https://github.com/teach-hack/intern-intel/blob/main/app/core/startup.py): boot and config · Configuration loading, validation, startup wiring, and logging. · `app/core/startup.py`
- [Security](https://github.com/teach-hack/intern-intel/blob/main/app/security/tokens.py): auth support · Password hashing, tokens, and throttle controls used by the API. · `app/security/tokens.py`

## Connections

- CLI → Pipeline: run · Manual command invokes the shared ingestion pipeline.
- Runner → Pipeline: execute · Runtime entry drives the same pipeline logic.
- Scheduler → Pipeline: schedule · Scheduled jobs trigger pipeline runs.
- Pipeline → Pipeline: control · API can trigger or observe pipeline execution.
- Pipeline → Scraping: collect · Pipeline asks for internships from configured scrapers.
- Scraping → Scraper base: contract · Scraper execution is built around the shared scraper interface.
- Scraping → ATS scrapers: adapters · Platform-specific scraper implementations are selected here.
- ATS scrapers → HTTP reliability: fetch · Scrapers rely on the HTTP/retry/rate-limit layer.
- Pipeline → Mapping: normalize · Scraped payloads are converted into canonical internship records.
- Pipeline → Deduplication: filter · Duplicate records are removed before persistence.
- Pipeline → Persistence: persist · Normalized records are written to storage.
- Persistence → Repositories: access · Persistence goes through repository abstractions.
- Repositories → Database: store · Repositories operate over SQLAlchemy-backed storage.
- Database → Domain models: map · ORM models define the persisted domain schema.
- API app → Auth: mount · Application registers auth routes.
- API app → Internships: mount · Application registers internship routes.
- API app → Pipeline: mount · Application registers pipeline control routes.
- API app → Notifications: mount · Application registers notification routes.
- Auth → Security: protect · Auth endpoints use token, password, and throttling utilities.
- Internships → Repositories: query · API reads and writes through repositories.
- Notifications → Telegram: send · Notifications are delivered through Telegram.
- Pipeline → Notifications: alert · New or relevant internships can trigger outbound notifications.
- Startup config → API app: boot · Configuration and startup wiring initialize the HTTP app.
- Startup config → Scheduler: boot · Startup also prepares background scheduling.
