Imported from aps08/fullstack-clean-architecture (
AGENTS.md). Install upstream withnpx skills add aps08/fullstack-clean-architecture. Copyright stays with the author.
Agent & Project Guidelines
Welcome! This document provides commands, rules, and guidelines for developing and managing the Tempto project.
Agent Behavior Rules
These rules take highest priority and must be followed at all times.
- Keep responses short — Always give the smallest response possible unless the user explicitly asks to describe in detail (e.g., "explain", "describe", "in detail").
- No code changes on questions — If the user says "tell me", "how", asks a question with "?", or uses similar inquiry language, only answer — do not modify any code or files.
- Explain differences with tables — Whenever explaining a difference or comparison between two or more things, always use a markdown table.
🚀 Quick Commands
Frontend (web/)
- Install:
pnpm install - Development Server:
pnpm dev - Production Build:
pnpm build - Preview Build:
pnpm preview - Linting:
pnpm lint - Lint & Fix:
pnpm lint:fix - Formatting:
pnpm format - Format Check:
pnpm format:check - Unit Testing (watch):
pnpm test - Unit Testing (UI):
pnpm test:ui - Unit Testing (coverage):
pnpm test:cov - E2E Testing:
pnpm test:e2e
Backend (server/)
- Environment Sync:
uv sync - Development Server:
uv run task dev - Run Linter:
uv run task check - Run Formatter:
uv run task format - Type Checking:
uv run task type-check - Database Migrations:
- Upgrade:
uv run task upgrade(runsalembic upgrade head) - Downgrade:
uv run task downgrade(runsalembic downgrade -1)
- Upgrade:
- Testing:
uv run task test - Generate Coverage HTML Report:
uv run task cov-html(runspytest --cov=app --cov-report=html)
Backend Folder Structure (server/)
The application resides in the server/app/ directory:
-
core/: Core configurations, containers (dependency injection), DB connectors, standard middleware, unified exceptions, logging, security, and global dependencies. -
models/: Declarative SQLAlchemy models (subclassingBaseModel). -
repositories/: Repositories handling database data access (inheriting fromBaseRepository). -
schemas/: Pydantic request/response validation schemas (inheriting fromBaseModel/ usingto_camelandpopulate_by_name). -
services/: Service classes implementing business logic (inheriting fromBaseService). -
routes/: API routers and controllers organized by version:v1/: Auth endpoints (routes.py,endpoints/auth.py).v2/: Resource-oriented REST APIs (routes.py,endpoints/todos.py,endpoints/attachments.py,endpoints/users.py).
-
utils/: Core utilities and helpers.
Frontend Folder Structure (web/)
The source code resides in the web/src/ directory:
-
components/: Reusable component library. Shared/atomic inputs are placed incommon/(e.g.Button.tsx,Input.tsx,Modal.tsx). -
constants/: Shared UI and navigation configuration constants. -
features/: Modular components implementing feature-specific pages (e.g.,todo/TodoList.tsx,todo/TodoEdit.tsx,Archives.tsx,Attachments.tsx). -
hooks/: React state and fetching hooks:queries/: React Query hooks for fetching data (e.g.,todos.ts).mutations/: React Query mutations for sending data (e.g.,auth.ts,todos.ts).shared/: Generic frontend helpers (e.g.,useDebounce.ts).
-
lib/: Client utilities such as the API axiosclient.tsand query configurationquery.ts. -
models/: Client-side Zod validation schemas and types (e.g.,todo.ts,attachment.ts). -
routes/: File-based TanStack Router configuration directories (e.g.,_authenticated/,_guest/). -
store/: Client-side state stores (e.g.auth.store.ts). -
utils/: Formatting and processing helper functions (e.g.helper.ts).
Backend Technology Stack
- FastAPI (Async) for the API layer.
- SQLAlchemy 2.0 (Async) with
asyncpgfor database connection and ORM. - Dependency Injector for IoC container management.
- Alembic for schema migrations.
- Clean Architecture Principles: Keep business logic separated (Routes -> Services -> Repositories -> Models).
Frontend Technology Stack
- React 19 (TypeScript) built with Vite 8.
- React Compiler (babel-plugin-react-compiler): Memoization is automatic. Avoid manual
useMemoanduseCallbackunless necessary. - TanStack Router: File-based routing with automatic code-splitting enabled in
vite.config.ts. - TanStack Query & Form: Server state caching and type-safe form validations.
- Zod: Validation schemas aligned with backend Pydantic models.
📖 Coding & Design Guidelines
Frontend
- Routing & Code Splitting:
- Keep page-specific components inside the
web/src/features/directory. - Map them to files in
web/src/routes/using static route configurations. The build pipeline handles code splitting automatically.
- Keep page-specific components inside the
- Search Components:
- When searching within a paginated view, always reset the current page parameter to
1on query changes (setPage(1)) to avoid out-of-bounds pagination matches.
- When searching within a paginated view, always reset the current page parameter to
- MIME Types vs. Filenames:
- Always resolve visual elements (like file type icons via
getAttachmentIcon(filename)) using the actual file name/extension rather than the MIME type string.
- Always resolve visual elements (like file type icons via
- For writing test for frontend check the
react testingskill.
Backend
- Async Flow: Always use
async/awaitfor database actions, API calls, and handlers. - Rate Limiting: Apply
@rate_limitdecorators to API endpoints according to resource utilization profiles. - UTC Datetimes: Always save and process times using timezone-aware UTC format.
- Background Tasks: Use
BackgroundTaskswhen sending emails or other long-running tasks to prevent user delays in response to user requests. - For writing test for backend check the
python testingskill.
STRICTLY FOLLOW THESE RULES
- Run
uv run task check,uv run task formatanduv run task type-checkif more than 5*.pyfiles in the backend (server/app) codebase have been changed in the current session. - Run
uv run task cov-htmloruv run task testif changes have been made to*.pyfiles in the backend (server/) codebase inside thetestsdirectory. - Run
pnpm lint,pnpm lint:fix,pnpm formatandpnpm format:checkif more than 10*.tsor*.tsxfiles inweb/src/have been changed in the current session. - Run
pnpm testorpnpm test:covif changes have been made to files in theweb/tests/directory and more than 5 files have changed in the current session. - Always update
docs/API_FLOW.mdwhen making changes to the backend API using the documentation skills. - Always update
docs/DATA_MODEL.mdwhen making changes to the database schema using the documentation skills.