Development Environment
This guide provides information for developers who want to contribute to the OnlyAutomator project or customize their own instance.System Requirements
- Node.js: v18.x or later
- npm: v9.x or later
- PostgreSQL: v14.x or later
- Git: v2.x or later
Local Development Setup
- Clone the repository:
- Install dependencies:
- Set up environment variables:
.env.local
to include your development keys and settings.
- Run the development server:
Project Architecture
OnlyAutomator follows a modular architecture pattern to ensure clean separation of concerns and maintainability.Key Directories
/app
- Next.js app router pages and layouts/components
- Reusable UI components/lib
- Utility functions and shared code/api
- API route handlers/services
- Business logic services/types
- TypeScript type definitions/prisma
- Database schema and migrations/public
- Static assets
Component Structure
Components follow a consistent structure to ensure maintainability:Development Workflow
Git Workflow
We follow a feature branch workflow:- Create a new branch for each feature or fix:
- Make changes and commit them:
- Push your branch:
- Create a Pull Request on GitHub for review.
Continuous Integration
Our CI pipeline runs on each PR and includes:- Linting
- Type checking
- Unit tests
- Integration tests
- Build verification
Data Models
Core Data Models
OnlyAutomator relies on several core data models that drive the application functionality:API Structure
The API follows RESTful conventions and is organized by resource:Authentication APIs
POST /api/auth/login
- Log in a userPOST /api/auth/logout
- Log out a userPOST /api/auth/refresh
- Refresh authentication tokenPOST /api/auth/register
- Register a new user
User APIs
GET /api/users/me
- Get current userPATCH /api/users/me
- Update current userGET /api/users/me/accounts
- Get user accounts
Account APIs
GET /api/accounts
- List accountsPOST /api/accounts
- Create accountGET /api/accounts/:id
- Get accountPATCH /api/accounts/:id
- Update accountDELETE /api/accounts/:id
- Delete accountGET /api/accounts/:id/fans
- Get account fans
Fans APIs
GET /api/fans
- List fansGET /api/fans/:id
- Get fanPATCH /api/fans/:id
- Update fanGET /api/fans/:id/stats
- Get fan statistics
Subscription APIs
GET /api/subscriptions
- List subscriptionsPOST /api/subscriptions
- Create subscriptionGET /api/subscriptions/:id
- Get subscriptionPATCH /api/subscriptions/:id
- Update subscriptionDELETE /api/subscriptions/:id
- Cancel subscription
Authentication
We use JWT-based authentication with Supabase:State Management
We use a combination of approaches for state management:- Server Components - For server-rendered data
- React Context - For shared state across components
- SWR/React Query - For data fetching and caching
- React Hook Form - For form state management
- Local State - For component-specific state
Example SWR Usage
Testing Strategy
We use a comprehensive testing strategy to ensure code quality:Unit Tests
We use Jest for unit testing components and functions:Integration Tests
We use Cypress for integration tests:Performance Considerations
Performance Optimizations
We focus on several key areas for performance:- Code Splitting - Using dynamic imports for route-based code splitting
- Image Optimization - Using Next.js Image component for optimized images
- Server Components - Leveraging React Server Components for reduced client JS
- Lazy Loading - Implementing lazy loading for below-the-fold content
- Memoization - Using React.memo and useMemo to prevent unnecessary re-renders
Example Performance Optimization
Deployment
Deployment Process
We use Vercel for deployments with the following pipeline:Contabo Microservice Deployment
For the specialized microservice backend, we use a Contabo VPS with GitHub Actions for CI/CD:GitHub Actions Workflow
The deployment is automated through a GitHub Actions workflow defined in.github/workflows/deploy.yml
:
Required GitHub Secrets
The following secrets need to be configured in your GitHub repository:SSH_HOST
- Contabo VPS hostname or IP addressSSH_USERNAME
- SSH username for the Contabo serverSSH_PRIVATE_KEY
- Private SSH key for authenticationLOGIN_TOKEN
- GitHub personal access token for repository accessSUPABASE_URL
- Supabase project URLSUPABASE_ANON_KEY
- Supabase anonymous keySUPABASE_SERVICE_ROLE_KEY
- Supabase service role keyNEXT_PUBLIC_SITE_URL
- Public URL of the web application
Process Manager Configuration
The microservice uses PM2 for process management, with its configuration inecosystem.config.js
:
Manual Deployment (if needed)
In case you need to deploy manually:- SSH into the Contabo server:
- Navigate to the application directory:
- Pull the latest changes:
- Install dependencies and build:
- Restart the PM2 processes:
Environment Configuration
Each environment has its own configuration:Customization
White Labeling
OnlyAutomator supports white labeling through configuration:Theme Customization
The UI theme can be customized through Tailwind:API Extensions
Creating Custom API Routes
To extend the API with custom functionality:- Create a new API route file:
- Access the API from your components:
Contributing Guide
Contribution Process
- Fork the Repository - Create your own fork of the code
- Create Feature Branch - Make your changes in a new branch
- Follow Style Guide - Ensure code matches our style guidelines
- Write Tests - Add tests for your changes
- Run CI Checks Locally - Ensure all checks pass before submitting
- Create Pull Request - Submit a PR with a clear description
- Code Review - Address feedback from maintainers
- Merge - Once approved, your PR will be merged