To help AI understand your project better, it is recommended to build a knowledge base inside the project. That way AI can work according to your conventions and habits.
4.1 Create a Project Description File
Create a or file in the project root to record key project information:
## Code Conventions
- Use ESLint and Prettier to format code
- Component files use PascalCase (such as UserProfile.tsx)
- Utility functions use camelCase (such as formatDate.ts)
- Constants use UPPER_SNAKE_CASE (such as API_BASE_URL)
## Development Flow
1. Create a feature branch from main
2. Submit a PR after development is complete
3. Merge after code review passes
## Common Tasks
- Start the development server: `npm run dev`
- Run tests: `npm test`
- Build for production: `npm run build`
- Format code: `npm run format`
## Notes
- All API calls must include error handling
- User input must be validated and escaped
- Use parameterized queries for database operations to avoid SQL injection
- Sensitive information (passwords, tokens) must not be written to logs
## Database Schema
- users: user table (id, email, password_hash, created_at)
- courses: course table (id, title, description, teacher_id)
- enrollments: enrollment table (id, user_id, course_id, enrolled_at)
4.2 Record Common Problems and Solutions
Create docs/troubleshooting.md in the project to record common problems:
# Common Problems
## Development Environment Problems
### Problem: npm install fails
**Cause:** Node version is incompatible
**Solution:** Use Node.js 18 or higher
### Problem: database connection fails
**Cause:** environment variables are not configured
**Solution:** Copy .env.example to .env and fill in the database connection info
## Feature Problems
### Problem: after users log in, refreshing the page logs them out
**Cause:** the token is stored in sessionStorage
**Solution:** switch to localStorage
### Problem: image upload fails
**Cause:** file size exceeds the limit
**Solution:** add a file size check on the frontend and limit it to 5MB
4.3 Maintain Technical Decision Records
Create a docs/decisions/ directory to record important technical decisions:
# ADR-001: Choosing PostgreSQL as the Database
## Status
Accepted
## Background
The project needs to choose a relational database. The candidates are MySQL and PostgreSQL.
## Decision
Choose PostgreSQL
## Rationale
1. Better JSON support, suitable for storing course content
2. Stronger full-text search
3. The team is more familiar with PostgreSQL
## Consequences
- We need to learn PostgreSQL-specific features
- Deployment requires a PostgreSQL environment