Skip to content

Commit 38d9852

Browse files
Abbreviated project docs in llms.txt
1 parent 47bcdd1 commit 38d9852

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

docs/static/llms.txt

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Project Architecture
2+
- Keep GET routes in main.py and POST routes in routers/ directory
3+
- Name GET routes using read_<name> convention
4+
- Follow Post-Redirect-Get (PRG) pattern for all form submissions
5+
- Use Jinja2 HTML templates for server-side rendering and minimize client-side JavaScript
6+
- Use forms for all POST routes
7+
- Validate form data comprehensively on the client side as first line of defense, with server-side Pydantic validation as fallback
8+
9+
# File Structure
10+
- main.py: Application entry point and GET routes
11+
- routers/: POST route modules
12+
- templates/: Jinja2 templates
13+
- static/: Static assets
14+
- tests/: Unit tests
15+
- utils/: Helper functions and models
16+
- docker-compose.yml: Test database configuration
17+
- .env: Environment variables
18+
19+
# Python/FastAPI Guidelines
20+
- For all POST routes, define request models in a separate section at the top of the router file
21+
- Implement as_form() classmethod for all form-handling request models
22+
- Use Pydantic for request/response models with @field_validator and custom exceptions for custom form validation
23+
- Use middleware defined in main.py for centralized exception handling
24+
- Add type hints to all function signatures and variables
25+
- Follow mypy type checking standards rigorously
26+
27+
# Form Validation Strategy
28+
- Implement thorough client-side validation via HTML pattern attributes where possible and Javascript otherwise
29+
- Use Pydantic models with custom validators as server-side fallback
30+
- Handle validation errors through middleware exception handlers
31+
- Render validation_error.html template for failed server-side validation
32+
33+
# Database Operations
34+
- Use SQLModel for all database interactions
35+
- Use get_session() from utils/db.py for database connections
36+
- Define database relational models explicitly in utils/models.py
37+
- Inject database session as dependency in route handlers
38+
39+
# Authentication System
40+
- JWT-based token authentication with separate access/refresh tokens and bcrypt for password hashing are defined in utils/auth.py
41+
- Password and email reset tokens with expiration and password reset email flow powered by Resend are defined in utils/auth.py
42+
- HTTP-only cookies are implemented with secure flag and SameSite=strict
43+
- Inject common_authenticated_parameters as a dependency in all authenticated GET routes
44+
- Inject common_unauthenticated_parameters as a dependency in all unauthenticated GET routes
45+
- Inject get_session as a dependency in all POST routes
46+
- Handle security-related errors without leaking information
47+
48+
# Testing
49+
- Run mypy type checking before committing code
50+
- Write comprehensive unit tests using pytest
51+
- Test both success and error cases
52+
- Use test fixtures from tests/conftest.py: engine, session, client, test_user
53+
- set_up_database and clean_db fixtures are autoused by pytest to ensure clean database state
54+
55+
# Error Handling
56+
- Use middleware for centralized exception handling
57+
- Define custom exception classes for specific error cases
58+
- Return appropriate HTTP status codes and error messages
59+
- Render error templates with context data
60+
- Log errors with "uvicorn.error" logger
61+
62+
# Template Structure
63+
- Extend base.html for consistent layout
64+
- Use block tags for content sections
65+
- Include reusable components
66+
- Pass request object and context data to all templates
67+
- Keep form validation logic in corresponding templates
68+
- Use Bootstrap for styling
69+
70+
# Contributing Guidelines
71+
- Follow existing code style and patterns
72+
- Preserve existing comments and docstrings
73+
- Ensure all tests pass before submitting PR
74+
- Update .qmd documentation files for significant changes
75+
- Use Poetry for dependency management

0 commit comments

Comments
 (0)