ntc-dev-kit 1.0.0__py3-none-any.whl
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.
- ntc/__init__.py +5 -0
- ntc/app_creator.py +296 -0
- ntc/cli.py +4 -0
- ntc/cli_enhanced.py +820 -0
- ntc/composer/__init__.py +0 -0
- ntc/composer/main.py +443 -0
- ntc/deployment/__init__.py +0 -0
- ntc/templates/__init__.py +2 -0
- ntc/templates/auth_app/__init__.py +0 -0
- ntc/templates/auth_app/admin.py +24 -0
- ntc/templates/auth_app/apps.py +6 -0
- ntc/templates/auth_app/models.py +30 -0
- ntc/templates/auth_app/serializers.py +101 -0
- ntc/templates/auth_app/urls.py +19 -0
- ntc/templates/auth_app/views.py +175 -0
- ntc/templates/drf_structure/__init__.py +1 -0
- ntc/templates/drf_structure/drf_structure.md +83 -0
- ntc/templates/drf_structure/main.py +389 -0
- ntc/templates/drf_structure/structure.json +126 -0
- ntc/templates/drf_structure/templates/.entry/start_core_backend.sh +37 -0
- ntc/templates/drf_structure/templates/.entry/start_tasks_backend.sh +30 -0
- ntc/templates/drf_structure/templates/CLAUDE.md +194 -0
- ntc/templates/drf_structure/templates/README.md +117 -0
- ntc/templates/drf_structure/templates/apps/app_admin.py +3 -0
- ntc/templates/drf_structure/templates/apps/app_apps.py +6 -0
- ntc/templates/drf_structure/templates/apps/app_models.py +4 -0
- ntc/templates/drf_structure/templates/apps/app_urls.py +8 -0
- ntc/templates/drf_structure/templates/apps/app_views.py +6 -0
- ntc/templates/drf_structure/templates/apps/common_apps.py +6 -0
- ntc/templates/drf_structure/templates/apps/common_models.py +8 -0
- ntc/templates/drf_structure/templates/config/gunicorn_config.py +9 -0
- ntc/templates/drf_structure/templates/config/http.conf +33 -0
- ntc/templates/drf_structure/templates/core/base_model.py +9 -0
- ntc/templates/drf_structure/templates/core/formatter.py +5 -0
- ntc/templates/drf_structure/templates/core/logger.py +8 -0
- ntc/templates/drf_structure/templates/core/pagination.py +6 -0
- ntc/templates/drf_structure/templates/core/response_wrapper.py +7 -0
- ntc/templates/drf_structure/templates/core/services/azure/email/backend.py +108 -0
- ntc/templates/drf_structure/templates/core/services/azure/email/client.py +296 -0
- ntc/templates/drf_structure/templates/core/services/azure/email/notifier.py +102 -0
- ntc/templates/drf_structure/templates/core/services/object_storage.py +285 -0
- ntc/templates/drf_structure/templates/django_project/asgi.py +5 -0
- ntc/templates/drf_structure/templates/django_project/celery.py +8 -0
- ntc/templates/drf_structure/templates/django_project/dev_settings.py +2 -0
- ntc/templates/drf_structure/templates/django_project/django_settings.txt +322 -0
- ntc/templates/drf_structure/templates/django_project/management_command.py +114 -0
- ntc/templates/drf_structure/templates/django_project/prod_settings.py +3 -0
- ntc/templates/drf_structure/templates/django_project/schema.py +7 -0
- ntc/templates/drf_structure/templates/django_project/urls.py +6 -0
- ntc/templates/drf_structure/templates/django_project/wsgi.py +5 -0
- ntc/templates/drf_structure/templates/docker/docker-compose.yml +11 -0
- ntc/templates/drf_structure/templates/knowledge/knowledge_description.md +201 -0
- ntc/templates/drf_structure/templates/knowledge/knowledge_design_pattern.md +722 -0
- ntc/templates/drf_structure/templates/knowledge/knowledge_structure.md +151 -0
- ntc/templates/drf_structure/templates/root/README.md +307 -0
- ntc/templates/drf_structure/templates/root/django_env.txt +98 -0
- ntc/templates/drf_structure/templates/root/django_requirements.txt +24 -0
- ntc/templates/drf_structure/templates/root/gitignore.txt +6 -0
- ntc/templates/drf_structure/templates/root/manage.py +11 -0
- ntc/templates/flutter/.gitignore +44 -0
- ntc/templates/flutter/.knowledge/knowledge_description.md +215 -0
- ntc/templates/flutter/.knowledge/knowledge_design_pattern.md +310 -0
- ntc/templates/flutter/.knowledge/knowledge_structure.md +83 -0
- ntc/templates/flutter/CLAUDE.md +190 -0
- ntc/templates/flutter/__init__.py +0 -0
- ntc/templates/flutter/analysis_options.yaml +9 -0
- ntc/templates/flutter/main.py +187 -0
- ntc/templates/flutter/pubspec.yaml +65 -0
- ntc/templates/flutter/structure.json +51 -0
- ntc/templates/nextjs/.env.example +10 -0
- ntc/templates/nextjs/.gitignore +36 -0
- ntc/templates/nextjs/CLAUDE.md +181 -0
- ntc/templates/nextjs/README.md +94 -0
- ntc/templates/nextjs/__init__.py +0 -0
- ntc/templates/nextjs/knowledge/knowledge_description.md +208 -0
- ntc/templates/nextjs/knowledge/knowledge_design_pattern.md +460 -0
- ntc/templates/nextjs/knowledge/knowledge_structure.md +75 -0
- ntc/templates/nextjs/main.py +224 -0
- ntc/templates/nextjs/package.json +25 -0
- ntc/templates/nextjs/src/app/globals.css +26 -0
- ntc/templates/nextjs/src/app/layout.tsx +59 -0
- ntc/templates/nextjs/src/app/page.tsx +21 -0
- ntc/templates/nextjs/src/components/Header.tsx +16 -0
- ntc/templates/nextjs/src/services/api.ts +81 -0
- ntc/templates/nextjs/src/utils/constants.ts +1 -0
- ntc/templates/nextjs/structure.json +32 -0
- ntc/templates/nextjs/tsconfig.json +27 -0
- ntc/templates/react_admin/.env.example +1 -0
- ntc/templates/react_admin/.gitignore +10 -0
- ntc/templates/react_admin/CLAUDE.md +210 -0
- ntc/templates/react_admin/README.md +72 -0
- ntc/templates/react_admin/__init__.py +0 -0
- ntc/templates/react_admin/index.html +13 -0
- ntc/templates/react_admin/knowledge/knowledge_description.md +202 -0
- ntc/templates/react_admin/knowledge/knowledge_design_pattern.md +448 -0
- ntc/templates/react_admin/knowledge/knowledge_structure.md +97 -0
- ntc/templates/react_admin/main.py +208 -0
- ntc/templates/react_admin/package.json +35 -0
- ntc/templates/react_admin/src/App.tsx +60 -0
- ntc/templates/react_admin/src/components/ProtectedRoute.tsx +16 -0
- ntc/templates/react_admin/src/components/Sidebar.tsx +90 -0
- ntc/templates/react_admin/src/components/TopNav.tsx +44 -0
- ntc/templates/react_admin/src/context/AuthContext.tsx +107 -0
- ntc/templates/react_admin/src/context/ThemeContext.tsx +34 -0
- ntc/templates/react_admin/src/context/WorkspaceContext.tsx +28 -0
- ntc/templates/react_admin/src/hooks/useApi.ts +39 -0
- ntc/templates/react_admin/src/index.css +34 -0
- ntc/templates/react_admin/src/layouts/AuthLayout.tsx +23 -0
- ntc/templates/react_admin/src/layouts/DashboardLayout.tsx +24 -0
- ntc/templates/react_admin/src/main.tsx +5 -0
- ntc/templates/react_admin/src/pages/DashboardPage.tsx +10 -0
- ntc/templates/react_admin/src/pages/auth/LoginPage.tsx +79 -0
- ntc/templates/react_admin/src/pages/auth/RegisterPage.tsx +93 -0
- ntc/templates/react_admin/src/services/api.service.ts +44 -0
- ntc/templates/react_admin/src/services/base.service.ts +193 -0
- ntc/templates/react_admin/structure.json +52 -0
- ntc/templates/react_admin/tsconfig.app.json +25 -0
- ntc/templates/react_admin/tsconfig.json +7 -0
- ntc/templates/react_admin/tsconfig.node.json +19 -0
- ntc/templates/react_admin/vite.config.ts +13 -0
- ntc/templates/react_structure/CLAUDE.md +176 -0
- ntc/templates/react_structure/__init__.py +1 -0
- ntc/templates/react_structure/index.css +21 -0
- ntc/templates/react_structure/index.html +13 -0
- ntc/templates/react_structure/knowledge/knowledge_description.md +170 -0
- ntc/templates/react_structure/knowledge/knowledge_design_pattern.md +411 -0
- ntc/templates/react_structure/knowledge/knowledge_structure.md +74 -0
- ntc/templates/react_structure/main.py +217 -0
- ntc/templates/react_structure/package.json +32 -0
- ntc/templates/react_structure/src/App.tsx +63 -0
- ntc/templates/react_structure/src/components/Header.tsx +51 -0
- ntc/templates/react_structure/src/main.tsx +5 -0
- ntc/templates/react_structure/src/services/api.ts +90 -0
- ntc/templates/react_structure/src/utils/constants.ts +1 -0
- ntc/templates/react_structure/structure.json +65 -0
- ntc/templates/react_structure/tsconfig.app.json +25 -0
- ntc/templates/react_structure/tsconfig.json +7 -0
- ntc/templates/react_structure/tsconfig.node.json +19 -0
- ntc/templates/react_structure/vite.config.ts +12 -0
- ntc/utils/__init__.py +1 -0
- ntc/utils/environment.py +67 -0
- ntc/utils/output.py +41 -0
- ntc_dev_kit-1.0.0.dist-info/METADATA +188 -0
- ntc_dev_kit-1.0.0.dist-info/RECORD +148 -0
- ntc_dev_kit-1.0.0.dist-info/WHEEL +5 -0
- ntc_dev_kit-1.0.0.dist-info/entry_points.txt +2 -0
- ntc_dev_kit-1.0.0.dist-info/licenses/LICENSE +21 -0
- ntc_dev_kit-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# AI Agent Instructions for NTC-Generated React Projects
|
|
2
|
+
|
|
3
|
+
This document provides specific instructions for AI agents (Claude, GPT, etc.) working with NTC-generated React + TypeScript + Vite projects.
|
|
4
|
+
|
|
5
|
+
## 📖 Knowledge Base Reading Order
|
|
6
|
+
|
|
7
|
+
When first approaching this codebase, AI agents should read the knowledge files in this order:
|
|
8
|
+
|
|
9
|
+
1. **CLAUDE.md** (this file) - AI agent specific instructions
|
|
10
|
+
2. **.knowledge/knowledge_structure.md** - Project structure and organization
|
|
11
|
+
3. **.knowledge/knowledge_description.md** - Architecture overview and technical stack
|
|
12
|
+
4. **.knowledge/knowledge_design_pattern.md** - Design patterns and coding conventions
|
|
13
|
+
|
|
14
|
+
## 🤖 AI Agent Guidelines
|
|
15
|
+
|
|
16
|
+
### Before Making Changes
|
|
17
|
+
|
|
18
|
+
1. **Read the Knowledge Base**: Always read the knowledge files before making any changes to understand the project structure and conventions.
|
|
19
|
+
|
|
20
|
+
2. **Understand the NTC Structure**: This project follows the NTC (Nexent Toolkit Console) structure with TypeScript, Vite, and modern React patterns.
|
|
21
|
+
|
|
22
|
+
3. **Check Existing Implementations**: Before adding new features, check if similar implementations already exist in `src/components/` or `src/services/`.
|
|
23
|
+
|
|
24
|
+
### Code Modification Rules
|
|
25
|
+
|
|
26
|
+
1. **Use TypeScript Strict Mode**: All code must use TypeScript with strict mode enabled. Avoid `any` types whenever possible.
|
|
27
|
+
|
|
28
|
+
2. **Follow Component Patterns**:
|
|
29
|
+
- Functional components with hooks
|
|
30
|
+
- Use TypeScript interfaces for props
|
|
31
|
+
- Keep components small and focused
|
|
32
|
+
- Use proper TypeScript types for all variables and functions
|
|
33
|
+
|
|
34
|
+
3. **API Integration**:
|
|
35
|
+
- Use the `apiService` from `src/services/api.ts` for all API calls
|
|
36
|
+
- Use `authService` for authentication operations
|
|
37
|
+
- Handle loading and error states properly
|
|
38
|
+
- Use async/await for asynchronous operations
|
|
39
|
+
|
|
40
|
+
4. **Environment Variables**:
|
|
41
|
+
- Use `import.meta.env.VITE_*` for environment variables
|
|
42
|
+
- All configuration should use environment variables, never hardcode values
|
|
43
|
+
- Define types for environment variables in a separate file if needed
|
|
44
|
+
|
|
45
|
+
5. **Follow Naming Conventions**:
|
|
46
|
+
- Components: `PascalCase` (e.g., `UserProfile`)
|
|
47
|
+
- Functions/Hooks: `camelCase` (e.g., `useUserProfile`)
|
|
48
|
+
- Files: `PascalCase` for components, `camelCase` for utilities
|
|
49
|
+
- Constants: `UPPER_SNAKE_CASE`
|
|
50
|
+
|
|
51
|
+
### SEO Best Practices
|
|
52
|
+
|
|
53
|
+
1. **Meta Tags**: Always include proper meta tags for SEO:
|
|
54
|
+
- Title, description, keywords
|
|
55
|
+
- Open Graph tags for social sharing
|
|
56
|
+
- Twitter Card tags
|
|
57
|
+
- Canonical URLs
|
|
58
|
+
|
|
59
|
+
2. **Performance**:
|
|
60
|
+
- Use React.memo for expensive components
|
|
61
|
+
- Implement code splitting with React.lazy and Suspense
|
|
62
|
+
- Optimize images with proper alt text
|
|
63
|
+
- Use semantic HTML elements
|
|
64
|
+
|
|
65
|
+
3. **Accessibility**:
|
|
66
|
+
- Use ARIA labels where needed
|
|
67
|
+
- Ensure keyboard navigation works
|
|
68
|
+
- Use proper heading hierarchy
|
|
69
|
+
- Provide alt text for images
|
|
70
|
+
|
|
71
|
+
### External Service Integration
|
|
72
|
+
|
|
73
|
+
1. **API Communication**:
|
|
74
|
+
- Use the configured axios instance in `apiService`
|
|
75
|
+
- Handle authentication with JWT tokens via `authService`
|
|
76
|
+
- Implement proper error handling and user feedback
|
|
77
|
+
- Use loading states for async operations
|
|
78
|
+
|
|
79
|
+
2. **State Management**:
|
|
80
|
+
- Use React hooks for local state
|
|
81
|
+
- Consider using React Context or a state library for global state
|
|
82
|
+
- Keep state as close to where it's used as possible
|
|
83
|
+
|
|
84
|
+
### Development Workflow
|
|
85
|
+
|
|
86
|
+
1. **Running the Project**:
|
|
87
|
+
- Install dependencies: `npm install`
|
|
88
|
+
- Run development server: `npm run dev`
|
|
89
|
+
- Build for production: `npm run build`
|
|
90
|
+
- Preview production build: `npm run preview`
|
|
91
|
+
|
|
92
|
+
2. **Adding New Components**:
|
|
93
|
+
- Place in `src/components/` for reusable components
|
|
94
|
+
- Place in `src/pages/` for page-level components
|
|
95
|
+
- Follow the existing component patterns
|
|
96
|
+
- Include TypeScript interfaces for props
|
|
97
|
+
|
|
98
|
+
3. **Adding API Services**:
|
|
99
|
+
- Add endpoint methods to `src/services/api.ts`
|
|
100
|
+
- Use the existing `apiClient` with interceptors
|
|
101
|
+
- Follow the existing service patterns
|
|
102
|
+
- Include proper TypeScript types
|
|
103
|
+
|
|
104
|
+
### Testing
|
|
105
|
+
|
|
106
|
+
1. **Test Structure**: Each component should have corresponding test files in the same directory or in a `__tests__` directory.
|
|
107
|
+
|
|
108
|
+
2. **Run Tests**: Use `npm test` to run the test suite (when configured).
|
|
109
|
+
|
|
110
|
+
### Security Considerations
|
|
111
|
+
|
|
112
|
+
1. **Never Commit Secrets**: Environment variables should never be committed to the repository.
|
|
113
|
+
|
|
114
|
+
2. **Use HTTPS in Production**: All API calls should use HTTPS in production.
|
|
115
|
+
|
|
116
|
+
3. **Validate Inputs**: Always validate user inputs both on client and server side.
|
|
117
|
+
|
|
118
|
+
4. **Sanitize User Content**: When displaying user-generated content, sanitize to prevent XSS attacks.
|
|
119
|
+
|
|
120
|
+
### When to Ask for Clarification
|
|
121
|
+
|
|
122
|
+
1. If you're unsure about the NTC structure or conventions
|
|
123
|
+
2. If you need to add a new external service integration
|
|
124
|
+
3. If you're modifying the build configuration (vite.config.ts)
|
|
125
|
+
4. If you're changing the TypeScript configuration
|
|
126
|
+
5. If you're modifying the authentication flow
|
|
127
|
+
|
|
128
|
+
## 🎯 Quick Reference
|
|
129
|
+
|
|
130
|
+
### Import Patterns
|
|
131
|
+
```typescript
|
|
132
|
+
// API service
|
|
133
|
+
import { apiService, authService } from '@/services/api'
|
|
134
|
+
|
|
135
|
+
// Constants
|
|
136
|
+
import { API_BASE_URL } from '@/utils/constants'
|
|
137
|
+
|
|
138
|
+
// React hooks
|
|
139
|
+
import { useState, useEffect } from 'react'
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Common Patterns
|
|
143
|
+
```typescript
|
|
144
|
+
// API call with loading and error states
|
|
145
|
+
const [loading, setLoading] = useState(false)
|
|
146
|
+
const [error, setError] = useState<string | null>(null)
|
|
147
|
+
|
|
148
|
+
const fetchData = async () => {
|
|
149
|
+
setLoading(true)
|
|
150
|
+
setError(null)
|
|
151
|
+
try {
|
|
152
|
+
const response = await apiService.get('/endpoint')
|
|
153
|
+
// Handle response
|
|
154
|
+
} catch (err) {
|
|
155
|
+
setError('Failed to fetch data')
|
|
156
|
+
} finally {
|
|
157
|
+
setLoading(false)
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Environment variable
|
|
162
|
+
const apiUrl = import.meta.env.VITE_API_BASE_URL
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## 📝 Additional Resources
|
|
166
|
+
|
|
167
|
+
- React Documentation: https://react.dev/
|
|
168
|
+
- TypeScript Documentation: https://www.typescriptlang.org/
|
|
169
|
+
- Vite Documentation: https://vitejs.dev/
|
|
170
|
+
- React Router Documentation: https://reactrouter.com/
|
|
171
|
+
- Axios Documentation: https://axios-http.com/
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
**Last Updated**: 2026-05-09
|
|
176
|
+
**Template Version**: React 19 + TypeScript + Vite 8
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .main import init_react_project, init_react_project_in_current_dir
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
* {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
html {
|
|
6
|
+
scroll-behavior: smooth;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
body {
|
|
10
|
+
margin: 0;
|
|
11
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
|
12
|
+
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
|
13
|
+
sans-serif;
|
|
14
|
+
-webkit-font-smoothing: antialiased;
|
|
15
|
+
-moz-osx-font-smoothing: grayscale;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
code {
|
|
19
|
+
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
|
20
|
+
monospace;
|
|
21
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>{project_name}</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# Architecture Overview - {project_name}
|
|
2
|
+
|
|
3
|
+
This document provides a comprehensive overview of the architecture and technical stack for this NTC-generated React + TypeScript + Vite project.
|
|
4
|
+
|
|
5
|
+
## 🏗️ Architecture Overview
|
|
6
|
+
|
|
7
|
+
This is a modern React application built with TypeScript and Vite, designed for API-driven single-page applications (SPAs). The architecture follows a component-based approach with a clear separation of concerns.
|
|
8
|
+
|
|
9
|
+
### Core Architecture Principles
|
|
10
|
+
|
|
11
|
+
- **Component-First Design**: UI is built using reusable, composable components
|
|
12
|
+
- **Type Safety**: TypeScript provides compile-time type checking
|
|
13
|
+
- **API-Centric**: All data flows through a centralized API service
|
|
14
|
+
- **Environment-Based Configuration**: Configuration via environment variables
|
|
15
|
+
- **Modern Build Tool**: Vite provides fast development and optimized production builds
|
|
16
|
+
|
|
17
|
+
## 🛠️ Technical Stack
|
|
18
|
+
|
|
19
|
+
### Frontend Framework
|
|
20
|
+
- **React 19**: Latest React with concurrent features
|
|
21
|
+
- **TypeScript 5.9**: Type-safe JavaScript
|
|
22
|
+
- **Vite 8**: Modern build tool with HMR
|
|
23
|
+
|
|
24
|
+
### Routing & State
|
|
25
|
+
- **React Router 7**: Client-side routing
|
|
26
|
+
- **React Hooks**: State management (useState, useEffect, useContext)
|
|
27
|
+
- **Context API**: Global state management when needed
|
|
28
|
+
|
|
29
|
+
### HTTP Client
|
|
30
|
+
- **Axios**: Promise-based HTTP client with interceptors
|
|
31
|
+
- **Custom API Service**: Centralized API communication layer
|
|
32
|
+
|
|
33
|
+
### Development Tools
|
|
34
|
+
- **ESLint**: Code linting
|
|
35
|
+
- **TypeScript ESLint**: TypeScript-specific linting rules
|
|
36
|
+
- **Path Aliases**: `@` mapped to `src/` directory
|
|
37
|
+
|
|
38
|
+
## 📊 Data Flow Architecture
|
|
39
|
+
|
|
40
|
+
### API Communication Flow
|
|
41
|
+
```
|
|
42
|
+
Component → apiService → apiClient (Axios) → Backend API
|
|
43
|
+
↓
|
|
44
|
+
Interceptors
|
|
45
|
+
↓
|
|
46
|
+
Auth Token Injection
|
|
47
|
+
↓
|
|
48
|
+
Error Handling
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### State Management Flow
|
|
52
|
+
```
|
|
53
|
+
User Interaction → Component State → API Call → Update State → Re-render
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## 🔐 Authentication Architecture
|
|
57
|
+
|
|
58
|
+
### JWT Token Management
|
|
59
|
+
- Tokens stored in localStorage
|
|
60
|
+
- Automatic token injection via axios interceptors
|
|
61
|
+
- Token removal on 401 responses
|
|
62
|
+
- Login/logout through authService
|
|
63
|
+
|
|
64
|
+
### Auth Service Methods
|
|
65
|
+
- `login(credentials)`: Authenticate and store token
|
|
66
|
+
- `logout()`: Remove token and clear auth state
|
|
67
|
+
- `getCurrentUser()`: Fetch current user data
|
|
68
|
+
- `isAuthenticated()`: Check auth status
|
|
69
|
+
|
|
70
|
+
## 🌐 API Service Architecture
|
|
71
|
+
|
|
72
|
+
### API Client Configuration
|
|
73
|
+
- Base URL from environment variable
|
|
74
|
+
- 10-second timeout
|
|
75
|
+
- JSON content-type headers
|
|
76
|
+
- Request/response interceptors
|
|
77
|
+
|
|
78
|
+
### Available Methods
|
|
79
|
+
- `get(url, config)`: GET requests
|
|
80
|
+
- `post(url, data, config)`: POST requests
|
|
81
|
+
- `put(url, data, config)`: PUT requests
|
|
82
|
+
- `patch(url, data, config)`: PATCH requests
|
|
83
|
+
- `delete(url, config)`: DELETE requests
|
|
84
|
+
- `uploadFile(url, formData, onUploadProgress)`: File uploads
|
|
85
|
+
|
|
86
|
+
## 📁 Component Architecture
|
|
87
|
+
|
|
88
|
+
### Component Hierarchy
|
|
89
|
+
```
|
|
90
|
+
App.tsx (Root)
|
|
91
|
+
├── Header.tsx (Navigation)
|
|
92
|
+
└── [Page Components]
|
|
93
|
+
└── [UI Components]
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Component Patterns
|
|
97
|
+
- **Functional Components**: Only functional components with hooks
|
|
98
|
+
- **Props Interfaces**: TypeScript interfaces for component props
|
|
99
|
+
- **Custom Hooks**: Reusable logic extraction into custom hooks
|
|
100
|
+
- **Component Composition**: Building complex UI from simple components
|
|
101
|
+
|
|
102
|
+
## 🔧 Configuration Architecture
|
|
103
|
+
|
|
104
|
+
### Environment Variables
|
|
105
|
+
- `VITE_API_BASE_URL`: Backend API base URL
|
|
106
|
+
- `VITE_APP_NAME`: Application name
|
|
107
|
+
|
|
108
|
+
### Build Configuration
|
|
109
|
+
- **Vite Config**: Path aliases, React plugin
|
|
110
|
+
- **TypeScript Config**: Strict mode, path mapping
|
|
111
|
+
- **ESLint Config**: React and TypeScript rules
|
|
112
|
+
|
|
113
|
+
## 🚀 Build Process
|
|
114
|
+
|
|
115
|
+
### Development Build
|
|
116
|
+
- Vite dev server with HMR
|
|
117
|
+
- TypeScript compilation on-the-fly
|
|
118
|
+
- Source maps for debugging
|
|
119
|
+
- Port: 5173
|
|
120
|
+
|
|
121
|
+
### Production Build
|
|
122
|
+
- TypeScript compilation
|
|
123
|
+
- Minification and tree-shaking
|
|
124
|
+
- Code splitting
|
|
125
|
+
- Asset optimization
|
|
126
|
+
- Output: `dist/` directory
|
|
127
|
+
|
|
128
|
+
## 🎯 Performance Considerations
|
|
129
|
+
|
|
130
|
+
### Optimization Strategies
|
|
131
|
+
- Code splitting with React.lazy
|
|
132
|
+
- Memoization with React.memo
|
|
133
|
+
- Lazy loading of components
|
|
134
|
+
- Image optimization
|
|
135
|
+
- Bundle size monitoring
|
|
136
|
+
|
|
137
|
+
### Best Practices
|
|
138
|
+
- Avoid unnecessary re-renders
|
|
139
|
+
- Use useCallback for event handlers
|
|
140
|
+
- Use useMemo for expensive computations
|
|
141
|
+
- Implement virtual scrolling for long lists
|
|
142
|
+
|
|
143
|
+
## 🔒 Security Considerations
|
|
144
|
+
|
|
145
|
+
### Security Measures
|
|
146
|
+
- HTTPS in production
|
|
147
|
+
- Input validation
|
|
148
|
+
- XSS prevention
|
|
149
|
+
- CSRF protection (via backend)
|
|
150
|
+
- Secure token storage
|
|
151
|
+
|
|
152
|
+
### Environment Variable Security
|
|
153
|
+
- Never commit `.env` files
|
|
154
|
+
- Use `.env.example` for documentation
|
|
155
|
+
- Server-side secrets should not be exposed to client
|
|
156
|
+
|
|
157
|
+
## 📈 Scalability Architecture
|
|
158
|
+
|
|
159
|
+
### Scalability Features
|
|
160
|
+
- Component reusability
|
|
161
|
+
- Service layer abstraction
|
|
162
|
+
- Modular file structure
|
|
163
|
+
- Easy integration with new features
|
|
164
|
+
- Support for multiple API endpoints
|
|
165
|
+
|
|
166
|
+
### Future Extensibility
|
|
167
|
+
- Easy addition of state management (Redux, Zustand)
|
|
168
|
+
- Integration with testing frameworks
|
|
169
|
+
- Support for i18n
|
|
170
|
+
- Analytics integration
|