|
| 1 | +# Frontend Project Structure & Architecture |
| 2 | + |
| 3 | +## 1. Overview |
| 4 | + |
| 5 | +This document defines the frontend project structure, directory organization, naming conventions, and best practices to ensure maintainability, scalability, and consistency across the codebase. |
| 6 | + |
| 7 | +## 2. General Principles |
| 8 | + |
| 9 | +- **Modularization**: Organize code into feature-based modules rather than generic categories. In module we can import from shared folder, no from another module (except easy_ui). |
| 10 | +- **Separation of Concerns**: Keep UI components, API interactions, state management, and utilities separate. |
| 11 | +- **Naming Consistency**: Follow a strict and predictable naming convention for files and folders. |
| 12 | +- **Scalability**: Design the structure to accommodate future growth and easy feature addition. |
| 13 | +- **Single Responsibility Principle**: Each file should have a clearly defined purpose. |
| 14 | + |
| 15 | +## 3. Structure |
| 16 | + |
| 17 | +### 3.1 Base Structure |
| 18 | + |
| 19 | +``` |
| 20 | +app/frontend/ |
| 21 | +├── entrypoints/ # Contains entry points files |
| 22 | +│ ├── <module_name>.ts # Entry point for a specific module |
| 23 | +│ ├── application.js # Global entrypoint accessible in whole application |
| 24 | +├── src/ # Contains all frontend modules |
| 25 | +│ ├── <module_name>/ # Each module contain subset of module structure or submodules and shared folder |
| 26 | +│ │ ├── <submodule_name>/ # Nested submodules (if needed) with same structure as module |
| 27 | +│ │ ├── shared/ # Shared between submodules, contain subset of module structure |
| 28 | +│ ├── easy_ui/ # Global shared UI components, from this module can be imported in any other module |
| 29 | +│ ├── shared/ # Global shared, contain subset of module structure |
| 30 | +│ ├── tests/ # Unit and integration frontend tests, contains tests structure, more in frontend testing guidelines |
| 31 | +``` |
| 32 | + |
| 33 | +### 3.2 Module Structure |
| 34 | + |
| 35 | +``` |
| 36 | +<module_name>/ |
| 37 | +├── api/ # API services |
| 38 | +├── components/ # Vue components |
| 39 | +├── composables/ # Reusable feature-specific logic (Vue composables) |
| 40 | +├── constants/ # Module-related constants |
| 41 | +├── directives/ # Module-specific directives |
| 42 | +├── graphql/ # GraphQL definitions |
| 43 | +│ ├── fragments/ # GraphQL fragments definitions |
| 44 | +│ ├── mutations/ # GraphQL mutations definitions |
| 45 | +│ ├── queries/ # GraphQL queries definitions |
| 46 | +├── store/ # Module-specific state management stores |
| 47 | +├── stylesheets/ # Global stylesheets, contain structure using atomic design, more in detail in styling guidelines |
| 48 | +├── types/ # TypeScript interfaces & types & enums |
| 49 | +├── utils/ # Utility functions |
| 50 | +``` |
| 51 | + |
| 52 | +<!-- theme: danger --> |
| 53 | +> **Note**: Module can contain submodules and shared folder or subset of module structure. Not submodules and subset of module structure at the same time. If we need to share somethig between submodules we can use shared folder. |
| 54 | +
|
| 55 | +## 4. Naming Conventions |
| 56 | + |
| 57 | +### 4.3 File Naming |
| 58 | + |
| 59 | +- Use **camelCase** for *.ts and *.js filenames. |
| 60 | +- Use **PascalCase** for Vue component filenames. |
| 61 | +- API services: Filename ends with `Api` suffix like `easyAIFeedbackApi.ts` |
| 62 | +- Composables: Filename starts with `use` prefix like `useScrollToBottomMessages.ts` |
| 63 | + |
| 64 | +### 4.2 Directory Naming |
| 65 | + |
| 66 | +- Use **snake_case** for folder names (`easy_scrum_boards`) |
| 67 | +- Use **module-based or shared folders** under `src/`. |
| 68 | +- Use **shared/** inside modules when common components/utils exist across submodules. |
| 69 | + |
| 70 | +### 4.3 Code Naming |
| 71 | + |
| 72 | +- **API services:** Class name ends with `Api` suffix like `class EasyAIFeedbackApi ...` |
| 73 | +- **Composables:** Function name starts with `use` prefix like `const useScrollToBottomMessages = ...` |
| 74 | +- **Directives:** Directive name starts with `v` prefix like `const vTrapTab = ...` |
| 75 | +- **Graphql fragments:** Definitions name ends with `Fragment` suffix like `const easyAIFeedbackFragment = gql(...` |
| 76 | +- **Graphql mutations:** Definitions name ends with `Mutation` suffix like `const easyAIFeedbackMutation = gql(...` |
| 77 | +- **Graphql queries:** Definitions name ends with `Query` suffix like `const easyAIFeedbackQuery = gql(...` |
| 78 | +- **Store:** Store name has prefix `use` and suffix `Store` like `const useEasyAIFeedbackStore = ...` |
| 79 | +- **Typescript enums:** Enum has singular name like `enum EasyAIFeedbackStatus { ... }` |
0 commit comments