Skip to content

Commit 3f70837

Browse files
Merge pull request #18 from stellar-nexus-experience/development
Development to prod (fix referral system, clean code, optimize and make more fluid and smoothly UX)
2 parents feb0dd8 + 43ec1bf commit 3f70837

File tree

105 files changed

+8673
-6147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+8673
-6147
lines changed

README.md

Lines changed: 138 additions & 84 deletions
Large diffs are not rendered by default.

analytics/README.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Analytics System
22

3-
A comprehensive analytics system for tracking platform performance, user engagement, and mandatory feedback statistics.
3+
A comprehensive analytics system for tracking platform performance, user
4+
engagement, and mandatory feedback statistics.
45

56
## Overview
67

78
The analytics system provides insights into:
9+
810
- Platform-wide statistics and performance metrics
911
- User account analytics and engagement tracking
1012
- Mandatory feedback analysis and trends
@@ -29,6 +31,7 @@ The analytics system provides insights into:
2931
### Types
3032

3133
Comprehensive TypeScript interfaces for:
34+
3235
- Platform statistics
3336
- Account analytics
3437
- Feedback analytics
@@ -38,27 +41,31 @@ Comprehensive TypeScript interfaces for:
3841
## Features
3942

4043
### Platform Analytics
44+
4145
- Total users and accounts
4246
- Demo completion statistics
4347
- Badge and points tracking
4448
- User engagement metrics
4549
- Performance indicators
4650

4751
### Account Analytics
52+
4853
- User account management
4954
- Engagement scoring
5055
- Activity tracking
5156
- Sorting and filtering
5257
- Search functionality
5358

5459
### Feedback Analytics
60+
5561
- Rating distribution
5662
- Difficulty analysis
5763
- Demo-specific feedback
5864
- Recent feedback display
5965
- Recommendation rates
6066

6167
### Navigation
68+
6269
- Tabbed interface
6370
- Responsive design
6471
- Mobile-friendly navigation
@@ -67,16 +74,19 @@ Comprehensive TypeScript interfaces for:
6774
## Usage
6875

6976
### Accessing Analytics
77+
7078
Navigate to `/analytics` or click the "Analytics" link in the header navigation.
7179

7280
### Dashboard Views
81+
7382
- **Overview** - Platform-wide statistics
7483
- **Users** - Account analytics and management
7584
- **Feedback** - Mandatory feedback analysis
7685
- **Demos** - Demo performance metrics (coming soon)
7786
- **Engagement** - User engagement insights (coming soon)
7887

7988
### Data Sources
89+
8090
- Firebase Firestore collections
8191
- Mandatory feedback collection
8292
- Account data
@@ -86,18 +96,21 @@ Navigate to `/analytics` or click the "Analytics" link in the header navigation.
8696
## Implementation Details
8797

8898
### Data Flow
99+
89100
1. Analytics components request data from AnalyticsService
90101
2. AnalyticsService aggregates data from multiple Firebase services
91102
3. Data is processed and formatted for display
92103
4. Components render analytics with loading and error states
93104

94105
### Performance Considerations
106+
95107
- Lazy loading of analytics data
96108
- Efficient data aggregation
97109
- Caching strategies (future enhancement)
98110
- Pagination for large datasets
99111

100112
### Security
113+
101114
- User authentication required
102115
- Admin-level access for sensitive analytics
103116
- Data privacy compliance
@@ -106,6 +119,7 @@ Navigate to `/analytics` or click the "Analytics" link in the header navigation.
106119
## Future Enhancements
107120

108121
### Planned Features
122+
109123
- Real-time analytics updates
110124
- Advanced filtering and search
111125
- Export functionality
@@ -114,6 +128,7 @@ Navigate to `/analytics` or click the "Analytics" link in the header navigation.
114128
- Automated reporting
115129

