Standards & Reference

Code Organization

Status: [ ] Not Started | [ ] In Progress | [ ] Complete | [ ] Approved

This document defines the codebase organization, naming conventions, and module boundaries. Complete this document during the Global Setup phase before creating any feature specifications.


Directory Organization

Root Structure

[TODO: Define root directory structure]

Example:
project-root/
├── .flowstate/           # FlowState configuration and docs
├── packages/             # Monorepo packages
├── apps/                 # Application entry points
├── libs/                 # Shared libraries
├── tools/                # Build and dev tools
├── docs/                 # Documentation
└── tests/                # Test suites

Package Structure

[TODO: Define package structure]

Example:
packages/{package-name}/
├── src/
│   ├── index.ts         # Public exports
│   ├── types.ts         # Type definitions
│   └── {feature}/       # Feature modules
├── tests/               # Package tests
├── package.json
├── tsconfig.json
└── README.md

Naming Conventions

Files and Directories

TypeConventionExample
Directories[TODO][TODO]
React Components[TODO][TODO]
Utility Files[TODO][TODO]
Test Files[TODO][TODO]
Type Files[TODO][TODO]
Config Files[TODO][TODO]

Code Elements

TypeConventionExample
Classes[TODO][TODO]
Functions[TODO][TODO]
Variables[TODO][TODO]
Constants[TODO][TODO]
Types/Interfaces[TODO][TODO]
Enums[TODO][TODO]

Database and API

TypeConventionExample
Table Names[TODO][TODO]
Column Names[TODO][TODO]
API Endpoints[TODO][TODO]
Query Parameters[TODO][TODO]

Module Boundaries

Package Dependencies

[TODO: Define dependency rules]

Example:
apps/* → packages/*     (allowed)
packages/* → libs/*     (allowed)
libs/* → packages/*     (NOT allowed - circular)

Layer Architecture

[TODO: Define layer structure]

Example:
UI Layer (components)

Application Layer (hooks, services)

Domain Layer (models, business logic)

Infrastructure Layer (API, database)

Import Patterns

Import Order

// [TODO: Define import order]

// Example:
// 1. External dependencies
import React from 'react';
import { useQuery } from '@tanstack/react-query';

// 2. Internal packages
import { Button } from '@project/ui';
import { useAuth } from '@project/auth';

// 3. Relative imports
import { UserCard } from './UserCard';
import { formatDate } from '../utils';

// 4. Type imports
import type { User } from '@project/types';

Path Aliases

AliasTargetUsage
[TODO][TODO][TODO]
[TODO][TODO][TODO]

Component Organization

Component Structure

// [TODO: Define component structure]

// Example:
// 1. Imports
// 2. Types/Interfaces
// 3. Constants
// 4. Helper functions
// 5. Component definition
// 6. Exports

Component Co-location

[TODO: Define co-location rules]

Example:
ComponentName/
├── index.ts              # Public export
├── ComponentName.tsx     # Main component
├── ComponentName.test.tsx # Tests
├── ComponentName.styles.ts # Styles (if applicable)
└── types.ts              # Component-specific types

Test Organization

Test File Placement

Test TypeLocationNaming
Unit Tests[TODO][TODO]
Integration Tests[TODO][TODO]
E2E Tests[TODO][TODO]

Test Structure

// [TODO: Define test structure]

Configuration Files

Standard Config Files

FilePurposeLocation
[TODO][TODO][TODO]
[TODO][TODO][TODO]

Environment Configuration

EnvironmentConfig FilePurpose
Development[TODO][TODO]
Testing[TODO][TODO]
Production[TODO][TODO]

Documentation Structure

Documentation Types

TypeLocationPurpose
API Docs[TODO][TODO]
README[TODO][TODO]
CLAUDE.md[TODO][TODO]
Architecture[TODO][TODO]

Approval

RoleNameDateSignature
Technical Lead
Senior Developer

Last Updated: [Date] Document Owner: [Name]

Previous
Architecture