You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: General description of the backend used in the repository. Use this to have more context on the /backend structure.
3
+
globs: backend, *.py
4
+
alwaysApply: false
5
+
---
6
+
# Cursor Rules for FastAPI Backend Project
7
+
8
+
## Project Overview
9
+
This is a FastAPI backend project structured with SQLModel for database models, JWT authentication, and a modular architecture. The project uses PostgreSQL for data storage, uv for package management, and follows a clear separation of concerns.
10
+
11
+
## Key Technologies
12
+
- **FastAPI**: Web framework for building APIs
13
+
- **SQLModel**: ORM for working with SQL databases
14
+
- **PostgreSQL**: Database backend
15
+
- **JWT**: For authentication
16
+
- **uv**: For Python package and environment management
17
+
- **Alembic**: For database migrations
18
+
- **Docker**: For containerization
19
+
20
+
## Project Structure Rules
21
+
22
+
### Core Components
23
+
- **/app/core/**: Contains core configuration and utilities
24
+
- **config.py**: Centralized configuration using Pydantic settings
25
+
- **security.py**: Authentication and security functions
26
+
- **db.py**: Database engine and initialization
27
+
28
+
### Models
29
+
- **/app/models.py**: All data models are defined using SQLModel
30
+
- Models use UUID fields as primary keys
31
+
- Relationships are defined with cascading delete behavior
32
+
- Models include clear separation between base, public, and internal models
33
+
34
+
### API Structure
35
+
- **/app/api/**: API route definitions and dependencies
36
+
- **/api/routes/**: Organized by resource (users, items, login, etc.)
37
+
- **/api/deps.py**: Dependency injection for routes
38
+
39
+
### Authentication
40
+
- JWT-based authentication is implemented
41
+
- Access tokens expire after configurable time (8 days default)
42
+
- Password recovery flow is supported
43
+
44
+
### Database
45
+
- Models are managed via Alembic migrations
46
+
- UUIDs are used for all IDs (migrated from integers)
47
+
- String fields have explicit max lengths
48
+
49
+
### Environment
50
+
- Environment variables are loaded from .env file
51
+
- Development vs production environment settings
52
+
- CORS settings for frontend communication
53
+
54
+
### Email Templates
55
+
- Located in **/app/email-templates/**
56
+
- Built from MJML source files to HTML
57
+
58
+
## Development Rules
59
+
60
+
### Code Patterns
61
+
- Use type annotations throughout
62
+
- Follow REST principles for API endpoints
63
+
- Use dependency injection via FastAPI
64
+
- Use SQLModel for database operations
65
+
- Handle errors with proper HTTP status codes
66
+
67
+
### Testing
68
+
- Tests are in **/app/tests/**
69
+
- Tests use pytest fixtures for database and client
70
+
- Mock external services in tests
71
+
72
+
### Docker Setup
73
+
- Use Docker Compose for local development
74
+
- FastAPI run with live reloading during development
75
+
- PostgreSQL database runs in a container
76
+
77
+
## API Response Standards
78
+
- Consistent response objects for collections (with count and data fields)
79
+
- Use of standard message response objects
80
+
- Proper error handling with appropriate status codes
0 commit comments