Skip to content

Commit 9c74064

Browse files
committed
chore: 整理项目结构与文档
- 更新 .gitignore 支持 docs 子目录图片 - 移除根目录重复的站点验证文件 - 完善 CLAUDE.md 文档说明 - 添加项目规范与开发指南 - 添加推广文案文档
1 parent fdb8fbf commit 9c74064

File tree

8 files changed

+383
-9
lines changed

8 files changed

+383
-9
lines changed

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,10 @@ image copy 2.png
159159
线下聚会数据.png
160160
deepwiki.png
161161
*.png
162-
!docs/*.png
163-
!docs/*.jpg
162+
!docs/*.png
163+
!docs/*.jpg
164+
!docs/**/*.png
165+
!docs/**/*.jpg
164166
!public/**/*.png
165167
!public/**/*.jpg
166168

.kiro/steering/api-development.md

Whitespace-only changes.
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
# Development Standards & Best Practices
2+
3+
## Code Style & Formatting
4+
5+
### Python Standards
6+
- **Indentation**: 4 spaces (never tabs)
7+
- **Type hints**: Required everywhere - functions, variables, class attributes
8+
- **Naming conventions**:
9+
- Functions/variables: `snake_case`
10+
- Classes: `PascalCase`
11+
- Constants: `SCREAMING_SNAKE_CASE`
12+
- Private methods: `_leading_underscore`
13+
- **Function length**: Keep under ~50 lines for readability
14+
- **Data structures**: Prefer dataclasses for structured payloads over dictionaries
15+
16+
### HTML/CSS Standards
17+
- **Class naming**: BEM-like convention (`meetspot-header__title`, `card--featured`)
18+
- **Colors**: Always use design tokens from `static/css/design-tokens.css`
19+
- **Inline styles**: Minimize usage, only for generated HTML in `workspace/js_src/`
20+
- **Responsive design**: Mobile-first approach with progressive enhancement
21+
- **Accessibility**: All interactive elements must be keyboard accessible
22+
23+
### JavaScript Standards
24+
- **ES6+**: Use modern JavaScript features
25+
- **Async/await**: Prefer over Promise chains
26+
- **Error handling**: Always wrap API calls in try-catch blocks
27+
- **DOM manipulation**: Use semantic HTML and ARIA attributes
28+
29+
## Quality Gates
30+
31+
### Pre-commit Requirements
32+
All of these must pass before opening a PR:
33+
34+
```bash
35+
# Code formatting
36+
black .
37+
38+
# Linting
39+
ruff check .
40+
41+
# Type checking
42+
mypy app/
43+
44+
# Test coverage
45+
pytest --cov=app tests/
46+
# Target: ≥80% coverage for app/ package
47+
```
48+
49+
### Testing Standards
50+
- **Test organization**: Place tests in `tests/` using `test_<feature>.py` naming
51+
- **Test types**:
52+
- Unit tests: Individual functions and classes
53+
- Integration tests: FastAPI routes + tool layer helpers
54+
- SEO tests: Meta tags, schema.org, sitemap validation
55+
- **Fixtures**: Create reusable fixtures for database, API clients, mock data
56+
- **Coverage**: Maintain ≥80% coverage for the `app/` package
57+
- **Focus areas**: Prioritize testing caching, concurrency, and SEO logic
58+
59+
## Logging Standards
60+
61+
### Structured Logging
62+
Use `app/logger.py` for all logging needs:
63+
64+
```python
65+
from app.logger import logger
66+
67+
# Good: Structured logging with context
68+
logger.info("geo_center_calculated", extra={
69+
"center_lat": 39.9042,
70+
"center_lng": 116.4074,
71+
"locations_count": 3,
72+
"processing_time": 1.2
73+
})
74+
75+
# Bad: Unstructured string logging
76+
logger.info("Calculated center at 39.9042, 116.4074")
77+
```
78+
79+
### Log Levels
80+
- **DEBUG**: Detailed diagnostic information
81+
- **INFO**: General operational messages
82+
- **WARNING**: Something unexpected but recoverable
83+
- **ERROR**: Error conditions that don't stop execution
84+
- **CRITICAL**: Serious errors that may abort execution
85+
86+
## Performance Guidelines
87+
88+
### Memory Management
89+
- **Concurrency**: Respect `MAX_CONCURRENT_REQUESTS = 3` semaphore
90+
- **Caching**: Use LRU cache with reasonable limits (30 geocodes, 15 POI searches)
91+
- **Cleanup**: Call `gc.collect()` after memory-intensive operations
92+
- **Agent mode**: Currently disabled to save memory on Render free tier
93+
94+
### Async Best Practices
95+
- **All I/O async**: Use aiohttp, aiofiles, async database operations
96+
- **Concurrent operations**: Use `asyncio.gather()` for parallel API calls
97+
- **Error handling**: Always handle async exceptions properly
98+
- **Session management**: Reuse HTTP sessions, close properly
99+
100+
### Caching Strategy
101+
- **HTTP caching**: Set appropriate Cache-Control headers
102+
- Immutable assets: 1 year
103+
- Images: 30 days
104+
- Dynamic content: no-cache
105+
- **Application caching**: Use LRU cache for expensive operations
106+
- **Database caching**: Cache frequently accessed data
107+
108+
## Security Standards
109+
110+
### API Security
111+
- **Authentication**: Use JWT tokens for protected endpoints
112+
- **Rate limiting**: Apply appropriate limits (default 60/minute)
113+
- **Input validation**: Validate all inputs using Pydantic models
114+
- **CORS**: Configure appropriately for production
115+
- **Environment variables**: Never hardcode secrets, use `.env` files
116+
117+
### Data Protection
118+
- **PII handling**: Mask phone numbers in logs and responses
119+
- **Token security**: Use secure JWT signing, appropriate expiration
120+
- **Database**: Use parameterized queries (SQLAlchemy ORM handles this)
121+
- **File uploads**: Validate file types and sizes if implemented
122+
123+
## Configuration Management
124+
125+
### Environment Variables
126+
Required variables:
127+
```bash
128+
AMAP_API_KEY # Required: Amap API key
129+
```
130+
131+
Optional variables:
132+
```bash
133+
AMAP_SECURITY_JS_CODE # Amap JS security code
134+
AMAP_JS_API_KEY # Amap JS API key
135+
LLM_API_KEY # LLM API key
136+
LLM_API_BASE # LLM base URL
137+
LLM_MODEL # LLM model name
138+
OPENAI_API_KEY # Alternative OpenAI key
139+
PORT # Server port (default 8000)
140+
LOG_LEVEL # Logging level
141+
```
142+
143+
### Configuration Hierarchy
144+
1. Environment variables (highest priority)
145+
2. `config/config.toml` file
146+
3. `config/config.toml.example` (fallback)
147+
4. Hardcoded defaults (lowest priority)
148+
149+
### Adding New Configuration
150+
1. Add to appropriate settings class in `app/config.py`
151+
2. Update `AppConfig` model
152+
3. Add environment variable support
153+
4. Update `config/config.toml.example`
154+
5. Document in README.md
155+
156+
## Error Handling
157+
158+
### Exception Handling
159+
- **Custom exceptions**: Use classes from `app/exceptions.py`
160+
- **HTTP errors**: Return appropriate status codes with meaningful messages
161+
- **Async exceptions**: Always handle in async contexts
162+
- **Logging**: Log errors with context for debugging
163+
164+
### API Error Responses
165+
```python
166+
# Good: Structured error response
167+
{
168+
"success": false,
169+
"error": "geocoding_failed",
170+
"message": "无法解析地址: 北京市朝阳区",
171+
"details": {
172+
"address": "北京市朝阳区",
173+
"provider": "amap"
174+
}
175+
}
176+
```
177+
178+
## Documentation Standards
179+
180+
### Code Documentation
181+
- **Docstrings**: Use Google-style docstrings for all public functions/classes
182+
- **Type hints**: Comprehensive type annotations
183+
- **Comments**: Explain complex business logic, not obvious code
184+
- **README**: Keep up-to-date with setup instructions and API documentation
185+
186+
### API Documentation
187+
- **FastAPI**: Automatic OpenAPI/Swagger documentation
188+
- **Endpoint descriptions**: Clear, concise descriptions of what each endpoint does
189+
- **Request/response examples**: Provide realistic examples
190+
- **Error codes**: Document all possible error responses

