# priyank766/tross architecture

> Architecture diagram of the GitHub repository priyank766/tross, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/priyank766/tross
- Repository: https://github.com/priyank766/tross

## Overview

#### Purpose and Entrypoints
A browserless LinkedIn profile-read service. It accepts a LinkedIn URL/vanity name, calls LinkedIn Voyager APIs using a server-held member session, and returns a normalized JSON profile with provenance and partial-data warnings.

- ASGI app: `app/main.py`
- CLI lookup command: `app/cli.py`
- React evaluation console: `web/src/main.tsx`, `web/src/App.tsx`

#### HTTP Boundary
FastAPI routes expose profile retrieval, health/readiness, session diagnostics, and optionally raw upstream payloads. Middleware/error handling provides request IDs, timings, stable error envelopes, API-key authentication, and per-client/key fixed-window limiting before service calls.

- `app/api/routes/profile.py`
- `app/api/routes/system.py`
- `app/api/errors.py`
- `app/api/security.py`
- `app/api/ratelimit.py`

#### Profile Orchestration and Cache
The service canonicalizes profile identifiers, checks a TTL/LRU cache, and coalesces simultaneous misses for the same profile. A refresh bypasses cache. Successful assembled documents receive cache metadata; upstream failures are translated into API-level errors.

- `app/services/profile_service.py`
- `app/services/cache.py`
- `app/linkedin/urls.py`

#### LinkedIn Session and Transport
The integration owns LinkedIn-specific HTTP concerns: session cookies and CSRF headers, optional password fallback, persisted cookie rotation, HTTP/2 requests, proxy support, retries, and status-to-domain-exception mapping. Each client session pairs with pacing, concurrency limits, and a circuit breaker to protect the scarce upstream account budget.

- `app/linkedin/auth.py`
- `app/linkedin/session.py`
- `app/linkedin/client.py`
- `app/linkedin/throttle.py`
- `app/linkedin/exceptions.py`

#### Upstream Retrieval Strategy
`repository` attempts progressively compatible profile sources: decorated Dash profile collection, minimal Dash variant, configured GraphQL, then legacy profile projection. It stops on a populated profile. Optional contact, skills, and network enrichment calls execute concurrently and degrade to warnings instead of failing the entire profile.

- `app/linkedin/repository.py`
- `app/linkedin/endpoints.py`
- `app/linkedin/normalized.py`

#### Transformation and Public Contract
Raw Dash embedded trees and GraphQL normalized entity graphs are converted to a shared draft, then assembled into the published Pydantic response schema. Parsers remain pure and isolated from FastAPI and transport code. Output standardizes names, dates, images, URNs, nullability, populated sections, source-call results, warnings, and completeness.

- `app/linkedin/parsers/dash.py`
- `app/linkedin/parsers/draft.py`
- `app/linkedin/parsers/assembler.py`
- `app/models/profile.py`
- `app/models/responses.py`

#### Runtime and Deployment
Python/FastAPI runs the API; the frontend is a Vite/React build served from the application image. Typed environment settings are centralized, including LinkedIn cookies, API keys, cache/throttle limits, proxy, and raw-endpoint exposure. Docker builds Node assets and Python runtime into one container; Fly and Render manifests support persistent session/cache storage.

- `app/config.py`
- `Dockerfile`
- `docker-compose.yml`
- `fly.toml`
- `render.yaml`

