Skip to content

Commit 1edecbb

Browse files
committed
Add cursor instructions
1 parent 42819be commit 1edecbb

2 files changed

Lines changed: 59 additions & 1 deletion

File tree

.cursor/rules/instructions.mdc

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
description: RPC Service boilerplate
3+
globs:
4+
alwaysApply: false
5+
---
6+
# Copilot Contribution Instructions
7+
8+
Welcome to the Vinta Schedule project! This guide provides instructions for contributing to the codebase, with details on architecture, patterns, and best practices.
9+
10+
## Dependency Injection
11+
- We use [`dependency_injector`](https://python-dependency-injector.ets-labs.org/) for dependency injection.
12+
- The `di_core` app contains our DI containers and configuration. All services and components should be registered in the container defined in `di_core/containers.py`.
13+
- When developing new services, inject dependencies via the container rather than direct imports.
14+
15+
## Service Development
16+
- Services are typically placed in the `services/` subdirectory of each app (e.g., `calendar_integration/services/`).
17+
- Services should be stateless and receive dependencies via DI.
18+
- Follow the single responsibility principle: each service should do one thing well.
19+
20+
## Custom Managers and Querysets
21+
- Custom model managers and querysets are defined in each app's `managers.py` and `querysets.py` files.
22+
- Use custom managers to encapsulate query logic and expose domain-specific methods.
23+
- Querysets should be chainable and composable.
24+
- No complex queryset should be created within services/views/serializers. We must always define methods in custom managers/querysets to simplify the code and centralize querying logic.
25+
- Example: see @calendar_integration/managers.py and @calendar_integration/querysets.py.
26+
27+
## Django Virtual Models
28+
- We use [`django-virtual-models`](https://github.com/vintasoftware/django-virtual-models) for optimizing Django ORM querysets based on the Django REST Framework Serializers attached on views/endpoints.
29+
- Virtual models are defined in each app's `virtual_models.py` file.
30+
- Use virtual models for optimizing querysets in API responses.
31+
32+
## Custom Views (common app)
33+
- Shared views are defined in @common/views.py.
34+
- Use these views for reusable logic across apps.
35+
- When creating new views, prefer class-based views/viewsets and leverage mixins from the common app.
36+
37+
## Multi-Tenancy
38+
- Multi-tenancy is implemented via the `organizations` and `common` apps.
39+
- Organization context is managed in models, views, and services.
40+
- Always scope queries and business logic to the current organization. This is mandatory and not respecting it will lead to exceptions.
41+
- Tenant-scoped models must inherit from the OrganizationModel abstract model class.
42+
43+
## Testing
44+
- We use [`pytest`](https://docs.pytest.org/) for testing.
45+
- Tests are located in each app's `tests/` directory.
46+
- Write unit, integration, and functional tests for all new code.
47+
- Use pytest fixtures for setup and teardown.
48+
- Run tests with `pytest` from the project root.
49+
50+
## General Contribution Guidelines
51+
- Follow Ruff standards, its configuration can be seen in @pyproject.toml.
52+
- Use static typing for every class/function/method you define. Please use python type inference as much as possible to avoid redefining types.
53+
- Document public classes, methods, and functions.
54+
- Write meaningful commit messages.
55+
- Open pull requests with a clear description of changes and related issues.
56+
57+
For more details, refer to the README and code comments.

.github/copilot-instruction.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ Welcome to the Vinta Schedule project! This guide provides instructions for cont
4343
- Run tests with `pytest` from the project root.
4444

4545
## General Contribution Guidelines
46-
- Follow PEP8 and our code style conventions.
46+
- Follow Ruff standards, its configuration can be seen in @pyproject.toml.
47+
- Use static typing for every class/function/method you define. Please use python type inference as much as possible to avoid redefining types.
4748
- Document public classes, methods, and functions.
4849
- Write meaningful commit messages.
4950
- Open pull requests with a clear description of changes and related issues.

0 commit comments

Comments
 (0)