Coding Guidelines
General Principles
- Match the existing style — read the surrounding file before writing new code
- No unnecessary abstractions — only introduce one when there is clear evidence of duplication
- Explicit over implicit — prefer explicit types, explicit error handling, explicit data flow
- No speculative features — only implement what the current task requires
- Security by default — validate inputs, never log secrets, never expose tokens
Backend (Java / Spring Boot)
Package Structure
Follow the existing module layout: com.upblit.backend.<module>.<layer>
Layers: controller, service, repository, model / entity, DTO
Naming
| Type | Convention | Example |
|---|---|---|
| Controller | PascalCaseController.java | ApplicationController.java |
| Service | PascalCaseService.java | OrganizationService.java |
| Repository | PascalCaseRepository.java | TraceRepository.java |
| Entity | PascalCase.java | Organization.java |
| DTO | PascalCaseDTO.java | OrganizationDTO.java |
Rules
- Use
ResponseEntity<T>for all controller return types - Use
Optional<T>from repositories — never returnnullfrom service methods - Use
WebClientfor outbound HTTP — notRestTemplate - All env-sensitive config via
${ENV_VAR}inapplication.properties - Use Lombok
@Data,@Builder,@NoArgsConstructor,@AllArgsConstructorwhere appropriate - Never expose JPA entities directly in API responses — use DTOs
Frontend (TypeScript / Next.js)
Rules
- All backend calls go through
src/lib/api.tsorsrc/lib/upblit-api.ts— never callfetch()directly in a component - Use
"use client"directive only when needed (event handlers, hooks, browser APIs) - CSS Modules for component-specific styles —
ComponentName.module.cssco-located with the component - All icons from
lucide-react— no other icon libraries - All animations via
framer-motion— no CSS transitions for interactive animations - All images via
next/image— never<img>tags - No
anytypes without a comment explaining why - Use
normalizeProject,normalizeApplication,normalizeOrganizationhelpers when mapping API responses
Dark Theme Tokens
Background: #000 / #1c1b1b
Text: #e5e2e1 / #c3c5d9
Borders: #353534 / #434656
Brand blue: #0052ffSDKs
All SDKs Must
- Buffer traces and logs separately in memory
- Flush on a configurable interval (default 30s)
- Re-queue failed batches on transport error — never drop data
- Use
x-api-keyheader for authentication - Skip
GET /healthin middleware — do not trace health checks - Accept
baseURLandflushIntervalas constructor parameters — never read env vars
Span Naming
Always use the type:name prefix format:
controller:POST
service:getUserById
external:stripeGo
- Use
PascalCasefor exported types and functions - Use
camelCasefor unexported identifiers - Use
snake_casefor file names - All buffer operations must be protected by
sync.Mutex - Use functional options pattern for SDK configuration
Python
- Use
snake_casefor functions and variables - Use
PascalCasefor classes - All buffer operations must use
threading.RLock - Async span helpers must work with both sync and async callables
Last updated on