Skip to content

Commit dac84c6

Browse files
committed
add documentation
1 parent 3634c22 commit dac84c6

23 files changed

+9014
-30
lines changed

content/_index.md

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,58 @@ Our goal is to simplify the complexities of building modern SaaS applications, a
1919
* **Modern Development Stack**: Leveraging React, TypeScript, and TailwindCSS for a highly performant, maintainable, and visually appealing frontend.
2020
* **Scalable Backend**: Utilizing Firebase (Authentication, Firestore, Cloud Functions) for a serverless, scalable, and cost-effective backend infrastructure.
2121

22-
### Getting Started
22+
## Learning Path
2323

24-
To begin building your SaaS application with Fireact.dev, follow our comprehensive [Getting Started guide](/getting-started/). It will walk you through the prerequisites, installing the `create-fireact-app` CLI tool, creating a new project, and running your application locally.
24+
Follow this recommended learning progression from basics to advanced topics:
25+
26+
### 1. Getting Started
27+
Begin with the [Getting Started guide](/getting-started/) to set up your first Fireact.dev application. This covers:
28+
- Prerequisites and environment setup
29+
- Installing `create-fireact-app` CLI
30+
- Creating and running your first project
31+
- Understanding the project structure
32+
33+
### 2. Tutorials
34+
Follow hands-on [Tutorials](/tutorials/) to build real features:
35+
- [Building Your First Custom Feature](/tutorials/building-first-feature/) - End-to-end feature development
36+
- [Customizing the UI Theme](/tutorials/customizing-ui-theme/) - Brand your application
37+
- [Custom Subscription Plans](/tutorials/custom-subscription-plans/) - Advanced billing features
38+
- [Third-Party Integrations](/tutorials/third-party-integrations/) - Integrate external services
39+
40+
### 3. Examples & Code Snippets
41+
Explore ready-to-use [Examples](/examples/) for common tasks:
42+
- Authentication patterns (social login, email verification)
43+
- Data management (CRUD, real-time updates, pagination)
44+
- Cloud Functions (triggers, scheduled jobs, error handling)
45+
- Subscription & billing (payment flows, usage-based billing)
46+
- UI components (forms, modals, tables)
47+
- Integration patterns (APIs, webhooks, email)
48+
49+
### 4. Custom Development
50+
Learn to build advanced custom features in [Custom Development](/custom-development/):
51+
- Developing custom components and pages
52+
- Data fetching patterns
53+
- Localization and internationalization
54+
- Routing and permission control
55+
56+
### 5. API Reference
57+
Deep dive into framework internals:
58+
- [App Package](/app/) - Frontend components, hooks, and utilities
59+
- [Functions Package](/functions/) - Cloud Functions and backend logic
60+
61+
### 6. Best Practices
62+
Master production-ready development with [Best Practices](/best-practices/):
63+
- Code organization and architecture
64+
- Performance optimization
65+
- Error handling strategies
66+
- Testing methodologies
67+
- Security guidelines
68+
- Deployment and CI/CD
69+
70+
## Quick Links
71+
72+
- **First time?** Start with [Getting Started](/getting-started/)
73+
- **Need code?** Check [Examples](/examples/)
74+
- **Building a feature?** Follow [Tutorials](/tutorials/)
75+
- **Production ready?** Review [Best Practices](/best-practices/)
76+
- **Troubleshooting?** See [Troubleshooting Guide](https://github.com/fireact-dev/fireact.dev/blob/main/TROUBLESHOOTING.md)

content/app/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "@fireact.dev/app Package"
33
linkTitle: "App Package"
44
type: "docs"
55
no_list: true
6-
weight: 20
6+
weight: 40
77
menu:
88
docs:
99
parent: "app"

content/best-practices/_index.md

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
---
2+
title: "Best Practices"
3+
linkTitle: "Best Practices"
4+
type: "docs"
5+
weight: 60
6+
cascade:
7+
type: "docs"
8+
---
9+
10+
This section covers best practices for building production-ready SaaS applications with Fireact.dev.
11+
12+
## Categories
13+
14+
### Code Organization
15+
- [Project Structure](code-organization/) - Organize your codebase effectively
16+
- [Component Design](code-organization/#component-design) - Build maintainable React components
17+
- [State Management](code-organization/#state-management) - Manage application state
18+
19+
### Performance
20+
- [Optimization Techniques](performance/) - Improve application performance
21+
- [Bundle Size Management](performance/#bundle-size) - Reduce JavaScript bundle size
22+
- [Database Queries](performance/#database-queries) - Optimize Firestore queries
23+
24+
### Security
25+
- [Security Best Practices](../../SECURITY.md) - Comprehensive security guide (root documentation)
26+
- [Authentication](security/) - Secure authentication patterns
27+
- [Authorization](security/#authorization) - Implement proper access control
28+
- [Data Protection](security/#data-protection) - Protect sensitive data
29+
30+
### Error Handling
31+
- [Error Handling Guide](error-handling/) - Comprehensive error handling strategies
32+
- [Client-Side Errors](error-handling/#react-error-handling) - Handle errors in React components
33+
- [Server-Side Errors](error-handling/#cloud-functions-error-handling) - Handle Cloud Function errors
34+
- [User Feedback](error-handling/#user-friendly-error-messages) - Communicate errors to users
35+
36+
### Testing
37+
- [Testing Strategies](testing/) - Comprehensive testing guide
38+
- [Unit Testing](testing/#react-component-testing) - Test individual components and functions
39+
- [Integration Testing](testing/#cloud-functions-testing) - Test feature workflows
40+
- [E2E Testing](testing/#end-to-end-testing) - End-to-end testing strategies
41+
42+
### Deployment
43+
- [Deployment Guide](../../DEPLOYMENT.md) - Multi-platform deployment guide (root documentation)
44+
- [CI/CD Setup](../../demo/#cicd) - Automated deployment workflows
45+
- [Environment Management](../../DEPLOYMENT.md#environment-configuration) - Manage multiple environments
46+
- [Monitoring](../../DEPLOYMENT.md#monitoring-and-observability) - Monitor production applications
47+
48+
## General Principles
49+
50+
### 1. Follow TypeScript Best Practices
51+
52+
Always use TypeScript for type safety:
53+
54+
```typescript
55+
// ✅ Good: Explicit types
56+
interface UserData {
57+
name: string;
58+
email: string;
59+
role: 'admin' | 'user';
60+
}
61+
62+
const updateUser = async (userId: string, data: UserData): Promise<void> => {
63+
// Implementation
64+
};
65+
66+
// ❌ Bad: Using 'any'
67+
const updateUser = async (userId: any, data: any): Promise<any> => {
68+
// Implementation
69+
};
70+
```
71+
72+
### 2. Handle Errors Gracefully
73+
74+
Always handle potential errors:
75+
76+
```typescript
77+
// ✅ Good: Proper error handling
78+
try {
79+
const result = await functionCall();
80+
return result;
81+
} catch (error) {
82+
console.error('Operation failed:', error);
83+
throw new Error('User-friendly error message');
84+
}
85+
86+
// ❌ Bad: No error handling
87+
const result = await functionCall();
88+
return result;
89+
```
90+
91+
### 3. Optimize Performance
92+
93+
Use React best practices for performance:
94+
95+
```typescript
96+
// ✅ Good: Memoization
97+
const ExpensiveComponent = React.memo(({ data }) => {
98+
const processedData = useMemo(() => {
99+
return expensiveCalculation(data);
100+
}, [data]);
101+
102+
return <div>{processedData}</div>;
103+
});
104+
105+
// ❌ Bad: No optimization
106+
const ExpensiveComponent = ({ data }) => {
107+
const processedData = expensiveCalculation(data); // Runs on every render
108+
return <div>{processedData}</div>;
109+
};
110+
```
111+
112+
### 4. Secure Your Application
113+
114+
Implement proper security measures:
115+
116+
```typescript
117+
// ✅ Good: Check permissions
118+
const deleteSubscription = functions.https.onCall(async (data, context) => {
119+
if (!context.auth) {
120+
throw new functions.https.HttpsError('unauthenticated', 'Must be logged in');
121+
}
122+
123+
const isOwner = await checkSubscriptionOwnership(
124+
context.auth.uid,
125+
data.subscriptionId
126+
);
127+
128+
if (!isOwner) {
129+
throw new functions.https.HttpsError('permission-denied', 'Not authorized');
130+
}
131+
132+
// Proceed with deletion
133+
});
134+
135+
// ❌ Bad: No permission checks
136+
const deleteSubscription = functions.https.onCall(async (data, context) => {
137+
await admin.firestore().collection('subscriptions').doc(data.subscriptionId).delete();
138+
});
139+
```
140+
141+
### 5. Write Maintainable Code
142+
143+
Keep code clean and maintainable:
144+
145+
```typescript
146+
// ✅ Good: Small, focused functions with clear names
147+
const validateEmail = (email: string): boolean => {
148+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
149+
return emailRegex.test(email);
150+
};
151+
152+
const sendWelcomeEmail = async (userEmail: string): Promise<void> => {
153+
if (!validateEmail(userEmail)) {
154+
throw new Error('Invalid email address');
155+
}
156+
// Send email logic
157+
};
158+
159+
// ❌ Bad: Large function doing multiple things
160+
const processUser = async (data: any) => {
161+
// Validation
162+
if (!data.email || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(data.email)) {
163+
throw new Error('Invalid email');
164+
}
165+
// Database operation
166+
await db.collection('users').doc(data.id).set(data);
167+
// Send email
168+
await emailService.send(data.email, 'Welcome!');
169+
// Log event
170+
console.log('User processed:', data.id);
171+
};
172+
```
173+
174+
## Quick Reference Checklist
175+
176+
### Before Deploying
177+
178+
- [ ] All TypeScript errors resolved
179+
- [ ] Security rules tested and deployed
180+
- [ ] Environment variables configured
181+
- [ ] Error handling implemented
182+
- [ ] Loading states added to UI
183+
- [ ] Performance optimized
184+
- [ ] Tests passing
185+
- [ ] Documentation updated
186+
187+
### Code Quality
188+
189+
- [ ] Consistent naming conventions
190+
- [ ] Comments for complex logic
191+
- [ ] No console.logs in production
192+
- [ ] Proper error messages
193+
- [ ] TypeScript types defined
194+
- [ ] Code formatted with ESLint
195+
196+
### Security
197+
198+
- [ ] Authentication required for protected routes
199+
- [ ] Permissions checked in Cloud Functions
200+
- [ ] Firestore rules properly configured
201+
- [ ] Sensitive data not exposed
202+
- [ ] API keys in environment variables
203+
- [ ] Input validation implemented
204+
205+
### Performance
206+
207+
- [ ] Images optimized
208+
- [ ] Code splitting implemented
209+
- [ ] Database queries optimized
210+
- [ ] React components memoized where needed
211+
- [ ] Unnecessary re-renders eliminated
212+
213+
## Contributing
214+
215+
Have best practices to share? See our [Contributing Guide](https://github.com/fireact-dev/fireact.dev/blob/main/CONTRIBUTING.md) to submit your suggestions.

0 commit comments

Comments
 (0)