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,210 @@
|
|
|
1
|
+
# AI Agent Instructions for NTC-Generated React Admin Dashboard Projects
|
|
2
|
+
|
|
3
|
+
This document provides specific instructions for AI agents (Claude, GPT, etc.) working with NTC-generated React Admin Dashboard 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, React Router v7, TanStack Query, and modern React patterns for admin dashboards.
|
|
21
|
+
|
|
22
|
+
3. **Check Existing Implementations**: Before adding new features, check if similar implementations already exist in `src/components/`, `src/services/`, or `src/pages/`.
|
|
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 `base.service.ts` for HTTP operations
|
|
36
|
+
- Use the `api.service.ts` for typed API endpoints
|
|
37
|
+
- Use TanStack Query hooks (`useApi`, `useApiMutation`) for data fetching
|
|
38
|
+
- Handle loading and error states properly
|
|
39
|
+
|
|
40
|
+
4. **State Management**:
|
|
41
|
+
- Use React Context API for global state (Auth, Theme, Workspace)
|
|
42
|
+
- Keep context providers at the root level
|
|
43
|
+
- Use custom hooks for accessing context
|
|
44
|
+
|
|
45
|
+
5. **Routing**:
|
|
46
|
+
- Use React Router v7 for routing
|
|
47
|
+
- Use protected routes for authenticated pages
|
|
48
|
+
- Use nested routes for layout components
|
|
49
|
+
|
|
50
|
+
6. **Environment Variables**:
|
|
51
|
+
- Use `import.meta.env.VITE_*` for environment variables
|
|
52
|
+
- All configuration should use environment variables, never hardcode values
|
|
53
|
+
|
|
54
|
+
7. **Follow Naming Conventions**:
|
|
55
|
+
- Components: `PascalCase` (e.g., `UserProfile`)
|
|
56
|
+
- Pages: `PascalCase` with `Page` suffix (e.g., `DashboardPage`)
|
|
57
|
+
- Functions/Hooks: `camelCase` (e.g., `useUserProfile`)
|
|
58
|
+
- Files: `PascalCase` for components, `camelCase` for utilities
|
|
59
|
+
- Constants: `UPPER_SNAKE_CASE`
|
|
60
|
+
|
|
61
|
+
### Admin Dashboard Specific Patterns
|
|
62
|
+
|
|
63
|
+
1. **Layout Components**:
|
|
64
|
+
- `DashboardLayout`: Main layout with sidebar and top navigation
|
|
65
|
+
- `AuthLayout`: Layout for authentication pages
|
|
66
|
+
- Use nested routes for layout structure
|
|
67
|
+
|
|
68
|
+
2. **Authentication**:
|
|
69
|
+
- Use `AuthContext` for authentication state
|
|
70
|
+
- Use `ProtectedRoute` for route protection
|
|
71
|
+
- Implement login/register/logout flows
|
|
72
|
+
|
|
73
|
+
3. **Data Fetching**:
|
|
74
|
+
- Use TanStack Query for caching and state management
|
|
75
|
+
- Use `useApi` hook for GET requests
|
|
76
|
+
- Use `useApiMutation` hook for POST/PUT/PATCH/DELETE
|
|
77
|
+
- Implement proper error handling and loading states
|
|
78
|
+
|
|
79
|
+
### External Service Integration
|
|
80
|
+
|
|
81
|
+
1. **API Communication**:
|
|
82
|
+
- Use the configured axios instance in `base.service.ts`
|
|
83
|
+
- Handle authentication with JWT tokens via interceptors
|
|
84
|
+
- Implement proper error handling and user feedback
|
|
85
|
+
- Use loading states for async operations
|
|
86
|
+
|
|
87
|
+
2. **State Management**:
|
|
88
|
+
- Use React Context for global state (Auth, Theme, Workspace)
|
|
89
|
+
- Use TanStack Query for server state
|
|
90
|
+
- Keep component state local when possible
|
|
91
|
+
|
|
92
|
+
### Development Workflow
|
|
93
|
+
|
|
94
|
+
1. **Running the Project**:
|
|
95
|
+
- Install dependencies: `npm install`
|
|
96
|
+
- Run development server: `npm run dev`
|
|
97
|
+
- Build for production: `npm run build`
|
|
98
|
+
- Preview production build: `npm run preview`
|
|
99
|
+
|
|
100
|
+
2. **Adding New Components**:
|
|
101
|
+
- Place in `src/components/` for reusable components
|
|
102
|
+
- Place in `src/pages/` for page-level components
|
|
103
|
+
- Place in `src/layouts/` for layout components
|
|
104
|
+
- Follow the existing component patterns
|
|
105
|
+
- Include TypeScript interfaces for props
|
|
106
|
+
|
|
107
|
+
3. **Adding API Services**:
|
|
108
|
+
- Add typed endpoints to `src/services/api.service.ts`
|
|
109
|
+
- Use the existing `baseService` with interceptors
|
|
110
|
+
- Follow the existing service patterns
|
|
111
|
+
- Include proper TypeScript types
|
|
112
|
+
|
|
113
|
+
4. **Adding Pages**:
|
|
114
|
+
- Create page components in `src/pages/`
|
|
115
|
+
- Add routes to `App.tsx`
|
|
116
|
+
- Use `ProtectedRoute` for authenticated pages
|
|
117
|
+
- Update navigation in `Sidebar.tsx`
|
|
118
|
+
|
|
119
|
+
### Testing
|
|
120
|
+
|
|
121
|
+
1. **Test Structure**: Each component should have corresponding test files in the same directory or in a `__tests__` directory.
|
|
122
|
+
|
|
123
|
+
2. **Run Tests**: Use `npm test` to run the test suite (when configured).
|
|
124
|
+
|
|
125
|
+
### Security Considerations
|
|
126
|
+
|
|
127
|
+
1. **Never Commit Secrets**: Environment variables should never be committed to the repository.
|
|
128
|
+
|
|
129
|
+
2. **Use HTTPS in Production**: All API calls should use HTTPS in production.
|
|
130
|
+
|
|
131
|
+
3. **Validate Inputs**: Always validate user inputs both on client and server side.
|
|
132
|
+
|
|
133
|
+
4. **Sanitize User Content**: When displaying user-generated content, sanitize to prevent XSS attacks.
|
|
134
|
+
|
|
135
|
+
5. **Protect Routes**: Use `ProtectedRoute` for authenticated pages.
|
|
136
|
+
|
|
137
|
+
### When to Ask for Clarification
|
|
138
|
+
|
|
139
|
+
1. If you're unsure about the NTC structure or conventions
|
|
140
|
+
2. If you need to add a new external service integration
|
|
141
|
+
3. If you're modifying the build configuration (vite.config.ts)
|
|
142
|
+
4. If you're changing the TypeScript configuration
|
|
143
|
+
5. If you're modifying the authentication flow
|
|
144
|
+
6. If you're changing the routing structure
|
|
145
|
+
|
|
146
|
+
## 🎯 Quick Reference
|
|
147
|
+
|
|
148
|
+
### Import Patterns
|
|
149
|
+
```typescript
|
|
150
|
+
// API services
|
|
151
|
+
import { baseService } from '@/services/base.service'
|
|
152
|
+
import { apiService } from '@/services/api.service'
|
|
153
|
+
|
|
154
|
+
// React hooks
|
|
155
|
+
import { useApi, useApiMutation } from '@/hooks/useApi'
|
|
156
|
+
|
|
157
|
+
// Context
|
|
158
|
+
import { useAuth } from '@/context/AuthContext'
|
|
159
|
+
import { useTheme } from '@/context/ThemeContext'
|
|
160
|
+
import { useWorkspace } from '@/context/WorkspaceContext'
|
|
161
|
+
|
|
162
|
+
// React Router
|
|
163
|
+
import { useNavigate, useLocation } from 'react-router-dom'
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Common Patterns
|
|
167
|
+
```typescript
|
|
168
|
+
// API call with TanStack Query
|
|
169
|
+
const { data, isLoading, error } = useApi(
|
|
170
|
+
'/endpoint',
|
|
171
|
+
{ enabled: true }
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
// Mutation with TanStack Query
|
|
175
|
+
const mutation = useApiMutation(
|
|
176
|
+
(data) => apiService.postEndpoint(data),
|
|
177
|
+
{
|
|
178
|
+
onSuccess: () => {
|
|
179
|
+
// Handle success
|
|
180
|
+
},
|
|
181
|
+
onError: (error) => {
|
|
182
|
+
// Handle error
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
// Authentication
|
|
188
|
+
const { user, login, logout, isAuthenticated } = useAuth()
|
|
189
|
+
|
|
190
|
+
// Navigation
|
|
191
|
+
const navigate = useNavigate()
|
|
192
|
+
navigate('/dashboard')
|
|
193
|
+
|
|
194
|
+
// Environment variable
|
|
195
|
+
const apiUrl = import.meta.env.VITE_API_BASE_URL
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## 📝 Additional Resources
|
|
199
|
+
|
|
200
|
+
- React Documentation: https://react.dev/
|
|
201
|
+
- TypeScript Documentation: https://www.typescriptlang.org/
|
|
202
|
+
- Vite Documentation: https://vitejs.dev/
|
|
203
|
+
- React Router Documentation: https://reactrouter.com/
|
|
204
|
+
- TanStack Query Documentation: https://tanstack.com/query/latest
|
|
205
|
+
- Axios Documentation: https://axios-http.com/
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
**Last Updated**: 2026-05-09
|
|
210
|
+
**Template Version**: React Admin Dashboard with TypeScript, Vite 8, React Router 7, TanStack Query
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# {project_name} Admin Dashboard
|
|
2
|
+
|
|
3
|
+
A React + TypeScript + Vite admin dashboard initialized by `ntc react init`.
|
|
4
|
+
|
|
5
|
+
## Tech Stack
|
|
6
|
+
|
|
7
|
+
- React 19
|
|
8
|
+
- TypeScript
|
|
9
|
+
- Vite 8
|
|
10
|
+
- Tailwind CSS 4
|
|
11
|
+
- React Router 7
|
|
12
|
+
- TanStack Query
|
|
13
|
+
- Axios
|
|
14
|
+
- Lucide React
|
|
15
|
+
|
|
16
|
+
## Getting Started
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install
|
|
20
|
+
npm run dev
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Available Scripts
|
|
24
|
+
|
|
25
|
+
- `npm run dev` - Runs the app in development mode
|
|
26
|
+
- `npm run build` - Builds the app for production
|
|
27
|
+
- `npm run lint` - Runs ESLint
|
|
28
|
+
- `npm run preview` - Previews the production build
|
|
29
|
+
|
|
30
|
+
## Project Structure
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
src/
|
|
34
|
+
├── components/ # Reusable UI components
|
|
35
|
+
├── context/ # React context providers
|
|
36
|
+
├── hooks/ # Custom React hooks
|
|
37
|
+
├── layouts/ # Layout components
|
|
38
|
+
├── pages/ # Page components
|
|
39
|
+
├── services/ # API service layer
|
|
40
|
+
├── App.tsx # Main app component
|
|
41
|
+
├── main.tsx # Entry point
|
|
42
|
+
└── index.css # Global styles
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
- Authentication with JWT
|
|
48
|
+
- Protected routes
|
|
49
|
+
- Responsive sidebar navigation
|
|
50
|
+
- Theme switching (light/dark)
|
|
51
|
+
- API integration with TanStack Query
|
|
52
|
+
- Type-safe with TypeScript
|
|
53
|
+
|
|
54
|
+
## Environment Variables
|
|
55
|
+
|
|
56
|
+
Copy `.env.example` to `.env` and configure:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
VITE_API_BASE_URL=http://localhost:8000/v1
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Development
|
|
63
|
+
|
|
64
|
+
The dashboard is designed to work with a Django REST Framework backend. Ensure your backend API is running and CORS is configured to allow requests from this frontend.
|
|
65
|
+
|
|
66
|
+
## Building for Production
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npm run build
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The built files will be in the `dist/` directory.
|
|
File without changes
|
|
@@ -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} Admin Dashboard</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,202 @@
|
|
|
1
|
+
# Architecture Overview - {project_name}
|
|
2
|
+
|
|
3
|
+
This document provides a comprehensive overview of the architecture and technical stack for this NTC-generated React Admin Dashboard project.
|
|
4
|
+
|
|
5
|
+
## 🏗️ Architecture Overview
|
|
6
|
+
|
|
7
|
+
This is a modern React admin dashboard built with TypeScript, Vite, React Router v7, and TanStack Query, designed for API-driven administrative interfaces. The architecture follows a component-based approach with 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
|
+
- **State Management**: React Context for global state, TanStack Query for server state
|
|
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 with nested routes
|
|
26
|
+
- **React Hooks**: State management (useState, useEffect, useContext)
|
|
27
|
+
- **React Context API**: Global state management (Auth, Theme, Workspace)
|
|
28
|
+
- **TanStack Query**: Server state management and caching
|
|
29
|
+
|
|
30
|
+
### HTTP Client
|
|
31
|
+
- **Axios**: Promise-based HTTP client with interceptors
|
|
32
|
+
- **Base Service**: Centralized HTTP client configuration
|
|
33
|
+
- **API Service**: Typed API endpoints
|
|
34
|
+
|
|
35
|
+
### Development Tools
|
|
36
|
+
- **ESLint**: Code linting
|
|
37
|
+
- **TypeScript ESLint**: TypeScript-specific linting rules
|
|
38
|
+
- **Path Aliases**: `@` mapped to `src/` directory
|
|
39
|
+
|
|
40
|
+
## 📊 Data Flow Architecture
|
|
41
|
+
|
|
42
|
+
### API Communication Flow
|
|
43
|
+
```
|
|
44
|
+
Component → useApi/useApiMutation → apiService → baseService → Axios → Backend API
|
|
45
|
+
↓
|
|
46
|
+
Interceptors
|
|
47
|
+
↓
|
|
48
|
+
Auth Token Injection
|
|
49
|
+
↓
|
|
50
|
+
Error Handling
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### State Management Flow
|
|
54
|
+
```
|
|
55
|
+
User Interaction → Component State → TanStack Query → API Call → Cache Update → Re-render
|
|
56
|
+
↓
|
|
57
|
+
Context State → Global State Update → Re-render
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## 🔐 Authentication Architecture
|
|
61
|
+
|
|
62
|
+
### JWT Token Management
|
|
63
|
+
- Tokens stored in localStorage
|
|
64
|
+
- Automatic token injection via axios interceptors
|
|
65
|
+
- Token removal on 401 responses
|
|
66
|
+
- Login/logout through AuthContext
|
|
67
|
+
|
|
68
|
+
### Auth Context Methods
|
|
69
|
+
- `login(credentials)`: Authenticate and store token
|
|
70
|
+
- `register(data)`: Register new user
|
|
71
|
+
- `logout()`: Remove token and clear auth state
|
|
72
|
+
- `refreshToken()`: Refresh expired tokens
|
|
73
|
+
- `isAuthenticated()`: Check auth status
|
|
74
|
+
|
|
75
|
+
## 🌐 API Service Architecture
|
|
76
|
+
|
|
77
|
+
### Base Service Configuration
|
|
78
|
+
- Base URL from environment variable
|
|
79
|
+
- 10-second timeout
|
|
80
|
+
- JSON content-type headers
|
|
81
|
+
- Request/response interceptors
|
|
82
|
+
- Error handling utilities
|
|
83
|
+
|
|
84
|
+
### API Service Methods
|
|
85
|
+
- Typed endpoints for User and Auth
|
|
86
|
+
- GET, POST, PUT, PATCH, DELETE operations
|
|
87
|
+
- File upload support
|
|
88
|
+
- Error logging
|
|
89
|
+
|
|
90
|
+
## 📁 Component Architecture
|
|
91
|
+
|
|
92
|
+
### Component Hierarchy
|
|
93
|
+
```
|
|
94
|
+
App.tsx (Root with Routing)
|
|
95
|
+
├── AuthContext Provider
|
|
96
|
+
├── ThemeContext Provider
|
|
97
|
+
├── WorkspaceContext Provider
|
|
98
|
+
├── QueryClient Provider
|
|
99
|
+
├── AuthLayout
|
|
100
|
+
│ └── LoginPage, RegisterPage
|
|
101
|
+
└── DashboardLayout
|
|
102
|
+
├── Sidebar
|
|
103
|
+
├── TopNav
|
|
104
|
+
├── ProtectedRoute
|
|
105
|
+
└── [Page Components]
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Layout Patterns
|
|
109
|
+
- **DashboardLayout**: Main layout with sidebar and top navigation
|
|
110
|
+
- **AuthLayout**: Layout for authentication pages
|
|
111
|
+
- **ProtectedRoute**: Route protection wrapper
|
|
112
|
+
- **Nested Routes**: Layout-based routing
|
|
113
|
+
|
|
114
|
+
## 🎯 Context Architecture
|
|
115
|
+
|
|
116
|
+
### Auth Context
|
|
117
|
+
- User state
|
|
118
|
+
- Access token
|
|
119
|
+
- Authentication status
|
|
120
|
+
- Login, register, logout functions
|
|
121
|
+
- Token refresh logic
|
|
122
|
+
|
|
123
|
+
### Theme Context
|
|
124
|
+
- Theme mode (light/dark)
|
|
125
|
+
- Theme toggle function
|
|
126
|
+
|
|
127
|
+
### Workspace Context
|
|
128
|
+
- Current workspace
|
|
129
|
+
- Workspace selection
|
|
130
|
+
- Workspace-related state
|
|
131
|
+
|
|
132
|
+
## 🔧 Configuration Architecture
|
|
133
|
+
|
|
134
|
+
### Environment Variables
|
|
135
|
+
- `VITE_API_BASE_URL`: Backend API base URL
|
|
136
|
+
|
|
137
|
+
### Build Configuration
|
|
138
|
+
- **Vite Config**: Path aliases, React plugin
|
|
139
|
+
- **TypeScript Config**: Strict mode, path mapping
|
|
140
|
+
- **ESLint Config**: React and TypeScript rules
|
|
141
|
+
|
|
142
|
+
## 🚀 Build Process
|
|
143
|
+
|
|
144
|
+
### Development Build
|
|
145
|
+
- Vite dev server with HMR
|
|
146
|
+
- TypeScript compilation on-the-fly
|
|
147
|
+
- Source maps for debugging
|
|
148
|
+
- Port: 5173
|
|
149
|
+
|
|
150
|
+
### Production Build
|
|
151
|
+
- TypeScript compilation
|
|
152
|
+
- Minification and tree-shaking
|
|
153
|
+
- Code splitting
|
|
154
|
+
- Asset optimization
|
|
155
|
+
- Output: `dist/` directory
|
|
156
|
+
|
|
157
|
+
## 🎯 Performance Considerations
|
|
158
|
+
|
|
159
|
+
### Optimization Strategies
|
|
160
|
+
- Code splitting with React.lazy
|
|
161
|
+
- Memoization with React.memo
|
|
162
|
+
- TanStack Query caching
|
|
163
|
+
- Lazy loading of components
|
|
164
|
+
- Image optimization
|
|
165
|
+
|
|
166
|
+
### Best Practices
|
|
167
|
+
- Avoid unnecessary re-renders
|
|
168
|
+
- Use TanStack Query for server state
|
|
169
|
+
- Implement virtual scrolling for long lists
|
|
170
|
+
- Optimize bundle size
|
|
171
|
+
|
|
172
|
+
## 🔒 Security Considerations
|
|
173
|
+
|
|
174
|
+
### Security Measures
|
|
175
|
+
- HTTPS in production
|
|
176
|
+
- Input validation
|
|
177
|
+
- XSS prevention
|
|
178
|
+
- CSRF protection (via backend)
|
|
179
|
+
- Secure token storage
|
|
180
|
+
- Protected routes
|
|
181
|
+
|
|
182
|
+
### Environment Variable Security
|
|
183
|
+
- Never commit `.env` files
|
|
184
|
+
- Use `.env.example` for documentation
|
|
185
|
+
- Server-side secrets should not be exposed to client
|
|
186
|
+
|
|
187
|
+
## 📈 Scalability Architecture
|
|
188
|
+
|
|
189
|
+
### Scalability Features
|
|
190
|
+
- Component reusability
|
|
191
|
+
- Service layer abstraction
|
|
192
|
+
- Modular file structure
|
|
193
|
+
- Easy integration with new features
|
|
194
|
+
- Support for multiple API endpoints
|
|
195
|
+
- TanStack Query for efficient data fetching
|
|
196
|
+
|
|
197
|
+
### Future Extensibility
|
|
198
|
+
- Easy addition of state management libraries
|
|
199
|
+
- Integration with testing frameworks
|
|
200
|
+
- Support for i18n
|
|
201
|
+
- Analytics integration
|
|
202
|
+
- Additional context providers
|