.kiro/steering/project-overview.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# MeetSpot Project Overview
2+
3+
## What is MeetSpot?
4+
5+
MeetSpot is an AI-powered multi-person meeting point recommendation system that finds fair meeting locations using geographic algorithms and LLM-based intelligent scoring. It integrates with Amap (高德地图) for geolocation services and uses GPT-4o for semantic analysis.
6+
7+
## Core Architecture
8+
9+
### Technology Stack
10+
- **Backend**: FastAPI + SQLAlchemy (async) + aiosqlite
11+
- **Frontend**: Jinja2 templates + CSS design tokens + Amap JS API
12+
- **AI/LLM**: OpenAI SDK (GPT-4o, DeepSeek), tiktoken for token counting
13+
- **External APIs**: Amap (高德地图) for geocoding and POI search
14+
- **Deployment**: Docker, Render, Vercel support
15+
16+
### Key Components
17+
1. **Intelligent Routing System**: Automatically selects between fast rule-based mode and deep LLM-enhanced Agent mode
18+
2. **5-Step Recommendation Pipeline**: Geocoding → Center calculation → POI search → Ranking → HTML generation
19+
3. **WCAG 2.1 AA Design System**: Accessible color tokens and responsive design
20+
4. **SEO-Optimized Pages**: Schema.org structured data, meta tags, sitemap
21+
5. **Authentication**: JWT + SMS verification system
22+
23+
## Project Structure
24+
```
25+
MeetSpot/
26+
├── api/ # FastAPI application layer
27+
├── app/ # Core business logic (authoritative source)
28+
│ ├── tool/ # Tool implementations (recommender, search, etc.)
29+
│ ├── agent/ # AI Agent system (currently disabled)
30+
│ ├── auth/ # Authentication (JWT, SMS)
31+
│ ├── models/ # SQLAlchemy ORM models
32+
│ └── db/ # Database layer
33+
├── templates/ # Jinja2 templates
34+
├── static/ # CSS, design tokens
35+
├── public/ # Marketing pages, SEO assets
36+
├── workspace/js_src/ # Generated recommendation HTML pages
37+
└── tests/ # Test suite
38+
```
39+
40+
## Development Workflow
41+
- Use `python web_server.py` for local development
42+
- Quality gates: `black .`, `ruff check .`, `mypy app/` must be clean
43+
- Target ≥80% test coverage for `app/` package
44+
- Follow Conventional Commits (`feat:`, `fix:`, `ci:`, `docs:`)
45+
46+
## Key Features
47+
- **Complexity Assessment**: Automatically routes simple requests to fast rule mode, complex ones to LLM mode
48+
- **Multi-factor Scoring**: Base score + popularity + distance + scenario + requirements
49+
- **Brand Knowledge Base**: 60+ brand mappings with feature scores
50+
- **Caching Strategy**: Optimized for memory constraints on cloud platforms
51+
- **Accessibility First**: All colors meet WCAG 2.1 AA contrast requirements

