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,181 @@
|
|
|
1
|
+
# AI Agent Instructions for NTC-Generated Next.js Projects
|
|
2
|
+
|
|
3
|
+
This document provides specific instructions for AI agents (Claude, GPT, etc.) working with NTC-generated Next.js 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, Next.js App Router, 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 `process.env.NEXT_PUBLIC_*` for environment variables
|
|
42
|
+
- All configuration should use environment variables, never hardcode values
|
|
43
|
+
|
|
44
|
+
5. **Follow Naming Conventions**:
|
|
45
|
+
- Components: `PascalCase` (e.g., `UserProfile`)
|
|
46
|
+
- Functions/Hooks: `camelCase` (e.g., `useUserProfile`)
|
|
47
|
+
- Files: `PascalCase` for components, `camelCase` for utilities
|
|
48
|
+
- Constants: `UPPER_SNAKE_CASE`
|
|
49
|
+
|
|
50
|
+
### SEO Best Practices
|
|
51
|
+
|
|
52
|
+
1. **Metadata API**: Always include proper metadata for SEO:
|
|
53
|
+
- Use Next.js Metadata API in layout.tsx and page.tsx
|
|
54
|
+
- Title, description, keywords
|
|
55
|
+
- Open Graph tags for social sharing
|
|
56
|
+
- Twitter Card tags
|
|
57
|
+
- Canonical URLs
|
|
58
|
+
|
|
59
|
+
2. **Performance**:
|
|
60
|
+
- Use Next.js Image component for images
|
|
61
|
+
- Implement code splitting with dynamic imports
|
|
62
|
+
- Optimize fonts with next/font
|
|
63
|
+
- Use Server Components when possible
|
|
64
|
+
|
|
65
|
+
3. **Accessibility**:
|
|
66
|
+
- Use semantic HTML elements
|
|
67
|
+
- Provide alt text for images
|
|
68
|
+
- Ensure keyboard navigation
|
|
69
|
+
- Use ARIA labels where needed
|
|
70
|
+
- Follow WCAG guidelines
|
|
71
|
+
|
|
72
|
+
4. **Structured Data**:
|
|
73
|
+
- Add JSON-LD structured data for rich snippets
|
|
74
|
+
- Use Schema.org vocabulary
|
|
75
|
+
- Include organization, website, and article schemas
|
|
76
|
+
|
|
77
|
+
### External Service Integration
|
|
78
|
+
|
|
79
|
+
1. **API Communication**:
|
|
80
|
+
- Use the configured axios instance in `apiService`
|
|
81
|
+
- Handle authentication with JWT tokens via `authService`
|
|
82
|
+
- Implement proper error handling and user feedback
|
|
83
|
+
- Use loading states for async operations
|
|
84
|
+
|
|
85
|
+
2. **State Management**:
|
|
86
|
+
- Use React hooks for local state
|
|
87
|
+
- Consider using React Context or a state library for global state
|
|
88
|
+
- Keep state as close to where it's used as possible
|
|
89
|
+
|
|
90
|
+
### Development Workflow
|
|
91
|
+
|
|
92
|
+
1. **Running the Project**:
|
|
93
|
+
- Install dependencies: `npm install`
|
|
94
|
+
- Run development server: `npm run dev`
|
|
95
|
+
- Build for production: `npm run build`
|
|
96
|
+
- Preview production build: `npm start`
|
|
97
|
+
|
|
98
|
+
2. **Adding New Components**:
|
|
99
|
+
- Place in `src/components/` for reusable components
|
|
100
|
+
- Place in `src/app/` for page-level components
|
|
101
|
+
- Follow the existing component patterns
|
|
102
|
+
- Include TypeScript interfaces for props
|
|
103
|
+
|
|
104
|
+
3. **Adding API Services**:
|
|
105
|
+
- Add endpoint methods to `src/services/api.ts`
|
|
106
|
+
- Use the existing `apiClient` with interceptors
|
|
107
|
+
- Follow the existing service patterns
|
|
108
|
+
- Include proper TypeScript types
|
|
109
|
+
|
|
110
|
+
### Testing
|
|
111
|
+
|
|
112
|
+
1. **Test Structure**: Each component should have corresponding test files in the same directory or in a `__tests__` directory.
|
|
113
|
+
|
|
114
|
+
2. **Run Tests**: Use `npm test` to run the test suite (when configured).
|
|
115
|
+
|
|
116
|
+
### Security Considerations
|
|
117
|
+
|
|
118
|
+
1. **Never Commit Secrets**: Environment variables should never be committed to the repository.
|
|
119
|
+
|
|
120
|
+
2. **Use HTTPS in Production**: All API calls should use HTTPS in production.
|
|
121
|
+
|
|
122
|
+
3. **Validate Inputs**: Always validate user inputs both on client and server side.
|
|
123
|
+
|
|
124
|
+
4. **Sanitize User Content**: When displaying user-generated content, sanitize to prevent XSS attacks.
|
|
125
|
+
|
|
126
|
+
### When to Ask for Clarification
|
|
127
|
+
|
|
128
|
+
1. If you're unsure about the NTC structure or conventions
|
|
129
|
+
2. If you need to add a new external service integration
|
|
130
|
+
3. If you're modifying the build configuration (next.config.js)
|
|
131
|
+
4. If you're changing the TypeScript configuration
|
|
132
|
+
5. If you're modifying the authentication flow
|
|
133
|
+
|
|
134
|
+
## 🎯 Quick Reference
|
|
135
|
+
|
|
136
|
+
### Import Patterns
|
|
137
|
+
```typescript
|
|
138
|
+
// API service
|
|
139
|
+
import { apiService, authService } from '@/services/api'
|
|
140
|
+
|
|
141
|
+
// Constants
|
|
142
|
+
import { API_BASE_URL } from '@/utils/constants'
|
|
143
|
+
|
|
144
|
+
// React hooks
|
|
145
|
+
import { useState, useEffect } from 'react'
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Common Patterns
|
|
149
|
+
```typescript
|
|
150
|
+
// API call with loading and error states
|
|
151
|
+
const [loading, setLoading] = useState(false)
|
|
152
|
+
const [error, setError] = useState<string | null>(null)
|
|
153
|
+
|
|
154
|
+
const fetchData = async () => {
|
|
155
|
+
setLoading(true)
|
|
156
|
+
setError(null)
|
|
157
|
+
try {
|
|
158
|
+
const response = await apiService.get('/endpoint')
|
|
159
|
+
// Handle response
|
|
160
|
+
} catch (err) {
|
|
161
|
+
setError('Failed to fetch data')
|
|
162
|
+
} finally {
|
|
163
|
+
setLoading(false)
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Environment variable
|
|
168
|
+
const apiUrl = process.env.NEXT_PUBLIC_API_BASE_URL
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## 📝 Additional Resources
|
|
172
|
+
|
|
173
|
+
- Next.js Documentation: https://nextjs.org/docs
|
|
174
|
+
- React Documentation: https://react.dev/
|
|
175
|
+
- TypeScript Documentation: https://www.typescriptlang.org/
|
|
176
|
+
- Axios Documentation: https://axios-http.com/
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
**Last Updated**: 2026-05-09
|
|
181
|
+
**Template Version**: Next.js 15 + React 19 + TypeScript
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# {project_name}
|
|
2
|
+
|
|
3
|
+
A modern Next.js website with SEO best practices, initialized by `ntc init`.
|
|
4
|
+
|
|
5
|
+
## Tech Stack
|
|
6
|
+
|
|
7
|
+
- Next.js 15
|
|
8
|
+
- React 19
|
|
9
|
+
- TypeScript
|
|
10
|
+
- Tailwind CSS (optional, can be added)
|
|
11
|
+
- Axios for API communication
|
|
12
|
+
|
|
13
|
+
## Getting Started
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install
|
|
17
|
+
npm run dev
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
|
21
|
+
|
|
22
|
+
## Available Scripts
|
|
23
|
+
|
|
24
|
+
- `npm run dev` - Starts the development server
|
|
25
|
+
- `npm run build` - Creates an optimized production build
|
|
26
|
+
- `npm start` - Starts the production server
|
|
27
|
+
- `npm run lint` - Runs ESLint
|
|
28
|
+
|
|
29
|
+
## SEO Features
|
|
30
|
+
|
|
31
|
+
This template includes comprehensive SEO optimizations:
|
|
32
|
+
|
|
33
|
+
- **Metadata API**: Next.js Metadata API for dynamic meta tags
|
|
34
|
+
- **Open Graph**: Social media sharing optimization
|
|
35
|
+
- **Twitter Cards**: Twitter card support
|
|
36
|
+
- **Robots.txt**: Search engine crawling configuration
|
|
37
|
+
- **Sitemap**: Sitemap generation (can be added)
|
|
38
|
+
- **Canonical URLs**: Prevent duplicate content issues
|
|
39
|
+
- **Structured Data**: Schema.org support (can be added)
|
|
40
|
+
|
|
41
|
+
## Environment Variables
|
|
42
|
+
|
|
43
|
+
Copy `.env.example` to `.env.local` and configure:
|
|
44
|
+
|
|
45
|
+
```env
|
|
46
|
+
NEXT_PUBLIC_API_BASE_URL=http://localhost:8000
|
|
47
|
+
NEXT_PUBLIC_SITE_NAME={project_name}
|
|
48
|
+
NEXT_PUBLIC_SITE_URL=http://localhost:3000
|
|
49
|
+
NEXT_PUBLIC_SITE_DESCRIPTION=A modern website built with Next.js
|
|
50
|
+
NEXT_PUBLIC_SITE_KEYWORDS=nextjs,react,typescript
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Project Structure
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
src/
|
|
57
|
+
├── app/
|
|
58
|
+
│ ├── layout.tsx # Root layout with SEO metadata
|
|
59
|
+
│ ├── page.tsx # Home page
|
|
60
|
+
│ └── globals.css # Global styles
|
|
61
|
+
├── components/ # Reusable components
|
|
62
|
+
├── services/ # API services
|
|
63
|
+
└── utils/ # Utility functions
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## SEO Best Practices
|
|
67
|
+
|
|
68
|
+
1. **Meta Tags**: Each page should have appropriate meta tags
|
|
69
|
+
2. **Semantic HTML**: Use proper HTML5 semantic elements
|
|
70
|
+
3. **Performance**: Optimize images and use code splitting
|
|
71
|
+
4. **Accessibility**: Ensure proper ARIA labels and keyboard navigation
|
|
72
|
+
5. **Mobile-First**: Responsive design for all screen sizes
|
|
73
|
+
|
|
74
|
+
## Deployment
|
|
75
|
+
|
|
76
|
+
### Vercel
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
npm install -g vercel
|
|
80
|
+
vercel
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Docker
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
docker build -t {project_name} .
|
|
87
|
+
docker run -p 3000:3000 {project_name}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Learn More
|
|
91
|
+
|
|
92
|
+
- [Next.js Documentation](https://nextjs.org/docs)
|
|
93
|
+
- [React Documentation](https://react.dev)
|
|
94
|
+
- [TypeScript Documentation](https://www.typescriptlang.org)
|
|
File without changes
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# Architecture Overview - {project_name}
|
|
2
|
+
|
|
3
|
+
This document provides a comprehensive overview of the architecture and technical stack for this NTC-generated Next.js project.
|
|
4
|
+
|
|
5
|
+
## 🏗️ Architecture Overview
|
|
6
|
+
|
|
7
|
+
This is a modern Next.js website built with TypeScript, Next.js App Router, and React Server Components, designed for SEO-optimized websites with excellent performance.
|
|
8
|
+
|
|
9
|
+
### Core Architecture Principles
|
|
10
|
+
|
|
11
|
+
- **Server-First Design**: Leverage Next.js Server Components for better performance and SEO
|
|
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
|
+
- **SEO-Optimized**: Built-in SEO best practices with Next.js Metadata API
|
|
16
|
+
|
|
17
|
+
## 🛠️ Technical Stack
|
|
18
|
+
|
|
19
|
+
### Frontend Framework
|
|
20
|
+
- **Next.js 15**: Latest Next.js with App Router
|
|
21
|
+
- **React 19**: Latest React with Server Components
|
|
22
|
+
- **TypeScript 5.9**: Type-safe JavaScript
|
|
23
|
+
|
|
24
|
+
### Routing & State
|
|
25
|
+
- **Next.js App Router**: File-based routing with nested layouts
|
|
26
|
+
- **React Server Components**: Server-side rendering by default
|
|
27
|
+
- **React Client Components**: Client-side interactivity when needed
|
|
28
|
+
- **React Hooks**: State management for Client Components
|
|
29
|
+
|
|
30
|
+
### HTTP Client
|
|
31
|
+
- **Axios**: Promise-based HTTP client with interceptors
|
|
32
|
+
- **Custom API Service**: Centralized API communication layer
|
|
33
|
+
|
|
34
|
+
### Development Tools
|
|
35
|
+
- **ESLint**: Code linting with Next.js configuration
|
|
36
|
+
- **TypeScript**: Type checking
|
|
37
|
+
- **Path Aliases**: `@` mapped to `src/` directory
|
|
38
|
+
|
|
39
|
+
## 📊 Data Flow Architecture
|
|
40
|
+
|
|
41
|
+
### API Communication Flow
|
|
42
|
+
```
|
|
43
|
+
Server Component → API Service → apiClient (Axios) → Backend API
|
|
44
|
+
↓
|
|
45
|
+
Interceptors
|
|
46
|
+
↓
|
|
47
|
+
Auth Token Injection
|
|
48
|
+
↓
|
|
49
|
+
Error Handling
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Rendering Flow
|
|
53
|
+
```
|
|
54
|
+
Request → Server Component → Data Fetching → HTML Generation → Client Hydration
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 🔐 Authentication Architecture
|
|
58
|
+
|
|
59
|
+
### JWT Token Management
|
|
60
|
+
- Tokens stored in localStorage (Client Components)
|
|
61
|
+
- Automatic token injection via axios interceptors
|
|
62
|
+
- Token removal on 401 responses
|
|
63
|
+
- Login/logout through authService
|
|
64
|
+
|
|
65
|
+
### Auth Service Methods
|
|
66
|
+
- `login(credentials)`: Authenticate and store token
|
|
67
|
+
- `logout()`: Remove token and clear auth state
|
|
68
|
+
- `getCurrentUser()`: Fetch current user data
|
|
69
|
+
- `isAuthenticated()`: Check auth status
|
|
70
|
+
|
|
71
|
+
## 🌐 API Service Architecture
|
|
72
|
+
|
|
73
|
+
### API Client Configuration
|
|
74
|
+
- Base URL from environment variable
|
|
75
|
+
- 10-second timeout
|
|
76
|
+
- JSON content-type headers
|
|
77
|
+
- Request/response interceptors
|
|
78
|
+
- Error handling utilities
|
|
79
|
+
|
|
80
|
+
### Available Methods
|
|
81
|
+
- `get(url, config)`: GET requests
|
|
82
|
+
- `post(url, data, config)`: POST requests
|
|
83
|
+
- `put(url, data, config)`: PUT requests
|
|
84
|
+
- `patch(url, data, config)`: PATCH requests
|
|
85
|
+
- `delete(url, config)`: DELETE requests
|
|
86
|
+
|
|
87
|
+
## 📁 Component Architecture
|
|
88
|
+
|
|
89
|
+
### Component Hierarchy
|
|
90
|
+
```
|
|
91
|
+
layout.tsx (Root Layout)
|
|
92
|
+
├── Header.tsx (Navigation)
|
|
93
|
+
└── page.tsx (Home Page)
|
|
94
|
+
└── [Child Components]
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Component Patterns
|
|
98
|
+
- **Server Components**: Default for better performance and SEO
|
|
99
|
+
- **Client Components**: For interactivity (add 'use client' directive)
|
|
100
|
+
- **Layout Components**: Shared UI across routes
|
|
101
|
+
- **Page Components**: Route-specific content
|
|
102
|
+
|
|
103
|
+
## 🔧 Configuration Architecture
|
|
104
|
+
|
|
105
|
+
### Environment Variables
|
|
106
|
+
- `NEXT_PUBLIC_API_BASE_URL`: Backend API base URL
|
|
107
|
+
- `NEXT_PUBLIC_SITE_NAME`: Website name
|
|
108
|
+
- `NEXT_PUBLIC_SITE_URL`: Website URL
|
|
109
|
+
- `NEXT_PUBLIC_SITE_DESCRIPTION`: SEO description
|
|
110
|
+
- `NEXT_PUBLIC_SITE_KEYWORDS`: SEO keywords
|
|
111
|
+
|
|
112
|
+
### Build Configuration
|
|
113
|
+
- **Next.js Config**: Security headers, image domains
|
|
114
|
+
- **TypeScript Config**: Strict mode, path mapping
|
|
115
|
+
- **ESLint Config**: Next.js and TypeScript rules
|
|
116
|
+
|
|
117
|
+
## 🚀 Build Process
|
|
118
|
+
|
|
119
|
+
### Development Build
|
|
120
|
+
- Next.js dev server with HMR
|
|
121
|
+
- TypeScript compilation on-the-fly
|
|
122
|
+
- Source maps for debugging
|
|
123
|
+
- Port: 3000
|
|
124
|
+
|
|
125
|
+
### Production Build
|
|
126
|
+
- TypeScript compilation
|
|
127
|
+
- Server-side rendering
|
|
128
|
+
- Static generation where possible
|
|
129
|
+
- Code splitting
|
|
130
|
+
- Asset optimization
|
|
131
|
+
- Output: `.next/` directory
|
|
132
|
+
|
|
133
|
+
## 🎯 Performance Considerations
|
|
134
|
+
|
|
135
|
+
### Optimization Strategies
|
|
136
|
+
- Server Components by default
|
|
137
|
+
- Code splitting with dynamic imports
|
|
138
|
+
- Image optimization with Next.js Image component
|
|
139
|
+
- Font optimization with next/font
|
|
140
|
+
- Automatic CSS optimization
|
|
141
|
+
- Tree shaking
|
|
142
|
+
|
|
143
|
+
### Best Practices
|
|
144
|
+
- Use Server Components when possible
|
|
145
|
+
- Use Client Components only for interactivity
|
|
146
|
+
- Implement proper caching strategies
|
|
147
|
+
- Optimize images and assets
|
|
148
|
+
- Use streaming for large pages
|
|
149
|
+
|
|
150
|
+
## 🔒 Security Considerations
|
|
151
|
+
|
|
152
|
+
### Security Measures
|
|
153
|
+
- HTTPS in production
|
|
154
|
+
- Security headers configured
|
|
155
|
+
- Input validation
|
|
156
|
+
- XSS prevention
|
|
157
|
+
- CSRF protection (via backend)
|
|
158
|
+
- Secure token storage
|
|
159
|
+
|
|
160
|
+
### Environment Variable Security
|
|
161
|
+
- Never commit `.env` files
|
|
162
|
+
- Use `.env.example` for documentation
|
|
163
|
+
- Server-side secrets should not be exposed to client
|
|
164
|
+
|
|
165
|
+
## 📈 SEO Architecture
|
|
166
|
+
|
|
167
|
+
### SEO Features
|
|
168
|
+
- **Metadata API**: Dynamic meta tags per page
|
|
169
|
+
- **Open Graph**: Social media sharing optimization
|
|
170
|
+
- **Twitter Cards**: Twitter card support
|
|
171
|
+
- **Canonical URLs**: Prevent duplicate content
|
|
172
|
+
- **Structured Data**: JSON-LD for rich snippets
|
|
173
|
+
- **Sitemap**: Automatic sitemap generation
|
|
174
|
+
- **Robots.txt**: Search engine crawling configuration
|
|
175
|
+
|
|
176
|
+
### SEO Best Practices
|
|
177
|
+
- Semantic HTML elements
|
|
178
|
+
- Proper heading hierarchy
|
|
179
|
+
- Alt text for images
|
|
180
|
+
- Meta descriptions
|
|
181
|
+
- Mobile-responsive design
|
|
182
|
+
- Fast page load times
|
|
183
|
+
|
|
184
|
+
## 🔒 Accessibility Architecture
|
|
185
|
+
|
|
186
|
+
### Accessibility Features
|
|
187
|
+
- Semantic HTML
|
|
188
|
+
- ARIA labels where needed
|
|
189
|
+
- Keyboard navigation
|
|
190
|
+
- Screen reader support
|
|
191
|
+
- Color contrast compliance
|
|
192
|
+
- Focus management
|
|
193
|
+
|
|
194
|
+
## 📈 Scalability Architecture
|
|
195
|
+
|
|
196
|
+
### Scalability Features
|
|
197
|
+
- Component reusability
|
|
198
|
+
- Service layer abstraction
|
|
199
|
+
- Modular file structure
|
|
200
|
+
- Easy integration with new features
|
|
201
|
+
- Support for multiple API endpoints
|
|
202
|
+
|
|
203
|
+
### Future Extensibility
|
|
204
|
+
- Easy addition of state management libraries
|
|
205
|
+
- Integration with testing frameworks
|
|
206
|
+
- Support for i18n
|
|
207
|
+
- Analytics integration
|
|
208
|
+
- Additional SEO features
|