- Project Overview
- Getting Started
- Project Structure
- Development Workflow
- Adding New Features
- Best Practices
- Common Patterns
FlexPrice is a pricing management platform built with:
- React + TypeScript
- TanStack Query for data fetching
- Shadcn UI components
- Tailwind CSS for styling
- Environment management
- Product catalog
- Customer management
- Subscription handling
- Usage tracking
- Invoice management
- Setup Local Environment
# Clone repository
git clone [repository-url]
# Install dependencies
npm install
# Start development server
npm run dev- Required Extensions
- ESLint
- Prettier
- Tailwind CSS IntelliSense
- Environment Configuration
- Copy
.env.exampleto.env.local - Get required API keys from team lead
src/
├── components/ # Reusable UI components
│ ├── atoms/ # Basic components (buttons, inputs)
│ ├── molecules/ # Composite components
│ └── organisms/ # Complex components
├── pages/ # Route components
├── hooks/ # Custom React hooks
├── store/ # Global state management
├── utils/ # Helper functions
│ └── api_requests/ # API integration
├── models/ # TypeScript interfaces
└── core/ # Core application logic
# Create feature branch
git checkout -b feat/[feature-name]
# Create bugfix branch
git checkout -b fix/[bug-name]- Follow atomic design principles
- Keep components focused and single-responsibility
- Use TypeScript interfaces for type safety
- Write unit tests for critical business logic
- Test component behavior
- Run tests before committing:
npm run test
- Understand requirements
- Identify affected components
- Plan data structure
- Design component hierarchy
- Create page component in
src/pages/:
// src/pages/NewFeature/NewFeaturePage.tsx
import { useQuery } from '@tanstack/react-query';
import { NewFeatureApi } from '@/api/NewFeatureApi';
export const NewFeaturePage = () => {
const { data, isLoading } = useQuery({
queryKey: ['new-feature'],
queryFn: NewFeatureApi.getData
});
return (
<div>
{/* Implementation */}
</div>
);
};- Add route in
src/core/routes/Routes.tsx - Create necessary API integration
- Create new file in
src/utils/api_requests/:
// src/utils/api_requests/NewFeatureApi.ts
import { AxiosClient } from '@/core/axios/verbs';
interface NewFeatureData {
// Define interface
}
class NewFeatureApi {
private static baseUrl = '/new-feature';
public static async getData(): Promise<NewFeatureData> {
return await AxiosClient.get(this.baseUrl);
}
}
export default NewFeatureApi;- Determine component level (atom/molecule/organism)
- Create component with proper types:
// src/components/molecules/NewFeature/NewFeature.tsx
interface Props {
data: NewFeatureData;
onAction: (id: string) => void;
}
export const NewFeature: React.FC<Props> = ({ data, onAction }) => {
return (
// Implementation
);
};- Write unit tests
- Test edge cases
- Check performance
- Verify accessibility
- Review code against conventions
- Use React Query for server state
- Use local state for UI state
- Use context for shared state
- Consider Zustand for complex state
try {
await api.request();
} catch (error) {
toast.error('Operation failed');
// Log error if needed
}- Use React.memo for expensive components
- Implement proper loading states
- Optimize re-renders
- Use proper query caching
- Follow ESLint rules
- Use TypeScript strictly
- Write meaningful comments
- Use proper naming conventions
const { data, isLoading, error } = useQuery({
queryKey: ['key'],
queryFn: fetchData,
});import { useForm } from 'react-hook-form';
const { register, handleSubmit } = useForm<FormData>();<ErrorBoundary fallback={<ErrorComponent />}>
<Component />
</ErrorBoundary>{isLoading ? (
<LoadingSpinner />
) : error ? (
<ErrorMessage error={error} />
) : (
<DataDisplay data={data} />
)}-
Build Errors
- Check TypeScript errors
- Verify import paths
- Check for missing dependencies
-
Runtime Errors
- Check browser console
- Verify API responses
- Check state management
-
Performance Issues
- Use React DevTools
- Check for unnecessary re-renders
- Verify query caching
Remember: When in doubt, refer to existing implementations as examples and don't hesitate to ask for help from the team.