BingSiteAuth.xml

Lines changed: 0 additions & 4 deletions
This file was deleted.

CLAUDE.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ app/design_tokens.py # WCAG AA color palette, CSS generation
101101
api/routers/seo_pages.py # SEO landing pages
102102
```
103103

104+
### Frontend Address Input
105+
106+
`public/meetspot_finder.html` uses AMap Autocomplete API for real-time address suggestions. When users select from dropdown, coordinates are pre-resolved client-side, bypassing backend geocoding. Falls back to backend geocoding when manual text is entered.
107+
104108
### LLM Scoring (Agent Mode)
105109

106110
When Agent Mode is enabled, final venue scores blend rule-based and LLM semantic analysis:
@@ -148,9 +152,9 @@ The `max_distance` filter applies after POI retrieval during ranking. To change
148152
`BRAND_FEATURES` dict in `meetspot_recommender.py` contains 50+ brand profiles (Starbucks, Haidilao, etc.) with feature scores (0.0-1.0) for: quiet, WiFi, business, parking, child-friendly, 24h. Used in requirements matching - brands scoring >=0.7 satisfy the requirement. Place types prefixed with `_` (e.g., `_library`) provide defaults.
149153

150154
### Adding Address Mappings
151-
Two sources for address resolution:
152-
1. **External file**: `data/address_aliases.json` - JSON file with `university_aliases` and `landmark_aliases` dicts. Preferred for new mappings.
153-
2. **Internal dicts**: `university_mapping` and `landmark_mapping` in `_enhance_address()` method of `meetspot_recommender.py`. Use for mappings requiring city prefixes (prevents cross-city geocoding errors).
155+
**Preferred**: Edit `data/address_aliases.json` - maps abbreviations to full names (e.g., "北大" → "北京大学").
156+
157+
**For cross-city issues**: Add to `university_mapping` or `landmark_mapping` dicts in `meetspot_recommender.py` with city prefix (e.g., "华南理工" → "广州市番禺区华南理工大学").
154158

155159
### Adding Venue Themes
156160
Add entry to `PLACE_TYPE_CONFIG` with: Chinese name, Boxicons icons, 6 color values.

0 commit comments

Comments
 (0)