# belotti17/x-clone architecture

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

- Interactive diagram: https://gitdiagram.com/belotti17/x-clone
- Repository: https://github.com/belotti17/x-clone

## Overview

X Clone is a server-rendered social platform whose main workflow is account creation and OTP verification, followed by a protected personalized timeline where users publish and interact with posts. Routes dispatch requests to controllers; the application also supports profiles, follows, search/trending, communities, and private messages. Controllers use Lucid models for persistent domain data. The README documents additional interface and security capabilities, but views are absent from the supplied tree. Relationships among unsampled controllers and models are shown only where documentation supports them.

Main entry points: [`start/routes.ts`](https://github.com/belotti17/x-clone/blob/main/start/routes.ts) (HTTP routes), [`app/models/user.ts`](https://github.com/belotti17/x-clone/blob/main/app/models/user.ts) (User), [`config/database.ts`](https://github.com/belotti17/x-clone/blob/main/config/database.ts) (PostgreSQL), [`app/models/tweet.ts`](https://github.com/belotti17/x-clone/blob/main/app/models/tweet.ts) (Tweet)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Web entry and identity"]
  node_routes["HTTP routes<br/>[routes.ts]"]
  node_signup["Account registration"]
  node_auth["OTP verification<br/>[auth_controller.ts]"]
  node_session["Session login"]
  node_client["Interactive browser UI<br/>[index.js]"]
end

subgraph group_social["Posts and interactions"]
  node_timeline["Timeline"]
  node_tweets["Tweet actions"]
end

subgraph group_discovery["Profiles and discovery"]
  node_profile["Profile management"]
  node_follows["Follow actions"]
  node_search["Search"]
  node_hashtags["Trending hashtags"]
  node_communities["Communities"]
end

subgraph group_messaging["Private messaging"]
  node_messages["Messaging"]
end

subgraph group_data["Domain persistence"]
  node_user["User<br/>[user.ts]"]
  node_tweet["Tweet<br/>[tweet.ts]"]
  node_like["Like<br/>[like.ts]"]
  node_retweet["Retweet<br/>[retweet.ts]"]
  node_follow["Follow<br/>[follow.ts]"]
  node_message_model["Message<br/>[message.ts]"]
  node_otp_token["OTP token"]
  node_database[("PostgreSQL<br/>[database.ts]")]
end

node_visitor(("Visitor"))
node_mail["Email service"]

node_visitor -->|"requests"| node_routes
node_client -.->|"fetches"| node_routes
node_routes -->|"dispatches"| node_signup
node_routes -->|"dispatches"| node_auth
node_routes -->|"dispatches"| node_session
node_routes -->|"dispatches"| node_timeline
node_routes -->|"dispatches"| node_tweets
node_routes -->|"dispatches"| node_profile
node_routes -->|"dispatches"| node_follows
node_routes -->|"dispatches"| node_search
node_routes -->|"dispatches"| node_hashtags
node_routes -->|"dispatches"| node_communities
node_routes -->|"dispatches"| node_messages
node_signup -.->|"sends OTP"| node_mail
node_signup -.->|"creates token"| node_otp_token
node_auth -.->|"verifies token"| node_otp_token
node_messages -->|"reads and writes"| node_message_model
node_messages -->|"queries users"| node_user
node_user -->|"relates to"| node_tweet
node_user -->|"relates to"| node_like
node_user -->|"relates to"| node_retweet
node_user -->|"relates to"| node_follow
node_tweet -->|"belongs to"| node_user
node_tweet -->|"relates to"| node_like
node_like -->|"belongs to"| node_tweet
node_like -->|"belongs to"| node_user
node_retweet -->|"belongs to"| node_tweet
node_retweet -->|"belongs to"| node_user
node_follow -->|"references users"| node_user
node_message_model -->|"references users"| node_user
node_otp_token -->|"belongs to"| node_user
node_user -.->|"persists through ORM"| node_database
node_tweet -.->|"persists through ORM"| node_database
node_like -.->|"persists through ORM"| node_database
node_retweet -.->|"persists through ORM"| node_database
node_follow -.->|"persists through ORM"| node_database
node_message_model -.->|"persists through ORM"| node_database
node_otp_token -.->|"persists through ORM"| node_database

click node_user "https://github.com/belotti17/x-clone/blob/main/app/models/user.ts"
click node_tweet "https://github.com/belotti17/x-clone/blob/main/app/models/tweet.ts"
click node_like "https://github.com/belotti17/x-clone/blob/main/app/models/like.ts"
click node_retweet "https://github.com/belotti17/x-clone/blob/main/app/models/retweet.ts"
click node_follow "https://github.com/belotti17/x-clone/blob/main/app/models/follow.ts"
click node_message_model "https://github.com/belotti17/x-clone/blob/main/app/models/message.ts"
click node_otp_token "https://github.com/belotti17/x-clone/blob/main/app/models/email_verification_token.ts"
click node_database "https://github.com/belotti17/x-clone/blob/main/config/database.ts"
click node_routes "https://github.com/belotti17/x-clone/blob/main/start/routes.ts"
click node_signup "https://github.com/belotti17/x-clone/blob/main/app/controllers/new_account_controller.ts"
click node_auth "https://github.com/belotti17/x-clone/blob/main/app/controllers/auth_controller.ts"
click node_session "https://github.com/belotti17/x-clone/blob/main/app/controllers/session_controller.ts"
click node_timeline "https://github.com/belotti17/x-clone/blob/main/app/controllers/timeline_controller.ts"
click node_tweets "https://github.com/belotti17/x-clone/blob/main/app/controllers/tweets_controller.ts"
click node_profile "https://github.com/belotti17/x-clone/blob/main/app/controllers/profile_controller.ts"
click node_follows "https://github.com/belotti17/x-clone/blob/main/app/controllers/follows_controller.ts"
click node_search "https://github.com/belotti17/x-clone/blob/main/app/controllers/searches_controller.ts"
click node_hashtags "https://github.com/belotti17/x-clone/blob/main/app/controllers/hashtags_controller.ts"
click node_communities "https://github.com/belotti17/x-clone/blob/main/app/controllers/communities_controller.ts"
click node_messages "https://github.com/belotti17/x-clone/blob/main/app/controllers/messages_controller.ts"
click node_client "https://github.com/belotti17/x-clone/blob/main/resources/js/index.js"

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_routes,node_signup,node_auth,node_session,node_client toneBlue
class node_timeline,node_tweets toneAmber
class node_profile,node_follows,node_search,node_hashtags,node_communities toneMint
class node_messages toneRose
class node_user,node_tweet,node_like,node_retweet,node_follow,node_message_model,node_otp_token,node_database,node_visitor,node_mail toneIndigo
```

## Components

### Web entry and identity

- [HTTP routes](https://github.com/belotti17/x-clone/blob/main/start/routes.ts): `start/routes.ts`
- [Account registration](https://github.com/belotti17/x-clone/blob/main/app/controllers/new_account_controller.ts): `app/controllers/new_account_controller.ts`
- [OTP verification](https://github.com/belotti17/x-clone/blob/main/app/controllers/auth_controller.ts): `app/controllers/auth_controller.ts`
- [Session login](https://github.com/belotti17/x-clone/blob/main/app/controllers/session_controller.ts): `app/controllers/session_controller.ts`
- [Interactive browser UI](https://github.com/belotti17/x-clone/blob/main/resources/js/index.js): `resources/js/index.js`

### Posts and interactions

- [Timeline](https://github.com/belotti17/x-clone/blob/main/app/controllers/timeline_controller.ts): `app/controllers/timeline_controller.ts`
- [Tweet actions](https://github.com/belotti17/x-clone/blob/main/app/controllers/tweets_controller.ts): `app/controllers/tweets_controller.ts`

### Profiles and discovery

- [Profile management](https://github.com/belotti17/x-clone/blob/main/app/controllers/profile_controller.ts): `app/controllers/profile_controller.ts`
- [Follow actions](https://github.com/belotti17/x-clone/blob/main/app/controllers/follows_controller.ts): `app/controllers/follows_controller.ts`
- [Search](https://github.com/belotti17/x-clone/blob/main/app/controllers/searches_controller.ts): `app/controllers/searches_controller.ts`
- [Trending hashtags](https://github.com/belotti17/x-clone/blob/main/app/controllers/hashtags_controller.ts): `app/controllers/hashtags_controller.ts`
- [Communities](https://github.com/belotti17/x-clone/blob/main/app/controllers/communities_controller.ts): `app/controllers/communities_controller.ts`

### Private messaging

- [Messaging](https://github.com/belotti17/x-clone/blob/main/app/controllers/messages_controller.ts): `app/controllers/messages_controller.ts`

### Domain persistence

- [User](https://github.com/belotti17/x-clone/blob/main/app/models/user.ts): `app/models/user.ts`
- [Tweet](https://github.com/belotti17/x-clone/blob/main/app/models/tweet.ts): `app/models/tweet.ts`
- [Like](https://github.com/belotti17/x-clone/blob/main/app/models/like.ts): `app/models/like.ts`
- [Retweet](https://github.com/belotti17/x-clone/blob/main/app/models/retweet.ts): `app/models/retweet.ts`
- [Follow](https://github.com/belotti17/x-clone/blob/main/app/models/follow.ts): `app/models/follow.ts`
- [Message](https://github.com/belotti17/x-clone/blob/main/app/models/message.ts): `app/models/message.ts`
- [OTP token](https://github.com/belotti17/x-clone/blob/main/app/models/email_verification_token.ts): `app/models/email_verification_token.ts`
- [PostgreSQL](https://github.com/belotti17/x-clone/blob/main/config/database.ts): `config/database.ts`

### Other components

- **Visitor**
- **Email service**

## Connections

- Visitor → HTTP routes: requests (evidence: `start/routes.ts`)
- Interactive browser UI → HTTP routes: fetches
- HTTP routes → Account registration: dispatches (evidence: `start/routes.ts`)
- HTTP routes → OTP verification: dispatches (evidence: `start/routes.ts`)
- HTTP routes → Session login: dispatches (evidence: `start/routes.ts`)
- HTTP routes → Timeline: dispatches (evidence: `start/routes.ts`)
- HTTP routes → Tweet actions: dispatches (evidence: `start/routes.ts`)
- HTTP routes → Profile management: dispatches (evidence: `start/routes.ts`)
- HTTP routes → Follow actions: dispatches (evidence: `start/routes.ts`)
- HTTP routes → Search: dispatches (evidence: `start/routes.ts`)
- HTTP routes → Trending hashtags: dispatches (evidence: `start/routes.ts`)
- HTTP routes → Communities: dispatches (evidence: `start/routes.ts`)
- HTTP routes → Messaging: dispatches (evidence: `start/routes.ts`)
- Account registration → Email service: sends OTP
- Account registration → OTP token: creates token
- OTP verification → OTP token: verifies token
- Messaging → Message: reads and writes (evidence: `app/controllers/messages_controller.ts`)
- Messaging → User: queries users (evidence: `app/controllers/messages_controller.ts`)
- User → Tweet: relates to (evidence: `app/models/user.ts`)
- User → Like: relates to (evidence: `app/models/user.ts`)
- User → Retweet: relates to (evidence: `app/models/user.ts`)
- User → Follow: relates to (evidence: `app/models/user.ts`)
- Tweet → User: belongs to (evidence: `app/models/tweet.ts`)
- Tweet → Like: relates to (evidence: `app/models/tweet.ts`)
- Like → Tweet: belongs to (evidence: `app/models/like.ts`)
- Like → User: belongs to (evidence: `app/models/like.ts`)
- Retweet → Tweet: belongs to (evidence: `app/models/retweet.ts`)
- Retweet → User: belongs to (evidence: `app/models/retweet.ts`)
- Follow → User: references users (evidence: `app/models/follow.ts`)
- Message → User: references users (evidence: `app/models/message.ts`)
- OTP token → User: belongs to (evidence: `app/models/email_verification_token.ts`)
- User → PostgreSQL: persists through ORM
- Tweet → PostgreSQL: persists through ORM
- Like → PostgreSQL: persists through ORM
- Retweet → PostgreSQL: persists through ORM
- Follow → PostgreSQL: persists through ORM
- Message → PostgreSQL: persists through ORM
- OTP token → PostgreSQL: persists through ORM
