To ensure professional quality and maintainability, English is established as the sole official language. All team members must use English for source code (variable names, functions, and classes), comments, commit messages, and technical documentation.
- Code Standards (Syntax & Style)
- Comment Normalization
- Database (DB) Normalization
- Branch and Commit Normalization
- File and Folder Normalization
- Other Normalization Types
- Variables and Functions: Use
camelCase(e.g.,basePrice,calculateShipping()). - Classes and Components: Use
PascalCase(e.g.,SellerProfile,ProductGrid). - Global Constants: Use
UPPER_SNAKE_CASE(e.g.,MAX_STOCK_LIMIT,API_ENDPOINT).
- Variables: Prioritize
constfor values that do not change; useletonly when necessary. The use ofvaris strictly prohibited. - Functions: Prefer Arrow Functions for a more modern and clean syntax.
- Semicolons: Mandatory at the end of each statement to avoid interpretation errors.
- Function Comments (Optional): Use only for highly complex business logic within the marketplace.
- Standard Syntax:
- Single-line comments: Use double forward slashes.
// Brief explanation of a non-obvious technical decision. - Block comments: For optional complex functions.
- Single-line comments: Use double forward slashes.
- Tracking Tags: For pending tasks, always use the uppercase prefix:
// TODO: Description of what needs to be implemented.
Example:
/**
* Handles the state change of a C2C sale.
* Validates stock before locking the buyer's funds.
*/
async function processTransaction(sellerId, productId) {
// TODO: (Owner-Name) Integrate with the payment gateway module
if (!checkStock(productId)) {
return "OUT_OF_STOCK";
}
// Safety pause to prevent Race Conditions
const transactionStatus = await lockFunds(sellerId);
return transactionStatus;
}- DB Language: The entire schema (table names, columns, and relations) must be in English.
- Naming Style: Strictly use
snake_casefor all database elements (tables, columns, indexes). - Table Naming:
- Must be plural and in English (e.g.,
users,products,transactions). - Intermediate tables for many-to-many relationships should join both table names (e.g.,
products_tags).
- Must be plural and in English (e.g.,
- Column Naming:
- Primary Key: Always named
id(UUID or Serial Autoincrement). - Foreign Keys: Follow the format
table_singular_id(e.g.,user_id,product_id). - General: Descriptive lowercase names separated by underscores (e.g.,
first_name,phone_number,is_verified). - Booleans: Use prefixes like
is_,has_, orcan_(e.g.,is_active,has_stock).
- Primary Key: Always named
main: Protected branch containing stable and final marketplace code. Only the Tech Lead performs merges here.develop: Integration branch where all features are merged before moving tomain.feature/: For new functionalities (e.g.,feature/user-auth,feature/product-listing).fix/: For bug fixes (e.g.,fix/login-bug).docs/: For changes in documentation or READMEs.
The golden rule: One commit = One logical unit of work.
Format: <type>: subject.
<type>must be lowercase (e.g.,feat,fix,docs,refactor,wip).<subject>can start with lowercase or uppercase.feat: New functionality (e.g.,feat: add product upload for sellersorfeat: Add product upload for sellers).fix: Bug fix (e.g.,fix: header responsive issueorfix: Header responsive issue).docs: Documentation changes (e.g.,docs: update contributing guideordocs: Update contributing guide).refactor: Code changes that neither fix a bug nor add a feature (e.g.,refactor: simplify price calculation logicorrefactor: Simplify price calculation logic).
Commits can be pushed to continue work on another machine or to get help.
- Use the wip (Work In Progress) prefix.
- Example:
git commit -m "wip: Product upload form (halfway through styling)". - Note: Clean up or squash these commits once the logical unit is complete.
- Logic/JavaScript Files: Use
kebab-case(e.g.,user-controller.js,auth-middleware.js). - Frontend Components: Use
PascalCaseto match the component name (e.g.,ProductCard.tsx). - Styles (CSS/SASS): Use
kebab-case(e.g.,main-layout.css).
- Folder names must always be lowercase and in English.
- Use descriptive plural names for containers (e.g.,
/src/components,/src/services,/src/utils). - Rule of "One file, one responsibility": Each file should contain a single main logical piece.
- Indices: Use
index.jsfiles within folders to centralize exports and clean up import paths.
- Formats: Only
.jpg,.png, and.webpare accepted for product photos. - Max Size: 2MB per image to ensure performance and avoid server saturation.
- Naming: Uploaded files will be automatically renamed on the server with a unique ID (e.g.,
prod_550e8400.webp).
All API responses must follow this consistent structure:
- Success:
{ "status": "success", "data": { ... } } - Error:
{ "status": "error", "message": "Clear description of the error", "code": 400 }