|
| 1 | +# Contributing to Swoopin |
| 2 | + |
| 3 | +Thank you for your interest in contributing to Swoopin! This document provides guidelines and instructions for contributing to the project. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +- [Project Structure](#project-structure) |
| 8 | +- [Development Workflow](#development-workflow) |
| 9 | +- [Adding New Features](#adding-new-features) |
| 10 | +- [Code Style Guidelines](#code-style-guidelines) |
| 11 | +- [Testing](#testing) |
| 12 | +- [Pull Request Process](#pull-request-process) |
| 13 | + |
| 14 | +## Project Structure |
| 15 | + |
| 16 | +Swoopin follows a modular architecture with clear separation of concerns: |
| 17 | + |
| 18 | +``` |
| 19 | +src/ |
| 20 | +├── actions/ # Server actions for data mutations |
| 21 | +├── app/ # Next.js app router pages and API routes |
| 22 | +├── components/ # Reusable UI components |
| 23 | +├── constants/ # Global constants and configurations |
| 24 | +├── hooks/ # Custom React hooks |
| 25 | +├── icons/ # SVG icons as React components |
| 26 | +├── lib/ # Utility functions and service integrations |
| 27 | +├── providers/ # Context providers (Redux, Theme, etc.) |
| 28 | +├── redux/ # Redux store and slices |
| 29 | +└── types/ # TypeScript type definitions |
| 30 | +``` |
| 31 | + |
| 32 | +### Key Directories Explained |
| 33 | + |
| 34 | +- **actions/**: Contains server-side actions for data mutations, organized by feature (analytics, automations, integrations, etc.) |
| 35 | +- **app/**: Next.js 14 app router pages and API routes |
| 36 | + - `(auth)/`: Authentication-related pages |
| 37 | + - `(landingpage)/`: Public landing pages |
| 38 | + - `(protected)/`: Authenticated user pages |
| 39 | + - `api/`: API routes for external integrations |
| 40 | +- **components/**: |
| 41 | + - `global/`: Shared components used across multiple pages |
| 42 | + - `ui/`: Basic UI components (buttons, inputs, etc.) |
| 43 | + |
| 44 | +## Development Workflow |
| 45 | + |
| 46 | +1. **Fork and Clone** |
| 47 | + ```bash |
| 48 | + git clone https://github.com/your-username/swoopin.git |
| 49 | + cd swoopin |
| 50 | + ``` |
| 51 | + |
| 52 | +2. **Install Dependencies** |
| 53 | + ```bash |
| 54 | + npm install |
| 55 | + ``` |
| 56 | + |
| 57 | +3. **Set Up Environment** |
| 58 | + - Copy `.env.example` to `.env` |
| 59 | + - Add required environment variables: |
| 60 | + ```env |
| 61 | + NEXT_PUBLIC_HOST_URL=your_host_url |
| 62 | + STRIPE_SUBSCRIPTION_PRICE_ID=your_stripe_price_id |
| 63 | + # Add other required variables |
| 64 | + ``` |
| 65 | +
|
| 66 | +4. **Start Development Server** |
| 67 | + ```bash |
| 68 | + npm run dev |
| 69 | + ``` |
| 70 | + |
| 71 | +## Adding New Features |
| 72 | + |
| 73 | +1. **Create a New Branch** |
| 74 | + ```bash |
| 75 | + git checkout -b feature/your-feature-name |
| 76 | + ``` |
| 77 | + |
| 78 | +2. **Feature Implementation Guidelines** |
| 79 | + - Place new components in appropriate directories: |
| 80 | + - Global components in `src/components/global` |
| 81 | + - Page-specific components in their respective page directories |
| 82 | + - Add new API routes in `src/app/api` |
| 83 | + - Include server actions in `src/actions` |
| 84 | + - Update types in `src/types` |
| 85 | + |
| 86 | +3. **State Management** |
| 87 | + - Use Redux for global state management |
| 88 | + - Create new slices in `src/redux/slices` |
| 89 | + - Use React Query for server state management |
| 90 | + |
| 91 | +4. **Database Changes** |
| 92 | + - Update Prisma schema in `prisma/schema.prisma` |
| 93 | + - Generate migrations: |
| 94 | + ```bash |
| 95 | + npx prisma migrate dev --name your_migration_name |
| 96 | + ``` |
| 97 | + |
| 98 | +## Code Style Guidelines |
| 99 | + |
| 100 | +1. **TypeScript** |
| 101 | + - Use TypeScript for all new code |
| 102 | + - Define interfaces and types in `src/types` |
| 103 | + - Avoid using `any` type |
| 104 | + |
| 105 | +2. **Component Structure** |
| 106 | + ```typescript |
| 107 | + import { FC } from 'react'; |
| 108 | + |
| 109 | + interface ComponentProps { |
| 110 | + // Define props |
| 111 | + } |
| 112 | + |
| 113 | + export const Component: FC<ComponentProps> = ({ props }) => { |
| 114 | + return ( |
| 115 | + // JSX |
| 116 | + ); |
| 117 | + }; |
| 118 | + ``` |
| 119 | +
|
| 120 | +3. **Naming Conventions** |
| 121 | + - Components: PascalCase |
| 122 | + - Files: kebab-case |
| 123 | + - Functions: camelCase |
| 124 | + - Constants: UPPER_SNAKE_CASE |
| 125 | +
|
| 126 | +4. **CSS/Styling** |
| 127 | + - Use Tailwind CSS classes |
| 128 | + - Follow mobile-first approach |
| 129 | + - Use CSS modules for custom styles |
| 130 | +
|
| 131 | +## Testing |
| 132 | +
|
| 133 | +1. **Unit Tests** |
| 134 | + - Write tests for utility functions |
| 135 | + - Test React components using React Testing Library |
| 136 | + - Place tests next to the implementation files |
| 137 | +
|
| 138 | +2. **Integration Tests** |
| 139 | + - Test API routes |
| 140 | + - Test database interactions |
| 141 | + - Verify feature workflows |
| 142 | +
|
| 143 | +## Pull Request Process |
| 144 | +
|
| 145 | +1. **Before Submitting** |
| 146 | + - Ensure all tests pass |
| 147 | + - Update documentation if needed |
| 148 | + - Follow code style guidelines |
| 149 | + - Add comments for complex logic |
| 150 | +
|
| 151 | +2. **PR Description** |
| 152 | + - Clearly describe the changes |
| 153 | + - Reference related issues |
| 154 | + - Include screenshots for UI changes |
| 155 | + - List any breaking changes |
| 156 | +
|
| 157 | +3. **Review Process** |
| 158 | + - Address reviewer comments |
| 159 | + - Keep PR scope focused |
| 160 | + - Maintain clear communication |
| 161 | +
|
| 162 | +4. **After Merge** |
| 163 | + - Delete your feature branch |
| 164 | + - Update your local main branch |
| 165 | +
|
| 166 | +## Questions and Support |
| 167 | +
|
| 168 | +If you have questions or need help: |
| 169 | +- Open an issue for bugs |
| 170 | +- Use discussions for questions |
| 171 | +- Join our community channels |
| 172 | +
|
| 173 | +Thank you for contributing to Swoopin! Together, we're building a powerful social media management platform. |
0 commit comments