From 09584efa393ef44fea9e4991902eff27313117a3 Mon Sep 17 00:00:00 2001 From: Jean Jacques Avril Date: Tue, 11 Mar 2025 10:36:34 +0000 Subject: [PATCH] feat: Add project rules and guidelines for architecture, coding practices, security, documentation, testing, frontend, devops, and development workflow --- .clinerules | 46 ++++++++++++++++++++++++++++++++++++ docu/backend_architecture.md | 2 +- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 .clinerules diff --git a/.clinerules b/.clinerules new file mode 100644 index 0000000..9527ec1 --- /dev/null +++ b/.clinerules @@ -0,0 +1,46 @@ +# TimeTracker Project Rules (v2) + +1. ARCHITECTURE +- Multi-tenancy enforced via company_id in all DB queries +- FPGO/FPTS patterns required for service layer implementations + +2. CODING PRACTICES +- Type safety enforced (Go 1.21+ generics, TypeScript strict mode) +- Domain types must match across backend (Go) and frontend (TypeScript) +- All database access through repository interfaces +- API handlers must use DTOs for input/output +- Use tygo to generate TypeScript types after modifying Go types + +3. SECURITY +- JWT authentication required for all API endpoints +- RBAC implemented in middleware/auth.go +- Input validation using github.com/go-playground/validator +- No raw SQL - use GORM query builder + +4. DOCUMENTATION +- Swagger docs updated with all API changes +- Architecture decisions recorded in docu/ARCHITECTURE.md +- Type relationships documented in docu/domain_types.md + +5. TESTING +- 80%+ test coverage for domain logic +- Integration tests for API endpoints +- Model tests in backend/cmd/modeltest + +6. FRONTEND +- Next.js App Router pattern required +- Server components for data fetching +- Client components must use TanStack Query +- UI state management via Zustand + +7. DEVOPS +- Docker builds must pass Hadolint checks +- Kubernetes manifests in gitops/ directory +- Monitoring via OpenTelemetry instrumentation + +8. DEVELOPMENT WORKFLOW +- Use Makefile commands for common tasks: + - make generate: Run code generation (tygo, swagger, etc.) + - make test: Run all tests + - make build: Build the application + - make run: Start the development server \ No newline at end of file diff --git a/docu/backend_architecture.md b/docu/backend_architecture.md index 0ebd94a..55b5c56 100644 --- a/docu/backend_architecture.md +++ b/docu/backend_architecture.md @@ -2,7 +2,7 @@ **Note:** This document describes a *conceptual* architecture and is not a final, binding requirement. -The backend is written in Go and follows the principles of **Clean Architecture** and **Domain-Driven Design (DDD)**. +The backend is written in Go using idiomatic Go patterns. While initially following Clean Architecture and DDD principles, we've adapted to a more pragmatic approach that better fits Go's conventions and reduces boilerplate code. ## Project Structure ```