# fiqqar/url-shortener-platform architecture

> Architecture diagram of the GitHub repository fiqqar/url-shortener-platform, 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/fiqqar/url-shortener-platform
- Repository: https://github.com/fiqqar/url-shortener-platform

## Overview

This repository implements a FastAPI URL-shortening service. Clients create short links, follow redirects, and retrieve link information or click analytics; Redis stores URL mappings, a sequence counter, and click counts. The graph follows the documented route-to-service workflow and sampled calls. The README is brief, and unsampled files are not treated as evidence for additional product capabilities.

Main entry points: [`backend/app/main.py`](https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/main.py) (FastAPI app), [`backend/app/api/urls.py`](https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/api/urls.py) (URL endpoints), [`backend/app/services/url_service.py`](https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/services/url_service.py) (URL operations), [`backend/app/core/redis.py`](https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/core/redis.py) (Redis connection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application Runtime"]
  node_app["FastAPI app<br/>[main.py]"]
  node_middleware["Request middleware<br/>[middleware.py]"]
  node_logging["Logging setup<br/>[logging.py]"]
  node_config["Settings<br/>[config.py]"]
end

subgraph group_http["HTTP Interface"]
  node_url_routes["URL endpoints<br/>[urls.py]"]
  node_health["Health endpoint<br/>[health.py]"]
  node_dependencies["Redis dependency<br/>[dependencies.py]"]
  node_schemas["URL schemas<br/>[urls.py]"]
end

subgraph group_domain["URL Domain"]
  node_validation["Input validation<br/>[validation.py]"]
  node_url_service["URL operations<br/>[url_service.py]"]
  node_base62["Code encoding<br/>[base62.py]"]
end

subgraph group_storage["Redis Storage"]
  node_repository["URL repository<br/>[url_repository.py]"]
  node_redis_manager["Redis connection<br/>[redis.py]"]
end

node_client(("API clients"))
node_redis[("Redis")]

node_client -->|"sends requests"| node_app
node_app -->|"mounts routers"| node_url_routes
node_app -->|"mounts router"| node_health
node_app -->|"reads settings"| node_config
node_app -->|"starts and closes"| node_redis_manager
node_app -->|"registers middleware"| node_middleware
node_app -->|"configures logging"| node_logging
node_middleware -->|"logs requests"| node_logging
node_url_routes -->|"injects client"| node_dependencies
node_url_routes -->|"validates and responds"| node_schemas
node_url_routes -->|"checks codes"| node_validation
node_url_routes -->|"calls operations"| node_url_service
node_url_routes -->|"reads base URL"| node_config
node_dependencies -->|"gets client"| node_redis_manager
node_health -->|"checks Redis"| node_redis_manager
node_url_service -->|"validates URLs"| node_validation
node_url_service -->|"encodes IDs"| node_base62
node_url_service -->|"reads and writes"| node_repository
node_repository -->|"stores mappings and counts"| node_redis
node_redis_manager -->|"connects and pings"| node_redis

click node_app "https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/main.py"
click node_middleware "https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/core/middleware.py"
click node_logging "https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/core/logging.py"
click node_config "https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/core/config.py"
click node_url_routes "https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/api/urls.py"
click node_health "https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/api/health.py"
click node_dependencies "https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/api/dependencies.py"
click node_schemas "https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/schemas/urls.py"
click node_validation "https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/services/validation.py"
click node_url_service "https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/services/url_service.py"
click node_base62 "https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/core/base62.py"
click node_repository "https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/repositories/url_repository.py"
click node_redis_manager "https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/core/redis.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_app,node_middleware,node_logging,node_config,node_client toneBlue
class node_url_routes,node_health,node_dependencies,node_schemas,node_redis toneAmber
class node_validation,node_url_service,node_base62 toneMint
class node_repository,node_redis_manager toneRose
```

## Components

### Application Runtime

- [FastAPI app](https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/main.py): `backend/app/main.py`
- [Request middleware](https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/core/middleware.py): `backend/app/core/middleware.py`
- [Logging setup](https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/core/logging.py): `backend/app/core/logging.py`
- [Settings](https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/core/config.py): `backend/app/core/config.py`

### HTTP Interface

- [URL endpoints](https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/api/urls.py): `backend/app/api/urls.py`
- [Health endpoint](https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/api/health.py): `backend/app/api/health.py`
- [Redis dependency](https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/api/dependencies.py): `backend/app/api/dependencies.py`
- [URL schemas](https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/schemas/urls.py): `backend/app/schemas/urls.py`

### URL Domain

- [Input validation](https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/services/validation.py): `backend/app/services/validation.py`
- [URL operations](https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/services/url_service.py): `backend/app/services/url_service.py`
- [Code encoding](https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/core/base62.py): `backend/app/core/base62.py`

### Redis Storage

- [URL repository](https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/repositories/url_repository.py): `backend/app/repositories/url_repository.py`
- [Redis connection](https://github.com/fiqqar/url-shortener-platform/blob/main/backend/app/core/redis.py): `backend/app/core/redis.py`

### Other components

- **API clients**
- **Redis**

## Connections

- API clients → FastAPI app: sends requests (evidence: `backend/app/main.py`)
- FastAPI app → URL endpoints: mounts routers (evidence: `backend/app/main.py`)
- FastAPI app → Health endpoint: mounts router (evidence: `backend/app/main.py`)
- FastAPI app → Settings: reads settings (evidence: `backend/app/main.py`)
- FastAPI app → Redis connection: starts and closes (evidence: `backend/app/main.py`)
- FastAPI app → Request middleware: registers middleware (evidence: `backend/app/main.py`)
- FastAPI app → Logging setup: configures logging (evidence: `backend/app/main.py`)
- Request middleware → Logging setup: logs requests (evidence: `backend/app/core/middleware.py`)
- URL endpoints → Redis dependency: injects client (evidence: `backend/app/api/urls.py`)
- URL endpoints → URL schemas: validates and responds (evidence: `backend/app/api/urls.py`)
- URL endpoints → Input validation: checks codes (evidence: `backend/app/api/urls.py`)
- URL endpoints → URL operations: calls operations (evidence: `backend/app/api/urls.py`)
- URL endpoints → Settings: reads base URL (evidence: `backend/app/api/urls.py`)
- Redis dependency → Redis connection: gets client (evidence: `backend/app/api/dependencies.py`)
- Health endpoint → Redis connection: checks Redis (evidence: `backend/app/api/health.py`)
- URL operations → Input validation: validates URLs (evidence: `backend/app/services/url_service.py`)
- URL operations → Code encoding: encodes IDs (evidence: `backend/app/services/url_service.py`)
- URL operations → URL repository: reads and writes (evidence: `backend/app/services/url_service.py`)
- URL repository → Redis: stores mappings and counts (evidence: `backend/app/repositories/url_repository.py`)
- Redis connection → Redis: connects and pings (evidence: `backend/app/core/redis.py`)
