# Project-Specific Instructions for Cursor AI
## General Guidelines
- Write clear, readable, and well-documented Python code
- Follow PEP 8 style guidelines for code formatting
- Use type hints consistently throughout the codebase
- Implement proper error handling and logging
## Project Structure
- Follow strict directory structure:
- `src/api/endpoints/` - API endpoint modules
- `src/services/` - Business logic services
- `src/models/` - Pydantic models and schemas
- `src/utils/` - Utility functions
- `src/config.py` - Configuration settings
- `tools/` - Development tools
## API Implementation
- Required endpoints:
- `/api/v1/market-data` - Market overview
- `/api/v1/stock/{symbol}` - Stock details
- `/api/v1/stock/{symbol}/analysis-history` - Analysis history
- `/api/v1/analysis/{analysis_id}` - Analysis content
- `/api/v1/stock/{symbol}/refresh-analysis` - Generate new analysis
## Database Schema
- Collections:
- `detailed_financials` - Stock financial data
- `ai_analysis` - AI-generated analysis results
## AI Integration
- Use xAI's Grok model for analysis
- Required environment variables:
- XAI_API_KEY
- XAI_API_URL
## Caching Strategy
- TTL-based caching for:
- Market data (1 hour)
- Stock analysis (24 hours)
- AI insights (6 hours)
## Error Handling
- Use custom exception classes
- Implement proper error logging
- Return appropriate HTTP status codes
- Include detailed error messages
## Performance Requirements
- Maximum response time: 500ms
- Implement connection pooling
- Use proper database indexing
- Cache frequently accessed data
## Security
- Required environment variables:
- MONGODB_URI
- MONGODB_DB_NAME
- API_KEYS
- ALLOWED_ORIGINS
## Testing
- Implement pytest test cases
- Test coverage requirements:
- API endpoints: 90%
- Services: 85%
- Utils: 80%
## Documentation
- OpenAPI documentation
- Function docstrings
- README.md updates
- API endpoint documentation
golang
mongodb
python