-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstructure.txt
More file actions
123 lines (87 loc) · 5 KB
/
structure.txt
File metadata and controls
123 lines (87 loc) · 5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
decentlink/
├── contract/
│ └── programs/
│ └── registry/
│ └── src/
│ └── lib.rs ← Anchor program
├── prisma/
│ └── schema.prisma ← Prisma schema
├── src/
│ ├── app/
│ │ ├── api/
│ │ │ ├── ipfs/
│ │ │ │ └── add/
│ │ │ │ └── route.ts ← Pinata upload route
│ │ │ ├── users/
│ │ │ │ └── route.ts ← POST: register user
│ │ │ ├── click/
│ │ │ │ └── route.ts ← POST: register user
│ │ │ └── analytics/
│ │ │ └── route.ts ← GET: user analytics
│ │ ├── [shortCode]/
│ │ │ └── page.tsx ← Link resolver page
│ │ ├── layout-client.tsx
│ │ ├── layout.tsx
│ │ ├── globals.css
│ │ └── page.tsx ← Main UI
│ ├── analytics/
│ │ └── page.tsx ← Analytics UI page
│ ├── components/
│ │ ├── ConnectWallet.tsx
│ │ ├── UrlShortener.tsx
│ │ ├── Header.tsx
│ │ └── ui/
│ │ ├── button.tsx ← Button component (shadcn style)
│ │ └── card.tsx ← Optional: Card component (if needed)
│ ├── idl/
│ │ └── registry.json ← Anchor IDL file
│ └── lib/
│ ├── prisma.ts ← Prisma client instance
│ └── utils.ts ← Utility functions
├── Anchor.toml
├── package.json
├── tailwind.config.ts
└── tsconfig.json
Use PostgreSQL for user management, link metadata, and analytics.
Use Pinata for storing any associated content (like images or documents) that you want to keep decentralized.
| Concern | Decentralized Hybrid
|-------------------|---------------------------------------------------------------------------------------------------
| **API Layer** | Edge Functions + Peer-to-peer libp2p nodes
| **Mapping Store** | IPFS + DHT (Pinning) + Smart-Contract anchor
| **Auth** | Wallet-based Web3Auth / DIDs
| **Cache** | Edge Cache + DHT local caches
| **Analytics** | Event logs on IPFS + off-chain processing; optionally anchored hashes on chain for auditability
| **Governance** | DAO-controlled releases; on-chain proposals for fee model or feature flags
This format provides a clear overview of your project structure and the architectural considerations for different approaches.
Decentralization
When you say “decentralized,” you essentially want no single point of control or failure, and—ideally—an open, peer-to-peer or blockchain-based registry for short codes.
1 Decentralized Storage & Indexing
a) IPFS / libp2p / OrbitDB:
Store mapping documents (e.g. { short: "abc123", url: "https://…" }) on IPFS.
Use a DHT (Distributed Hash Table) via libp2p so any node can resolve “abc123” by looking it up in the DHT.
b) Pinning & Replication:
Run or incentivize a set of “pinning nodes” to keep frequently used mapping CIDs available across the network.
2 Blockchain-Anchored Registry
a) Smart Contract Registry:
Deploy a minimal smart contract (Ethereum, Polygon, Solana, etc.) that maps bytes6 shortCode → bytes32 IPFS_CID.
Users can submit/register short codes by sending a small transaction (gas fee + nominal registry fee).
b) Off-Chain Lookups with On-Chain Verification:
Clients first query an off-chain DHT or IPFS gateway; then verify the result against the on-chain hash for tamper-proofing.
c) Incentive / Token Model:
Issue a small fungible token so that node operators are rewarded for hosting and serving mappings.
3 Decentralized Identity & Auth
a) Wallet-Based Login (Web3Auth / Social logins):
Allow users to authenticate via their Ethereum/Phantom/Solana wallet—no central user database.
b) DID / Verifiable Credentials:
Issue a Decentralized Identifier (DID) for every creator, signed by a root authority or via a blockchain.
4 Governance & Upgradability
a) DAO Structure:
If you want community governance over new features or fee schedules, spin up a lightweight DAO (e.g. Aragon, Snapshot).
b) Upgradeable Smart Contracts:
Use proxy patterns so that the registry contract can be upgraded by a multi-sig or DAO vote.
What’s next?
Try it out: run npm run dev, connect Phantom, shorten a URL—watch it appear on IPFS & Solana.
Pinning: sign up with Pinata or run your own go-ipfs daemon for durability.
Analytics: append click-logs to IPFS or push events on-chain.
Governance: later add a DAO to vote on fees or pinning incentives.
Feel free to ask for code snippets on any spot!