116130
### Technical Improvements
131+
117132
- Data caching
118133
- Performance optimization
119134
- Error handling improvements
@@ -171,9 +186,12 @@ interface FeedbackAnalyticsProps {
171186
## Configuration
172187

173188
### Environment Variables
174-
No additional environment variables required. Uses existing Firebase configuration.
189+
190+
No additional environment variables required. Uses existing Firebase
191+
configuration.
175192

176193
### Dependencies
194+
177195
- React 18+
178196
- TypeScript
179197
- Firebase SDK
@@ -182,28 +200,34 @@ No additional environment variables required. Uses existing Firebase configurati
182200
## Troubleshooting
183201

184202
### Common Issues
203+
185204
1. **No data displayed** - Check Firebase connection and permissions
186205
2. **Slow loading** - Consider implementing data caching
187206
3. **Permission errors** - Verify user authentication and admin access
188207

189208
### Debug Mode
190-
Enable debug logging by setting `localStorage.setItem('analytics-debug', 'true')` in browser console.
209+
210+
Enable debug logging by setting
211+
`localStorage.setItem('analytics-debug', 'true')` in browser console.
191212

192213
## Contributing
193214

194215
### Development Setup
216+
195217
1. Ensure Firebase is properly configured
196218
2. Install dependencies: `npm install`
197219
3. Start development server: `npm run dev`
198220
4. Navigate to `/analytics` to test
199221

200222
### Code Style
223+
201224
- Follow existing TypeScript conventions
202225
- Use Tailwind CSS for styling
203226
- Implement proper error handling
204227
- Add loading states for async operations
205228

206229
### Testing
230+
207231
- Test with different user roles
208232
- Verify responsive design
209233
- Check data accuracy

analytics/components/AccountAnalytics.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,29 @@ export const AccountAnalytics: React.FC<AccountAnalyticsProps> = ({ className =
2323
const getThemeClasses = () => {
2424
if (theme === 'light') {
2525
return {
26-
container: 'bg-gradient-to-br from-white to-gray-50 border-gray-200/50 text-gray-800 backdrop-blur-sm rounded-2xl shadow-2xl',
26+
container:
27+
'bg-gradient-to-br from-white to-gray-50 border-gray-200/50 text-gray-800 backdrop-blur-sm rounded-2xl shadow-2xl',
2728
card: 'bg-gradient-to-br from-white to-gray-50 border-gray-200/50 hover:from-gray-50 hover:to-gray-100 backdrop-blur-sm rounded-xl shadow-lg',
2829
text: 'text-gray-800',
2930
textSecondary: 'text-gray-600',
3031
textMuted: 'text-gray-500',
3132
input: 'bg-white border-gray-300 text-gray-800 placeholder-gray-500',
3233
select: 'bg-white border-gray-300 text-gray-800',
33-
statsCard: 'bg-gradient-to-br from-white to-gray-50 border-gray-200/50 backdrop-blur-sm rounded-xl shadow-lg',
34+
statsCard:
35+
'bg-gradient-to-br from-white to-gray-50 border-gray-200/50 backdrop-blur-sm rounded-xl shadow-lg',
3436
};
3537
} else {
3638
return {
37-
container: 'bg-gradient-to-br from-slate-900 to-slate-800 border-white/20 text-white backdrop-blur-sm rounded-2xl shadow-2xl',
39+
container:
40+
'bg-gradient-to-br from-slate-900 to-slate-800 border-white/20 text-white backdrop-blur-sm rounded-2xl shadow-2xl',
3841
card: 'bg-gradient-to-br from-slate-800/60 to-slate-900/60 border-white/20 hover:from-slate-700/60 hover:to-slate-800/60 backdrop-blur-sm rounded-xl shadow-lg',
3942
text: 'text-white',
4043
textSecondary: 'text-gray-300',
4144
textMuted: 'text-gray-400',
4245
input: 'bg-white/5 border-white/20 text-white placeholder-gray-400',
4346
select: 'bg-white/5 border-white/20 text-white',
44-
statsCard: 'bg-gradient-to-br from-slate-800/60 to-slate-900/60 border-white/20 backdrop-blur-sm rounded-xl shadow-lg',
47+
statsCard:
48+
'bg-gradient-to-br from-slate-800/60 to-slate-900/60 border-white/20 backdrop-blur-sm rounded-xl shadow-lg',
4549
};
4650
}
4751
};
@@ -203,23 +207,23 @@ export const AccountAnalytics: React.FC<AccountAnalyticsProps> = ({ className =
203207

204208
{/* Summary Stats */}
205209
<div className='grid grid-cols-2 md:grid-cols-4 gap-4 mb-6'>
206-
<div className={`p-3 ${themeClasses.statsCard}`}>
210+
<div className={`p-3 ${themeClasses.statsCard}`}>
207211
<p className={`text-2xl font-bold ${themeClasses.text}`}>{accounts.length}</p>
208212
<p className={`text-sm ${themeClasses.textSecondary}`}>Total Users</p>
209213
</div>
210-
<div className={`p-3 ${themeClasses.statsCard}`}>
214+
<div className={`p-3 ${themeClasses.statsCard}`}>
211215
<p className='text-2xl font-bold text-green-600'>
212216
{accounts.filter(a => a.isActive).length}
213217
</p>
214218
<p className={`text-sm ${themeClasses.textSecondary}`}>Active Users</p>
215219
</div>
216-
<div className={`p-3 ${themeClasses.statsCard}`}>
220+
<div className={`p-3 ${themeClasses.statsCard}`}>
217221
<p className='text-2xl font-bold text-blue-600'>
218222
{accounts.reduce((sum, a) => sum + a.totalPoints, 0).toLocaleString()}
219223
</p>
220224
<p className={`text-sm ${themeClasses.textSecondary}`}>Total Points</p>
221225
</div>
222-
<div className={`p-3 ${themeClasses.statsCard}`}>
226+
<div className={`p-3 ${themeClasses.statsCard}`}>
223227
<p className='text-2xl font-bold text-purple-600'>
224228
{accounts.reduce((sum, a) => sum + a.demosCompleted.length, 0)}
225229
</p>

analytics/components/AnalyticsDashboard.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ export const AnalyticsDashboard: React.FC<AnalyticsDashboardProps> = ({ classNam
9696
<div className={themeClasses.headerContainer}>
9797
<div className='flex items-center justify-between'>
9898
<div>
99-
<div className='flex items-center space-x-2 cursor-pointer' onClick={() => router.push('/')}>
99+
<div
100+
className='flex items-center space-x-2 cursor-pointer'
101+
onClick={() => router.push('/')}
102+
>
100103
<Image src='/images/logo/logoicon.png' alt='Nexus Logo' width={100} height={100} />
101104
<Image src='/images/logo/iconletter.png' alt='Nexus Logo' width={100} height={100} />
102105
</div>
@@ -129,9 +132,11 @@ export const AnalyticsDashboard: React.FC<AnalyticsDashboardProps> = ({ classNam
129132
<span className='mr-2'>{view.icon}</span>
130133
{view.label}
131134
{view.comingSoon && (
132-
<div className={`absolute -top-2 -right-2 bg-gradient-to-r from-orange-400 to-red-500 text-white text-xs font-bold px-2 py-1 rounded-full border-2 ${
133-
theme === 'light' ? 'border-white' : 'border-gray-900'
134-
} animate-pulse shadow-lg`}>
135+
<div
136+
className={`absolute -top-2 -right-2 bg-gradient-to-r from-orange-400 to-red-500 text-white text-xs font-bold px-2 py-1 rounded-full border-2 ${
137+
theme === 'light' ? 'border-white' : 'border-gray-900'
138+
} animate-pulse shadow-lg`}
139+
>
135140
Soon
136141
</div>
137142
)}

analytics/components/FeedbackAnalytics.tsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@ export const FeedbackAnalytics: React.FC<FeedbackAnalyticsProps> = ({ className
1919
const getThemeClasses = () => {
2020
if (theme === 'light') {
2121
return {
22-
container: 'bg-gradient-to-br from-white to-gray-50 border-gray-200/50 text-gray-800 backdrop-blur-sm rounded-2xl shadow-2xl',
22+
container:
23+
'bg-gradient-to-br from-white to-gray-50 border-gray-200/50 text-gray-800 backdrop-blur-sm rounded-2xl shadow-2xl',
2324
card: 'bg-gradient-to-br from-white to-gray-50 border-gray-200/50 hover:from-gray-50 hover:to-gray-100 backdrop-blur-sm rounded-xl shadow-lg',
2425
text: 'text-gray-800',
2526
textSecondary: 'text-gray-600',
2627
textMuted: 'text-gray-500',
2728
};
2829
} else {
2930
return {
30-
container: 'bg-gradient-to-br from-slate-900 to-slate-800 border-white/20 text-white backdrop-blur-sm rounded-2xl shadow-2xl',
31+
container:
32+
'bg-gradient-to-br from-slate-900 to-slate-800 border-white/20 text-white backdrop-blur-sm rounded-2xl shadow-2xl',
3133
card: 'bg-gradient-to-br from-slate-800/60 to-slate-900/60 border-white/20 hover:from-slate-700/60 hover:to-slate-800/60 backdrop-blur-sm rounded-xl shadow-lg',
3234
text: 'text-white',
3335
textSecondary: 'text-gray-300',
@@ -105,7 +107,7 @@ export const FeedbackAnalytics: React.FC<FeedbackAnalyticsProps> = ({ className
105107
return (
106108
<div className={`space-y-6 ${className}`}>
107109
{/* Overview Stats */}
108-
<div className={`p-6 ${themeClasses.container}`}>
110+
<div className={`p-6 ${themeClasses.container}`}>
109111
<h2 className={`text-xl font-semibold ${themeClasses.text} mb-6`}>Feedback Overview</h2>
110112

111113
<div className='grid grid-cols-2 md:grid-cols-4 gap-4'>
@@ -141,7 +143,7 @@ export const FeedbackAnalytics: React.FC<FeedbackAnalyticsProps> = ({ className
141143
</div>
142144

143145
{/* Rating Distribution */}
144-
<div className={`p-6 ${themeClasses.container}`}>
146+
<div className={`p-6 ${themeClasses.container}`}>
145147
<h2 className={`text-xl font-semibold ${themeClasses.text} mb-6`}>Rating Distribution</h2>
146148

147149
<div className='space-y-3'>
@@ -178,7 +180,7 @@ export const FeedbackAnalytics: React.FC<FeedbackAnalyticsProps> = ({ className
178180
</div>
179181

180182
{/* Difficulty Distribution */}
181-
<div className={`p-6 ${themeClasses.container}`}>
183+
<div className={`p-6 ${themeClasses.container}`}>
182184
<h2 className={`text-xl font-semibold ${themeClasses.text} mb-6`}>
183185
Difficulty Distribution
184186
</h2>
@@ -195,10 +197,7 @@ export const FeedbackAnalytics: React.FC<FeedbackAnalyticsProps> = ({ className
195197
};
196198

197199
return (
198-
<div
199-
key={difficulty}
200-
className={`p-4 ${themeClasses.card}`}
201-
>
200+
<div key={difficulty} className={`p-4 ${themeClasses.card}`}>
202201
<div className='text-center'>
203202
<p className={`text-2xl font-bold ${themeClasses.text}`}>{count}</p>
204203
<p className={`text-sm ${themeClasses.textMuted} capitalize`}>{difficulty}</p>
@@ -221,7 +220,7 @@ export const FeedbackAnalytics: React.FC<FeedbackAnalyticsProps> = ({ className
221220
</div>
222221

223222
{/* Feedback by Demo */}
224-
<div className={`p-6 ${themeClasses.container}`}>
223+
<div className={`p-6 ${themeClasses.container}`}>
225224
<h2 className={`text-xl font-semibold ${themeClasses.text} mb-6`}>Feedback by Demo</h2>
226225

227226
<div className='space-y-4'>
@@ -267,7 +266,7 @@ export const FeedbackAnalytics: React.FC<FeedbackAnalyticsProps> = ({ className
267266
</div>
268267

269268
{/* Recent Feedback */}
270-
<div className={`p-6 ${themeClasses.container}`}>
269+
<div className={`p-6 ${themeClasses.container}`}>
271270
<h2 className={`text-xl font-semibold ${themeClasses.text} mb-6`}>Recent Feedback</h2>
272271

273272
<div className='space-y-3'>
@@ -339,12 +338,14 @@ const StatCard: React.FC<StatCardProps> = ({ title, value, icon, color, theme })
339338
const themeClasses =
340339
theme === 'light'
341340
? {
342-
container: 'bg-gradient-to-br from-white to-gray-50 border-gray-200/50 hover:from-gray-50 hover:to-gray-100 backdrop-blur-sm rounded-xl shadow-lg',
341+
container:
342+
'bg-gradient-to-br from-white to-gray-50 border-gray-200/50 hover:from-gray-50 hover:to-gray-100 backdrop-blur-sm rounded-xl shadow-lg',
343343
text: 'text-gray-800',
344344
textSecondary: 'text-gray-600',
345345
}
346346
: {
347-
container: 'bg-gradient-to-br from-slate-800/60 to-slate-900/60 border-white/20 hover:from-slate-700/60 hover:to-slate-800/60 backdrop-blur-sm rounded-xl shadow-lg',
347+
container:
348+
'bg-gradient-to-br from-slate-800/60 to-slate-900/60 border-white/20 hover:from-slate-700/60 hover:to-slate-800/60 backdrop-blur-sm rounded-xl shadow-lg',
348349
text: 'text-white',
349350
textSecondary: 'text-gray-300',
350351
};

analytics/components/PlatformAnalytics.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ export const PlatformAnalytics: React.FC<PlatformAnalyticsProps> = ({ className
130130
};
131131
} else {
132132
return {
133-
container: 'p-6 bg-gradient-to-br from-slate-900 to-slate-800 backdrop-blur-sm rounded-2xl border border-white/20 shadow-2xl',
133+
container:
134+
'p-6 bg-gradient-to-br from-slate-900 to-slate-800 backdrop-blur-sm rounded-2xl border border-white/20 shadow-2xl',
134135
card: 'p-4 bg-gradient-to-br from-slate-800/60 to-slate-900/60 backdrop-blur-sm rounded-xl border border-white/20 hover:from-slate-700/60 hover:to-slate-800/60 shadow-lg',
135136
text: 'text-white',
136137
textSecondary: 'text-gray-300',
@@ -342,8 +343,8 @@ export const PlatformAnalytics: React.FC<PlatformAnalyticsProps> = ({ className
342343
</div>
343344
<div className='text-right'>
344345
<p className={`${themeClasses.text} font-medium`}>
345-
{user.totalPoints.toLocaleString()} pts /
346-
{(user.experience || 0).toLocaleString()} XP
346+
{user.totalPoints.toLocaleString()} pts /{(user.experience || 0).toLocaleString()}{' '}
347+
XP
347348
</p>
348349
<p className={`${themeClasses.textMuted} text-sm`}>
349350
{user.demosCompleted} demos, {user.badgesEarned} badges

0 commit comments

Comments
 (0)