Main entry points: [`app/services/profile_service.py`](https://github.com/priyank766/tross/blob/main/app/services/profile_service.py) (Profile orchestration), [`app/linkedin/client.py`](https://github.com/priyank766/tross/blob/main/app/linkedin/client.py) (Voyager client session), [`app/main.py`](https://github.com/priyank766/tross/blob/main/app/main.py) (ASGI application), [`app/api/security.py`](https://github.com/priyank766/tross/blob/main/app/api/security.py) (API guardrails)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Clients"]
  node_web["React evaluation console<br/>React/Vite<br/>[App.tsx]"]
  node_cli["CLI lookup<br/>[cli.py]"]
end

subgraph group_api["API Runtime"]
  node_app["ASGI application<br/>FastAPI<br/>[main.py]"]
  node_profile_routes["Profile routes<br/>HTTP routes<br/>[profile.py]"]
  node_system_routes["System routes<br/>HTTP routes<br/>[system.py]"]
  node_api_guardrails["API guardrails<br/>middleware<br/>[security.py]"]
end

subgraph group_service["Profile Service"]
  node_profile_service["Profile orchestration<br/>[profile_service.py]"]
  node_profile_cache[("TTL/LRU profile cache<br/>[cache.py]")]
  node_url_canonicalizer["LinkedIn URL canonicalizer<br/>identifier normalization<br/>[urls.py]"]
end

subgraph group_linkedin["LinkedIn Integration"]
  node_repository["Retrieval repository<br/>upstream strategy<br/>[repository.py]"]
  node_linkedin_client["Voyager client session<br/>HTTP/2 transport<br/>[client.py]"]
  node_session_auth["Session authentication<br/>session lifecycle<br/>[auth.py]"]
  node_voyager_api{{"LinkedIn Voyager APIs<br/>external upstream"}}
end

subgraph group_transform["Transformation &amp; Contract"]
  node_parsers["Dash and GraphQL parsers<br/>pure transformation<br/>[dash.py]"]
  node_assembler["Profile assembler<br/>response assembly<br/>[assembler.py]"]
  node_profile_contract["Published profile contract<br/>Pydantic schema<br/>[profile.py]"]
end

subgraph group_deploy["Deployment"]
  node_settings["Typed runtime settings<br/>configuration<br/>[config.py]"]
  node_container["Container deployment<br/>Docker runtime"]
end

node_web -->|"HTTP requests"| node_app
node_cli -->|"lookup"| node_profile_service
node_app -->|"applies"| node_api_guardrails
node_api_guardrails -->|"protects"| node_profile_routes
node_api_guardrails -->|"protects"| node_system_routes
node_profile_routes -->|"retrieve profile"| node_profile_service
node_profile_service -->|"canonicalizes"| node_url_canonicalizer
node_profile_service -->|"checks and stores"| node_profile_cache
node_profile_service -->|"cache miss / refresh"| node_repository
node_repository -->|"progressive source calls"| node_linkedin_client
node_linkedin_client -->|"uses session"| node_session_auth
node_linkedin_client -->|"Voyager requests"| node_voyager_api
node_repository -->|"raw source payloads"| node_parsers
node_parsers -->|"shared draft"| node_assembler
node_assembler -->|"normalized response"| node_profile_contract
node_profile_service -->|"returns"| node_profile_contract
node_settings -.->|"configures"| node_app
node_settings -.->|"credentials and limits"| node_linkedin_client
node_container -->|"runs"| node_app
node_container -->|"serves built assets"| node_web

click node_web "https://github.com/priyank766/tross/blob/main/web/src/App.tsx"
click node_cli "https://github.com/priyank766/tross/blob/main/app/cli.py"
click node_app "https://github.com/priyank766/tross/blob/main/app/main.py"
click node_profile_routes "https://github.com/priyank766/tross/blob/main/app/api/routes/profile.py"
click node_system_routes "https://github.com/priyank766/tross/blob/main/app/api/routes/system.py"
click node_api_guardrails "https://github.com/priyank766/tross/blob/main/app/api/security.py"
click node_profile_service "https://github.com/priyank766/tross/blob/main/app/services/profile_service.py"
click node_profile_cache "https://github.com/priyank766/tross/blob/main/app/services/cache.py"
click node_url_canonicalizer "https://github.com/priyank766/tross/blob/main/app/linkedin/urls.py"
click node_repository "https://github.com/priyank766/tross/blob/main/app/linkedin/repository.py"
click node_linkedin_client "https://github.com/priyank766/tross/blob/main/app/linkedin/client.py"
click node_session_auth "https://github.com/priyank766/tross/blob/main/app/linkedin/auth.py"
click node_parsers "https://github.com/priyank766/tross/blob/main/app/linkedin/parsers/dash.py"
click node_assembler "https://github.com/priyank766/tross/blob/main/app/linkedin/parsers/assembler.py"
click node_profile_contract "https://github.com/priyank766/tross/blob/main/app/models/profile.py"
click node_settings "https://github.com/priyank766/tross/blob/main/app/config.py"
click node_container "https://github.com/priyank766/tross/blob/main/Dockerfile"

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_web,node_cli toneBlue
class node_app,node_profile_routes,node_system_routes,node_api_guardrails toneAmber
class node_profile_service,node_profile_cache,node_url_canonicalizer toneMint
class node_repository,node_linkedin_client,node_session_auth,node_voyager_api toneRose
class node_parsers,node_assembler,node_profile_contract toneIndigo
class node_settings,node_container toneTeal
```

## Components

### Clients

- [React evaluation console](https://github.com/priyank766/tross/blob/main/web/src/App.tsx): React/Vite · `web/src/App.tsx`
- [CLI lookup](https://github.com/priyank766/tross/blob/main/app/cli.py): CLI · `app/cli.py`

### API Runtime

- [ASGI application](https://github.com/priyank766/tross/blob/main/app/main.py): FastAPI · `app/main.py`
- [Profile routes](https://github.com/priyank766/tross/blob/main/app/api/routes/profile.py): HTTP routes · `app/api/routes/profile.py`
- [System routes](https://github.com/priyank766/tross/blob/main/app/api/routes/system.py): HTTP routes · Health, readiness, diagnostics, and optional raw payloads. · `app/api/routes/system.py`
- [API guardrails](https://github.com/priyank766/tross/blob/main/app/api/security.py): middleware · Authentication, rate limits, request context, and stable errors. · `app/api/security.py`

### Profile Service

- [Profile orchestration](https://github.com/priyank766/tross/blob/main/app/services/profile_service.py): service · Canonicalizes identifiers, coalesces misses, and translates upstream failures. · `app/services/profile_service.py`
- [TTL/LRU profile cache](https://github.com/priyank766/tross/blob/main/app/services/cache.py): cache · `app/services/cache.py`
- [LinkedIn URL canonicalizer](https://github.com/priyank766/tross/blob/main/app/linkedin/urls.py): identifier normalization · `app/linkedin/urls.py`

### LinkedIn Integration

- [Retrieval repository](https://github.com/priyank766/tross/blob/main/app/linkedin/repository.py): upstream strategy · Falls back across Dash, GraphQL, and legacy profile sources. · `app/linkedin/repository.py`
- [Voyager client session](https://github.com/priyank766/tross/blob/main/app/linkedin/client.py): HTTP/2 transport · Applies cookies, CSRF, retries, proxying, pacing, concurrency limits, and circuit breaking. · `app/linkedin/client.py`
- [Session authentication](https://github.com/priyank766/tross/blob/main/app/linkedin/auth.py): session lifecycle · Maintains and rotates persisted cookies with optional password fallback. · `app/linkedin/auth.py`
- **LinkedIn Voyager APIs**: external upstream

### Transformation & Contract

- [Dash and GraphQL parsers](https://github.com/priyank766/tross/blob/main/app/linkedin/parsers/dash.py): pure transformation · Converts embedded trees and normalized graphs into a shared draft. · `app/linkedin/parsers/dash.py`
- [Profile assembler](https://github.com/priyank766/tross/blob/main/app/linkedin/parsers/assembler.py): response assembly · Standardizes populated sections, provenance, warnings, and completeness. · `app/linkedin/parsers/assembler.py`
- [Published profile contract](https://github.com/priyank766/tross/blob/main/app/models/profile.py): Pydantic schema · `app/models/profile.py`

### Deployment

- [Typed runtime settings](https://github.com/priyank766/tross/blob/main/app/config.py): configuration · Centralizes credentials, limits, proxy, and raw-endpoint exposure. · `app/config.py`
- [Container deployment](https://github.com/priyank766/tross/blob/main/Dockerfile): Docker runtime · Builds React assets and Python API into one image. · `Dockerfile`

## Connections

- React evaluation console → ASGI application: HTTP requests
- CLI lookup → Profile orchestration: lookup
- ASGI application → API guardrails: applies
- API guardrails → Profile routes: protects
- API guardrails → System routes: protects
- Profile routes → Profile orchestration: retrieve profile
- Profile orchestration → LinkedIn URL canonicalizer: canonicalizes
- Profile orchestration → TTL/LRU profile cache: checks and stores
- Profile orchestration → Retrieval repository: cache miss / refresh
- Retrieval repository → Voyager client session: progressive source calls
- Voyager client session → Session authentication: uses session
- Voyager client session → LinkedIn Voyager APIs: Voyager requests
- Retrieval repository → Dash and GraphQL parsers: raw source payloads
- Dash and GraphQL parsers → Profile assembler: shared draft
- Profile assembler → Published profile contract: normalized response
- Profile orchestration → Published profile contract: returns
- Typed runtime settings → ASGI application: configures
- Typed runtime settings → Voyager client session: credentials and limits
- Container deployment → ASGI application: runs
- Container deployment → React evaluation console: serves built assets
