@riligar/agents-kit 1.10.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent/skills/riligar-business-startup/SKILL.md +70 -0
- package/.agent/skills/{riligar-business-startup-analyst/SKILL.md → riligar-business-startup/references/business-case.md} +24 -251
- package/.agent/skills/riligar-business-startup/references/financial-model.md +215 -0
- package/.agent/skills/riligar-business-startup/references/market-analysis.md +151 -0
- package/.agent/skills/riligar-dev-backend/SKILL.md +122 -87
- package/.agent/skills/riligar-dev-backend/references/elysia-basics.md +224 -0
- package/.agent/skills/riligar-dev-backend/references/elysia-lifecycle.md +268 -0
- package/.agent/skills/riligar-dev-backend/references/elysia-patterns.md +324 -0
- package/.agent/skills/riligar-dev-backend/references/elysia-plugins.md +202 -0
- package/.agent/skills/riligar-dev-backend/references/elysia-validation.md +247 -0
- package/.agent/skills/riligar-dev-clean-code/SKILL.md +81 -133
- package/package.json +1 -1
- package/.agent/skills/riligar-business-startup-financial/SKILL.md +0 -391
- package/.agent/skills/riligar-business-startup-market/SKILL.md +0 -265
- package/.agent/skills/riligar-dev-backend/api-style.md +0 -42
- package/.agent/skills/riligar-dev-backend/auth.md +0 -24
- package/.agent/skills/riligar-dev-backend/documentation.md +0 -26
- package/.agent/skills/riligar-dev-backend/graphql.md +0 -41
- package/.agent/skills/riligar-dev-backend/rate-limiting.md +0 -31
- package/.agent/skills/riligar-dev-backend/response.md +0 -37
- package/.agent/skills/riligar-dev-backend/rest.md +0 -40
- package/.agent/skills/riligar-dev-backend/security-testing.md +0 -122
- package/.agent/skills/riligar-dev-backend/trpc.md +0 -41
- package/.agent/skills/riligar-dev-backend/versioning.md +0 -22
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# Financial Projections
|
|
2
|
+
|
|
3
|
+
Create comprehensive 3-5 year financial model with revenue projections, cost structure, headcount planning, cash flow analysis, and three-scenario modeling.
|
|
4
|
+
|
|
5
|
+
## What This Module Creates
|
|
6
|
+
|
|
7
|
+
1. Cohort-based revenue projections
|
|
8
|
+
2. Detailed cost structure (COGS, S&M, R&D, G&A)
|
|
9
|
+
3. Headcount planning by role
|
|
10
|
+
4. Monthly cash flow analysis
|
|
11
|
+
5. Key metrics (CAC, LTV, burn rate, runway)
|
|
12
|
+
6. Three-scenario analysis
|
|
13
|
+
|
|
14
|
+
## Step 1: Gather Inputs
|
|
15
|
+
|
|
16
|
+
**Business Model:**
|
|
17
|
+
- Revenue model (SaaS, marketplace, transaction)
|
|
18
|
+
- Pricing structure (tiers, average price)
|
|
19
|
+
- Target customer segments
|
|
20
|
+
|
|
21
|
+
**Starting Point:**
|
|
22
|
+
- Current MRR/ARR (if any)
|
|
23
|
+
- Current customer count
|
|
24
|
+
- Current team size
|
|
25
|
+
- Current cash balance
|
|
26
|
+
|
|
27
|
+
**Growth Assumptions:**
|
|
28
|
+
- Expected monthly customer acquisition
|
|
29
|
+
- Customer retention/churn rate
|
|
30
|
+
- Average contract value (ACV)
|
|
31
|
+
- Sales cycle length
|
|
32
|
+
|
|
33
|
+
**Cost Assumptions:**
|
|
34
|
+
- Gross margin or COGS %
|
|
35
|
+
- S&M budget or CAC target
|
|
36
|
+
- Current burn rate
|
|
37
|
+
|
|
38
|
+
**Funding:**
|
|
39
|
+
- Planned fundraising (amount, timing)
|
|
40
|
+
- Pre/post-money valuation
|
|
41
|
+
|
|
42
|
+
## Step 2: Build Revenue Model
|
|
43
|
+
|
|
44
|
+
### Cohort-Based Approach
|
|
45
|
+
|
|
46
|
+
For each month, track:
|
|
47
|
+
1. New customers acquired
|
|
48
|
+
2. Existing customers retained (apply churn)
|
|
49
|
+
3. Revenue per cohort (customers × ARPU)
|
|
50
|
+
4. Expansion revenue (upsells)
|
|
51
|
+
|
|
52
|
+
**Formula:**
|
|
53
|
+
```
|
|
54
|
+
MRR (Month N) = Σ across all cohorts:
|
|
55
|
+
(Cohort Size × Retention Rate × ARPU) + Expansion
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Project:**
|
|
59
|
+
- Monthly detail for Year 1-2
|
|
60
|
+
- Quarterly detail for Year 3
|
|
61
|
+
- Annual for Years 4-5
|
|
62
|
+
|
|
63
|
+
## Step 3: Cost Structure
|
|
64
|
+
|
|
65
|
+
### 1. Cost of Goods Sold (COGS)
|
|
66
|
+
- Hosting/infrastructure
|
|
67
|
+
- Payment processing
|
|
68
|
+
- Variable customer support
|
|
69
|
+
- Third-party services
|
|
70
|
+
|
|
71
|
+
Target gross margin:
|
|
72
|
+
- SaaS: 75-85%
|
|
73
|
+
- Marketplace: 60-70%
|
|
74
|
+
- E-commerce: 40-60%
|
|
75
|
+
|
|
76
|
+
### 2. Sales & Marketing (S&M)
|
|
77
|
+
- Sales team compensation
|
|
78
|
+
- Marketing programs
|
|
79
|
+
- Tools and software
|
|
80
|
+
- Target: 40-60% of revenue (early stage)
|
|
81
|
+
|
|
82
|
+
### 3. Research & Development (R&D)
|
|
83
|
+
- Engineering team
|
|
84
|
+
- Product management
|
|
85
|
+
- Design
|
|
86
|
+
- Target: 30-40% of revenue
|
|
87
|
+
|
|
88
|
+
### 4. General & Administrative (G&A)
|
|
89
|
+
- Executive team
|
|
90
|
+
- Finance, legal, HR
|
|
91
|
+
- Office and facilities
|
|
92
|
+
- Target: 15-25% of revenue
|
|
93
|
+
|
|
94
|
+
## Step 4: Headcount Planning
|
|
95
|
+
|
|
96
|
+
**For each role:**
|
|
97
|
+
- Title and department
|
|
98
|
+
- Start date (month/quarter)
|
|
99
|
+
- Base salary
|
|
100
|
+
- Fully-loaded cost (salary × 1.3-1.4)
|
|
101
|
+
|
|
102
|
+
**Departmental ratios:**
|
|
103
|
+
- Engineering: 40-50% of team
|
|
104
|
+
- Sales & Marketing: 25-35%
|
|
105
|
+
- G&A: 10-15%
|
|
106
|
+
- Product/CS: 10-15%
|
|
107
|
+
|
|
108
|
+
## Step 5: Cash Flow
|
|
109
|
+
|
|
110
|
+
Monthly cash flow projection:
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
Beginning Cash Balance
|
|
114
|
+
+ Cash Collected (revenue, consider payment terms)
|
|
115
|
+
- Operating Expenses
|
|
116
|
+
- CapEx
|
|
117
|
+
= Ending Cash Balance
|
|
118
|
+
|
|
119
|
+
Monthly Burn = Revenue - Expenses (if negative)
|
|
120
|
+
Runway = Cash Balance / Monthly Burn Rate
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Include Funding Events:**
|
|
124
|
+
- Timing of raises
|
|
125
|
+
- Amount raised
|
|
126
|
+
- Impact on cash balance
|
|
127
|
+
|
|
128
|
+
## Step 6: Key Metrics
|
|
129
|
+
|
|
130
|
+
### Unit Economics
|
|
131
|
+
- CAC (S&M spend / new customers)
|
|
132
|
+
- LTV (ARPU × margin% / churn rate)
|
|
133
|
+
- LTV:CAC ratio (target > 3.0)
|
|
134
|
+
- CAC payback period (target < 18 months)
|
|
135
|
+
|
|
136
|
+
### Efficiency Metrics
|
|
137
|
+
- Burn multiple (net burn / net new ARR) - target < 2.0
|
|
138
|
+
- Magic number (net new ARR / S&M spend) - target > 0.5
|
|
139
|
+
- Rule of 40 (growth% + margin%) - target > 40%
|
|
140
|
+
|
|
141
|
+
### Cash Metrics
|
|
142
|
+
- Monthly burn rate
|
|
143
|
+
- Runway in months
|
|
144
|
+
|
|
145
|
+
## Step 7: Three Scenarios
|
|
146
|
+
|
|
147
|
+
### Conservative (P10)
|
|
148
|
+
- New customers: -30% vs. base
|
|
149
|
+
- Churn: +20% vs. base
|
|
150
|
+
- Pricing: -15% vs. base
|
|
151
|
+
- CAC: +25% vs. base
|
|
152
|
+
|
|
153
|
+
### Base (P50)
|
|
154
|
+
- Most likely assumptions
|
|
155
|
+
- Primary planning scenario
|
|
156
|
+
|
|
157
|
+
### Optimistic (P90)
|
|
158
|
+
- New customers: +30% vs. base
|
|
159
|
+
- Churn: -20% vs. base
|
|
160
|
+
- Pricing: +15% vs. base
|
|
161
|
+
- CAC: -25% vs. base
|
|
162
|
+
|
|
163
|
+
## Report Tables
|
|
164
|
+
|
|
165
|
+
### Revenue Projections
|
|
166
|
+
```
|
|
167
|
+
| Month | New Customers | Total Customers | MRR | ARR | Growth % |
|
|
168
|
+
|-------|---------------|-----------------|-----|-----|----------|
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Cost Breakdown
|
|
172
|
+
```
|
|
173
|
+
| Department | Year 1 | Year 2 | Year 3 | % Revenue |
|
|
174
|
+
|------------|--------|--------|--------|-----------|
|
|
175
|
+
| COGS | $X | $Y | $Z | XX% |
|
|
176
|
+
| S&M | $X | $Y | $Z | XX% |
|
|
177
|
+
| R&D | $X | $Y | $Z | XX% |
|
|
178
|
+
| G&A | $X | $Y | $Z | XX% |
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Key Metrics
|
|
182
|
+
```
|
|
183
|
+
| Metric | Year 1 | Year 2 | Year 3 | Target |
|
|
184
|
+
|--------|--------|--------|--------|--------|
|
|
185
|
+
| CAC | $X | $Y | $Z | <$A |
|
|
186
|
+
| LTV | $X | $Y | $Z | >$B |
|
|
187
|
+
| LTV:CAC | X | Y | Z | >3.0 |
|
|
188
|
+
| Burn Multiple | X | Y | Z | <2.0 |
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Scenario Comparison
|
|
192
|
+
```
|
|
193
|
+
| Scenario | Year 3 ARR | Customers | Burn | Runway |
|
|
194
|
+
|----------|------------|-----------|------|--------|
|
|
195
|
+
| Conservative | $X | Y | $Z | W mo |
|
|
196
|
+
| Base | $X | Y | $Z | W mo |
|
|
197
|
+
| Optimistic | $X | Y | $Z | W mo |
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Best Practices
|
|
201
|
+
|
|
202
|
+
**Do:**
|
|
203
|
+
- Use cohort-based revenue model
|
|
204
|
+
- Include 3 scenarios
|
|
205
|
+
- Show monthly detail (Year 1-2)
|
|
206
|
+
- Calculate key metrics
|
|
207
|
+
- Validate against benchmarks
|
|
208
|
+
- Document all assumptions
|
|
209
|
+
|
|
210
|
+
**Don't:**
|
|
211
|
+
- Be overly optimistic on growth
|
|
212
|
+
- Underestimate costs
|
|
213
|
+
- Forget fully-loaded compensation
|
|
214
|
+
- Ignore cash timing
|
|
215
|
+
- Skip scenario analysis
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Market Opportunity Analysis
|
|
2
|
+
|
|
3
|
+
Generate comprehensive market opportunity analysis with TAM/SAM/SOM calculations using both bottom-up and top-down methodologies.
|
|
4
|
+
|
|
5
|
+
## Process Overview
|
|
6
|
+
|
|
7
|
+
1. Define the target market and customer segments
|
|
8
|
+
2. Gather relevant market data
|
|
9
|
+
3. Calculate TAM using bottom-up methodology
|
|
10
|
+
4. Validate with top-down analysis
|
|
11
|
+
5. Narrow to SAM with appropriate filters
|
|
12
|
+
6. Estimate realistic SOM (3-5 year opportunity)
|
|
13
|
+
7. Present findings in a formatted report
|
|
14
|
+
|
|
15
|
+
## Step 1: Gather Context
|
|
16
|
+
|
|
17
|
+
Ask for essential information:
|
|
18
|
+
|
|
19
|
+
**Product/Service:**
|
|
20
|
+
- What problem is being solved?
|
|
21
|
+
- How does pricing work? (subscription, transaction, etc.)
|
|
22
|
+
|
|
23
|
+
**Target Customers:**
|
|
24
|
+
- Who is the ideal customer? (industry, size, geography)
|
|
25
|
+
- Initial target market (US, North America, Global)
|
|
26
|
+
|
|
27
|
+
**Stage:**
|
|
28
|
+
- What stage is the company? (pre-launch, seed, Series A)
|
|
29
|
+
|
|
30
|
+
## Step 2: Bottom-Up Analysis
|
|
31
|
+
|
|
32
|
+
### For B2B/SaaS
|
|
33
|
+
|
|
34
|
+
1. Define customer segments (company size, industry, use case)
|
|
35
|
+
2. Estimate number of companies in each segment
|
|
36
|
+
3. Determine average contract value (ACV) per segment
|
|
37
|
+
4. Calculate TAM: Σ (Segment Size × ACV)
|
|
38
|
+
|
|
39
|
+
### For Consumer/Marketplace
|
|
40
|
+
|
|
41
|
+
1. Define target user demographics
|
|
42
|
+
2. Estimate total addressable users
|
|
43
|
+
3. Determine average revenue per user (ARPU)
|
|
44
|
+
4. Calculate TAM: Total Users × ARPU × Frequency
|
|
45
|
+
|
|
46
|
+
### For Transactions/E-commerce
|
|
47
|
+
|
|
48
|
+
1. Estimate total transaction volume (GMV)
|
|
49
|
+
2. Determine take rate or margin
|
|
50
|
+
3. Calculate TAM: Total GMV × Take Rate
|
|
51
|
+
|
|
52
|
+
## Step 3: Data Sources
|
|
53
|
+
|
|
54
|
+
Recommended sources:
|
|
55
|
+
- Government data (Census, BLS)
|
|
56
|
+
- Industry reports (Gartner, Forrester, Statista)
|
|
57
|
+
- Public company filings (10-K reports)
|
|
58
|
+
- Trade associations
|
|
59
|
+
- Academic research
|
|
60
|
+
|
|
61
|
+
**Always cite sources with URLs and publication dates.**
|
|
62
|
+
|
|
63
|
+
## Step 4: Top-Down Validation
|
|
64
|
+
|
|
65
|
+
1. Find total market category size from research
|
|
66
|
+
2. Apply geographic filters
|
|
67
|
+
3. Apply segment/product filters
|
|
68
|
+
4. Compare to bottom-up TAM (should be within 30%)
|
|
69
|
+
|
|
70
|
+
If variance > 30%, investigate and explain differences.
|
|
71
|
+
|
|
72
|
+
## Step 5: Calculate SAM
|
|
73
|
+
|
|
74
|
+
Apply realistic filters to narrow TAM:
|
|
75
|
+
|
|
76
|
+
- **Geographic:** Regions actually serviceable
|
|
77
|
+
- **Product Capability:** Features needed to serve
|
|
78
|
+
- **Market Readiness:** Customers ready to adopt
|
|
79
|
+
- **Addressable Switching:** Can reach and convert
|
|
80
|
+
|
|
81
|
+
Formula:
|
|
82
|
+
```
|
|
83
|
+
SAM = TAM × Geographic % × Product Fit % × Market Readiness %
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Step 6: Estimate SOM
|
|
87
|
+
|
|
88
|
+
Calculate realistic obtainable market share:
|
|
89
|
+
|
|
90
|
+
**Conservative Approach (Recommended):**
|
|
91
|
+
- Year 3: 2-3% of SAM
|
|
92
|
+
- Year 5: 4-6% of SAM
|
|
93
|
+
|
|
94
|
+
**Consider:**
|
|
95
|
+
- Competitive intensity
|
|
96
|
+
- Available resources (funding, team)
|
|
97
|
+
- Go-to-market effectiveness
|
|
98
|
+
- Differentiation strength
|
|
99
|
+
|
|
100
|
+
## Report Structure
|
|
101
|
+
|
|
102
|
+
### Section 1: Executive Summary
|
|
103
|
+
- Market opportunity in one paragraph
|
|
104
|
+
- TAM/SAM/SOM headline numbers
|
|
105
|
+
|
|
106
|
+
### Section 2: Market Definition
|
|
107
|
+
- Problem being solved
|
|
108
|
+
- Target customer profile
|
|
109
|
+
- Geographic scope
|
|
110
|
+
|
|
111
|
+
### Section 3: Bottom-Up Analysis
|
|
112
|
+
- Customer segment breakdown
|
|
113
|
+
- Segment sizing with sources
|
|
114
|
+
- TAM calculation with formula
|
|
115
|
+
|
|
116
|
+
### Section 4: Top-Down Validation
|
|
117
|
+
- Industry category and size
|
|
118
|
+
- Validated TAM
|
|
119
|
+
- Comparison to bottom-up
|
|
120
|
+
|
|
121
|
+
### Section 5: SAM Calculation
|
|
122
|
+
- Filters applied with rationale
|
|
123
|
+
- SAM formula and result
|
|
124
|
+
|
|
125
|
+
### Section 6: SOM Projection
|
|
126
|
+
- Market share assumptions
|
|
127
|
+
- Year 3 and Year 5 estimates
|
|
128
|
+
- Revenue projections
|
|
129
|
+
|
|
130
|
+
### Section 7: Market Growth
|
|
131
|
+
- Industry growth rate (CAGR)
|
|
132
|
+
- Key growth drivers
|
|
133
|
+
|
|
134
|
+
### Section 8: Validation
|
|
135
|
+
- Public company comparisons
|
|
136
|
+
- Competitive context
|
|
137
|
+
|
|
138
|
+
## Best Practices
|
|
139
|
+
|
|
140
|
+
**Do:**
|
|
141
|
+
- Start with bottom-up (most credible)
|
|
142
|
+
- Always triangulate with top-down
|
|
143
|
+
- Cite all data sources
|
|
144
|
+
- Be conservative on SOM
|
|
145
|
+
- Compare to public company benchmarks
|
|
146
|
+
|
|
147
|
+
**Don't:**
|
|
148
|
+
- Rely solely on top-down
|
|
149
|
+
- Cherry-pick optimistic data
|
|
150
|
+
- Claim >10% SOM without strong justification
|
|
151
|
+
- Skip validation steps
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: riligar-dev-backend
|
|
3
3
|
type: development
|
|
4
|
-
description:
|
|
4
|
+
description: Elysia backend development patterns for Bun. Use when building APIs, routes, plugins, validation, middleware, and error handling with Elysia framework.
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
#
|
|
7
|
+
# Elysia Backend Development
|
|
8
8
|
|
|
9
|
-
>
|
|
10
|
-
> **Learn to THINK, not copy fixed patterns.**
|
|
11
|
-
|
|
12
|
-
---
|
|
9
|
+
> Build fast, type-safe APIs with Elysia + Bun.
|
|
13
10
|
|
|
14
11
|
## Mandatory Guidelines
|
|
15
12
|
|
|
@@ -17,84 +14,122 @@ description: API design principles and decision-making. REST vs GraphQL vs tRPC
|
|
|
17
14
|
> All work in this skill MUST adhere to:
|
|
18
15
|
>
|
|
19
16
|
> - @[.agent/skills/riligar-dev-clean-code] (Clean Code Standards)
|
|
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
|
-
|
|
17
|
+
> - @[.agent/skills/riligar-tech-stack] (Tech Stack - Bun, Elysia, SQLite, Drizzle)
|
|
18
|
+
|
|
19
|
+
## Quick Reference
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
import { Elysia, t } from 'elysia'
|
|
23
|
+
|
|
24
|
+
const app = new Elysia()
|
|
25
|
+
.get('/', () => 'Hello Elysia')
|
|
26
|
+
.post('/users', ({ body }) => createUser(body), {
|
|
27
|
+
body: t.Object({
|
|
28
|
+
name: t.String(),
|
|
29
|
+
email: t.String({ format: 'email' })
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
.listen(3000)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Content Map
|
|
36
|
+
|
|
37
|
+
| File | Description | When to Read |
|
|
38
|
+
| --- | --- | --- |
|
|
39
|
+
| [elysia-basics.md](references/elysia-basics.md) | Setup, routes, handlers, context | Starting new project |
|
|
40
|
+
| [elysia-plugins.md](references/elysia-plugins.md) | Plugins, guards, modular design | Organizing code |
|
|
41
|
+
| [elysia-validation.md](references/elysia-validation.md) | TypeBox validation (body, query, params) | Input validation |
|
|
42
|
+
| [elysia-lifecycle.md](references/elysia-lifecycle.md) | Hooks (onBeforeHandle, onError, etc.) | Middleware, auth checks |
|
|
43
|
+
| [elysia-patterns.md](references/elysia-patterns.md) | REST patterns, responses, pagination | API design |
|
|
44
|
+
|
|
45
|
+
## Project Structure
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
src/
|
|
49
|
+
├── index.js # Entry point
|
|
50
|
+
├── routes/
|
|
51
|
+
│ ├── index.js # Route aggregator
|
|
52
|
+
│ ├── users.js # User routes plugin
|
|
53
|
+
│ └── posts.js # Post routes plugin
|
|
54
|
+
├── services/
|
|
55
|
+
│ ├── user.js # Business logic
|
|
56
|
+
│ └── post.js
|
|
57
|
+
├── database/
|
|
58
|
+
│ ├── db.js # Drizzle connection
|
|
59
|
+
│ ├── schema.js # Drizzle schema
|
|
60
|
+
│ └── migrations/
|
|
61
|
+
└── middleware/
|
|
62
|
+
├── auth.js # Auth middleware
|
|
63
|
+
└── logger.js # Request logging
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Core Patterns
|
|
67
|
+
|
|
68
|
+
### Route Plugin
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
// routes/users.js
|
|
72
|
+
import { Elysia, t } from 'elysia'
|
|
73
|
+
import { getUserById, createUser } from '../services/user'
|
|
74
|
+
|
|
75
|
+
export const userRoutes = new Elysia({ prefix: '/users' })
|
|
76
|
+
.get('/', () => getAllUsers())
|
|
77
|
+
.get('/:id', ({ params }) => getUserById(params.id))
|
|
78
|
+
.post('/', ({ body }) => createUser(body), {
|
|
79
|
+
body: t.Object({
|
|
80
|
+
name: t.String({ minLength: 1 }),
|
|
81
|
+
email: t.String({ format: 'email' })
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Main App
|
|
87
|
+
|
|
88
|
+
```javascript
|
|
89
|
+
// index.js
|
|
90
|
+
import { Elysia } from 'elysia'
|
|
91
|
+
import { userRoutes } from './routes/users'
|
|
92
|
+
import { postRoutes } from './routes/posts'
|
|
93
|
+
|
|
94
|
+
const app = new Elysia()
|
|
95
|
+
.onError(({ error, set }) => {
|
|
96
|
+
console.error(error)
|
|
97
|
+
set.status = 500
|
|
98
|
+
return { error: 'Internal Server Error' }
|
|
99
|
+
})
|
|
100
|
+
.use(userRoutes)
|
|
101
|
+
.use(postRoutes)
|
|
102
|
+
.listen(3000)
|
|
103
|
+
|
|
104
|
+
console.log(`Server running at ${app.server?.url}`)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Related Skills
|
|
108
|
+
|
|
109
|
+
| Need | Skill |
|
|
110
|
+
| --- | --- |
|
|
111
|
+
| **Authentication** | @[.agent/skills/riligar-dev-auth-elysia] |
|
|
112
|
+
| **Database** | @[.agent/skills/riligar-dev-database] |
|
|
113
|
+
| **Tech Stack** | @[.agent/skills/riligar-tech-stack] |
|
|
114
|
+
| **Clean Code** | @[.agent/skills/riligar-dev-clean-code] |
|
|
115
|
+
| **Infrastructure** | @[.agent/skills/riligar-infrastructure] |
|
|
116
|
+
|
|
117
|
+
## Decision Checklist
|
|
118
|
+
|
|
119
|
+
Before building an API:
|
|
120
|
+
|
|
121
|
+
- [ ] Defined route structure and prefixes?
|
|
122
|
+
- [ ] Planned validation for all inputs?
|
|
123
|
+
- [ ] Error handling configured?
|
|
124
|
+
- [ ] Auth middleware needed? → Use `riligar-dev-auth-elysia`
|
|
125
|
+
- [ ] Database connection setup? → Use `riligar-dev-database`
|
|
126
|
+
|
|
127
|
+
## Anti-Patterns
|
|
128
|
+
|
|
129
|
+
| Don't | Do |
|
|
130
|
+
| --- | --- |
|
|
131
|
+
| Put business logic in handlers | Extract to `services/` |
|
|
132
|
+
| Skip input validation | Use TypeBox (`t.Object`) |
|
|
133
|
+
| Ignore error handling | Use `onError` lifecycle |
|
|
134
|
+
| Create monolithic files | Split into plugins |
|
|
135
|
+
| Use verbs in routes (`/getUser`) | Use nouns (`/users/:id`) |
|