# rishav9142/shortiq architecture

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

- Interactive diagram: https://gitdiagram.com/rishav9142/shortiq
- Repository: https://github.com/rishav9142/shortiq

## Overview

ShortIQ is a full-stack link-shortening and click-analytics platform. Users authenticate with Google or as guests, create and manage links in the dashboard, then visitors resolve aliases through the redirect endpoint; click context is queued and persisted asynchronously for dashboard analytics. The graph follows the excerpted server routes and module references. Analytics presentation, schema details, and documented capabilities are retained where supported; relationships stated only in the README are marked with README evidence.

Main entry points: [`server.ts`](https://github.com/rishav9142/shortiq/blob/main/server.ts) (HTTP API and redirects), [`src/db/index.ts`](https://github.com/rishav9142/shortiq/blob/main/src/db/index.ts) (Database access), [`src/App.tsx`](https://github.com/rishav9142/shortiq/blob/main/src/App.tsx) (Auth app), [`src/components/Dashboard.tsx`](https://github.com/rishav9142/shortiq/blob/main/src/components/Dashboard.tsx) (Link dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_app["Auth app<br/>[App.tsx]"]
  node_dashboard["Link dashboard<br/>[Dashboard.tsx]"]
  node_analytics_view["Analytics view<br/>[AnalyticsView.tsx]"]
end

subgraph group_api["API workflows"]
  node_server["HTTP API and redirects<br/>[server.ts]"]
end

subgraph group_infra["Identity and infrastructure"]
  node_firebase_client["Firebase client auth<br/>[firebase.ts]"]
  node_auth_middleware["Token verification<br/>[auth.ts]"]
  node_firebase_admin["Firebase Admin auth<br/>[firebase-admin.ts]"]
  node_rate_limit["Rate limiting<br/>[rateLimit.ts]"]
  node_redis_client["Redis adapter<br/>[redis.ts]"]
  node_redis[("Redis cache")]
  node_logger["Structured logging<br/>[logger.ts]"]
end

subgraph group_data["Persistence and analytics"]
  node_user_queries["User persistence<br/>[users.ts]"]
  node_db["Database access<br/>[index.ts]"]
  node_schema["Postgres schema<br/>[schema.ts]"]
  node_postgres[("PostgreSQL")]
  node_queue["Analytics queue<br/>[queue.ts]"]
  node_analytics_events["Click events<br/>[schema.ts]"]
end

node_user(("User"))
node_visitor(("Link visitor"))

node_user -->|"starts session"| node_app
node_app -->|"uses auth"| node_firebase_client
node_app -->|"renders"| node_dashboard
node_app -->|"syncs identity"| node_server
node_dashboard -->|"manages links"| node_server
node_dashboard -->|"renders"| node_analytics_view
node_dashboard -->|"uses auth"| node_firebase_client
node_visitor -.->|"requests alias"| node_server
node_server -->|"protects routes"| node_auth_middleware
node_server -->|"limits requests"| node_rate_limit
node_auth_middleware -->|"verifies token"| node_firebase_admin
node_server -->|"syncs and looks up"| node_user_queries
node_user_queries -->|"queries"| node_db
node_server -->|"reads and writes"| node_db
node_db -->|"uses tables"| node_schema
node_db -.->|"persists"| node_postgres
node_server -->|"caches aliases"| node_redis_client
node_rate_limit -->|"uses store"| node_redis_client
node_redis_client -->|"connects to"| node_redis
node_server -->|"enqueues clicks"| node_queue
node_queue -->|"persists events"| node_db
node_server -->|"records events"| node_logger
node_server -->|"aggregates clicks"| node_analytics_events
node_queue -->|"writes click rows"| node_analytics_events
node_analytics_view -.->|"requests analytics"| node_server

click node_app "https://github.com/rishav9142/shortiq/blob/main/src/App.tsx"
click node_firebase_client "https://github.com/rishav9142/shortiq/blob/main/src/lib/firebase.ts"
click node_dashboard "https://github.com/rishav9142/shortiq/blob/main/src/components/Dashboard.tsx"
click node_analytics_view "https://github.com/rishav9142/shortiq/blob/main/src/components/AnalyticsView.tsx"
click node_server "https://github.com/rishav9142/shortiq/blob/main/server.ts"
click node_auth_middleware "https://github.com/rishav9142/shortiq/blob/main/src/middleware/auth.ts"
click node_firebase_admin "https://github.com/rishav9142/shortiq/blob/main/src/lib/firebase-admin.ts"
click node_rate_limit "https://github.com/rishav9142/shortiq/blob/main/src/middleware/rateLimit.ts"
click node_user_queries "https://github.com/rishav9142/shortiq/blob/main/src/db/users.ts"
click node_db "https://github.com/rishav9142/shortiq/blob/main/src/db/index.ts"
click node_schema "https://github.com/rishav9142/shortiq/blob/main/src/db/schema.ts"
click node_redis_client "https://github.com/rishav9142/shortiq/blob/main/src/lib/redis.ts"
click node_queue "https://github.com/rishav9142/shortiq/blob/main/src/lib/queue.ts"
click node_logger "https://github.com/rishav9142/shortiq/blob/main/src/lib/logger.ts"
click node_analytics_events "https://github.com/rishav9142/shortiq/blob/main/src/db/schema.ts"

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_app,node_dashboard,node_analytics_view,node_user toneBlue
class node_server toneAmber
class node_firebase_client,node_auth_middleware,node_firebase_admin,node_rate_limit,node_redis_client,node_redis,node_logger toneMint
class node_user_queries,node_db,node_schema,node_postgres,node_queue,node_analytics_events toneRose
class node_visitor toneIndigo
```

## Components

### Client experience

- [Auth app](https://github.com/rishav9142/shortiq/blob/main/src/App.tsx): `src/App.tsx`
- [Link dashboard](https://github.com/rishav9142/shortiq/blob/main/src/components/Dashboard.tsx): `src/components/Dashboard.tsx`
- [Analytics view](https://github.com/rishav9142/shortiq/blob/main/src/components/AnalyticsView.tsx): `src/components/AnalyticsView.tsx`

### API workflows

- [HTTP API and redirects](https://github.com/rishav9142/shortiq/blob/main/server.ts): `server.ts`

### Identity and infrastructure

- [Firebase client auth](https://github.com/rishav9142/shortiq/blob/main/src/lib/firebase.ts): `src/lib/firebase.ts`
- [Token verification](https://github.com/rishav9142/shortiq/blob/main/src/middleware/auth.ts): `src/middleware/auth.ts`
- [Firebase Admin auth](https://github.com/rishav9142/shortiq/blob/main/src/lib/firebase-admin.ts): `src/lib/firebase-admin.ts`
- [Rate limiting](https://github.com/rishav9142/shortiq/blob/main/src/middleware/rateLimit.ts): `src/middleware/rateLimit.ts`
- [Redis adapter](https://github.com/rishav9142/shortiq/blob/main/src/lib/redis.ts): `src/lib/redis.ts`
- **Redis cache**
- [Structured logging](https://github.com/rishav9142/shortiq/blob/main/src/lib/logger.ts): `src/lib/logger.ts`

### Persistence and analytics

- [User persistence](https://github.com/rishav9142/shortiq/blob/main/src/db/users.ts): `src/db/users.ts`
- [Database access](https://github.com/rishav9142/shortiq/blob/main/src/db/index.ts): `src/db/index.ts`
- [Postgres schema](https://github.com/rishav9142/shortiq/blob/main/src/db/schema.ts): `src/db/schema.ts`
- **PostgreSQL**
- [Analytics queue](https://github.com/rishav9142/shortiq/blob/main/src/lib/queue.ts): `src/lib/queue.ts`
- [Click events](https://github.com/rishav9142/shortiq/blob/main/src/db/schema.ts): `src/db/schema.ts`

### Other components

- **User**
- **Link visitor**

## Connections

- User → Auth app: starts session (evidence: `src/App.tsx`)
- Auth app → Firebase client auth: uses auth (evidence: `src/App.tsx`)
- Auth app → Link dashboard: renders (evidence: `src/App.tsx`)
- Auth app → HTTP API and redirects: syncs identity (evidence: `src/App.tsx`)
- Link dashboard → HTTP API and redirects: manages links (evidence: `src/components/Dashboard.tsx`)
- Link dashboard → Analytics view: renders (evidence: `src/components/Dashboard.tsx`)
- Link dashboard → Firebase client auth: uses auth (evidence: `src/components/Dashboard.tsx`)
- Link visitor → HTTP API and redirects: requests alias (evidence: `README.md`)
- HTTP API and redirects → Token verification: protects routes (evidence: `server.ts`)
- HTTP API and redirects → Rate limiting: limits requests (evidence: `server.ts`)
- Token verification → Firebase Admin auth: verifies token (evidence: `src/middleware/auth.ts`)
- HTTP API and redirects → User persistence: syncs and looks up (evidence: `server.ts`)
- User persistence → Database access: queries (evidence: `src/db/users.ts`)
- HTTP API and redirects → Database access: reads and writes (evidence: `server.ts`)
- Database access → Postgres schema: uses tables (evidence: `src/db/index.ts`)
- Database access → PostgreSQL: persists (evidence: `README.md`)
- HTTP API and redirects → Redis adapter: caches aliases (evidence: `server.ts`)
- Rate limiting → Redis adapter: uses store (evidence: `src/middleware/rateLimit.ts`)
- Redis adapter → Redis cache: connects to (evidence: `src/lib/redis.ts`)
- HTTP API and redirects → Analytics queue: enqueues clicks (evidence: `server.ts`)
- Analytics queue → Database access: persists events (evidence: `src/lib/queue.ts`)
- HTTP API and redirects → Structured logging: records events (evidence: `server.ts`)
- HTTP API and redirects → Click events: aggregates clicks (evidence: `server.ts`)
- Analytics queue → Click events: writes click rows (evidence: `src/lib/queue.ts`)
- Analytics view → HTTP API and redirects: requests analytics
