Contributing to Flexus
Thank you for your interest in contributing to Flexus! This guide will help you get started with the codebase and make your first contribution.
Project Structure
Flexus is split across multiple repositories:
| Repository | Purpose | Language |
|---|---|---|
| flexus | Core platform (backend + frontend) | Python, TypeScript |
| flexus-client-kit | Bot SDK and example bots | Python |
| flexus-deployment | Kubernetes manifests | YAML |
| flexus-docs | Documentation (this site) | MDX |
Your First Contribution
New to Flexus? Follow this step-by-step guide:
-
Fork the Repository
Go to the repository on GitHub and click the “Fork” button in the top right.
-
Clone Your Fork
Terminal window git clone https://github.com/YOUR_USERNAME/flexus.gitcd flexus -
Add Upstream Remote
Terminal window git remote add upstream https://github.com/smallcloudai/flexus.git -
Create a Branch
Terminal window git checkout -b feature/my-awesome-feature -
Make Your Changes
Follow the code style guidelines below. Keep changes focused and atomic.
-
Run Tests
Terminal window python -m pytest # Backend testsnpm run test # Frontend tests (in flexus_frontend/) -
Commit Your Changes
Terminal window git add .git commit -m "feat: add awesome feature" -
Push and Create PR
Terminal window git push origin feature/my-awesome-featureThen go to GitHub and create a Pull Request.
Look for issues labeled good first issue — these are specifically chosen for newcomers and have clear scope and guidance.
Development Setup
Prerequisites
- Python 3.10+ — For backend and bots
- Node.js 18+ — For frontend
- Docker & Docker Compose — For local services (Postgres, Redis)
- Git — For version control
Quick Commands
We recommend creating a Makefile or shell aliases for common operations:
# Suggested workflow commands
# Setup everythingmake setup# Equivalent to:# docker-compose -f docker-compose.dev.yml up -d# pip install -e ".[dev]"# python -m prisma migrate deploy
# Run backendmake dev# Equivalent to: python -m flexus_backend.flexus_v1_server
# Run frontendmake frontend# Equivalent to: cd flexus_frontend && npm run dev
# Run all testsmake test# Equivalent to: python -m pytest && cd flexus_frontend && npm run test
# Lint codemake lint# Equivalent to: ruff check . && mypy . && cd flexus_frontend && npm run lintClone Repositories
# Create workspacemkdir flexus-dev && cd flexus-dev
# Clone repositoriesgit clone https://github.com/smallcloudai/flexus.gitgit clone https://github.com/smallcloudai/flexus-client-kit.gitBackend Setup
cd flexus
# Create virtual environmentpython -m venv venvsource venv/bin/activate # or venv\Scripts\activate on Windows
# Install dependenciespip install -e ".[dev]"
# Start local services (Postgres, Redis)docker-compose -f docker-compose.dev.yml up -d
# Run migrationspython -m prisma migrate deploy
# Start backendpython -m flexus_backend.flexus_v1_serverFrontend Setup
cd flexus/flexus_frontend
# Install dependenciesnpm install
# Start dev servernpm run devClient Kit Setup
cd flexus-client-kit
# Install in dev modepip install -e ".[dev]"
# Set environmentexport FLEXUS_API_BASEURL=http://localhost:8000/export FLEXUS_API_KEY=your-dev-api-keyEnvironment Variables
Backend (flexus)
| Variable | Required | Default | Description |
|---|---|---|---|
DATABASE_URL | Yes | - | PostgreSQL connection string |
REDIS_URL | Yes | - | Redis connection string |
SESSION_SECRET | Yes | - | Secret key for session encryption |
LITELLM_API_KEY | Yes | - | API key for LLM provider (OpenAI, Anthropic, etc.) |
LITELLM_MODEL | No | gpt-4o | Default LLM model to use |
STORAGE_TYPE | No | local | File storage type (local, s3) |
STORAGE_PATH | No | /data/uploads | Path for local file storage |
Client Kit (bots)
| Variable | Required | Default | Description |
|---|---|---|---|
FLEXUS_API_BASEURL | Yes | - | Backend URL (e.g., http://localhost:8000/) |
FLEXUS_API_KEY | Yes | - | API key for authentication |
FLEXUS_WORKSPACE | No | - | Default workspace ID |
Copy .env.example to .env and fill in your values.
Pre-commit Hooks
We use pre-commit hooks to ensure code quality before commits.
Setup
# Install pre-commitpip install pre-commit
# Install hookspre-commit install
# Run manually on all filespre-commit run --all-filesWhat Gets Checked
| Check | Tool | Purpose |
|---|---|---|
| Python linting | ruff | Code style and errors |
| Python types | mypy | Type checking |
| TypeScript linting | eslint | Code style |
| Formatting | prettier | Consistent formatting |
| Secrets | detect-secrets | Prevent credential leaks |
| Large files | built-in | Prevent accidental commits |
Code Style
Python
We don’t follow PEP8 strictly. Key rules:
# Trailing commas and indent independent of bracketsdef my_func( x: int, y: int,) -> int: return x + y
my_func( 5, 6,)Naming:
- Use prefixed names for data fields:
fgroup_name,ktask_id,ft_title - Local variables can be short:
x,i,args - No generic names like
data,result,itemfor important things
Imports:
- Prefer
import xxxoverfrom xxx import f - Exception: very standard imports like
from typing import Any - Never import inside functions
Comments:
- No docstrings unless explaining something clever
- Comment tricks, hacks, and non-obvious decisions
- Mark future improvements with
XXX
Error Handling:
- Never
except Exceptionwithoutexc_info=elogging - Catch specific exceptions only
- External API errors use
logger.info, notlogger.error
TypeScript (Frontend)
Naming:
snake_casefor backend fields:ws_id,fgroup_idcamelCasefor TypeScript variableskebab-casefor URLs and files
Error Handling:
- Never use
?.to silently ignore errors - Always log to console AND show error bubble
- No “best behavior” — fail visibly
// Badif (result.data?.field) { ... }
// Goodif (!result.data || !result.data.field) { console.error('COMPONENT_NAME FAILS:', result); errorBubble.setError(result.error); return;}GraphQL:
const { execute: meaningfulNameExecute } = useMutation(` mutation WhoCallsAndWhy($input: FType!) { real_name(input: $input) { output_field } }`);Making Changes
Branch Naming
feature/short-descriptionfix/issue-number-descriptiondocs/what-you-documentedCommit Messages
We use Conventional Commits:
type(scope): short description
Longer explanation if needed.
Fixes #123Types:
feat— New featurefix— Bug fixdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testschore— Maintenance tasks
Testing
# Python testspython -m pytest
# Frontend testsnpm run test
# Bot syntax checkpython -m py_compile my_bot.py my_prompts.py my_install.pyPull Requests
- Fork the repository
- Create branch from
main - Make changes following style guide
- Test your changes
- Submit PR with clear description
PRs are automatically checked for:
- Tests passing
- Linting passing
- No secrets committed
Troubleshooting
Docker Issues
Ports already in use:
# Check what's using port 5432 (Postgres)lsof -i :5432# Kill the process or use different port in docker-compose.ymlContainers won’t start:
# Check logsdocker-compose -f docker-compose.dev.yml logs
# Reset and rebuilddocker-compose -f docker-compose.dev.yml down -vdocker-compose -f docker-compose.dev.yml up -d --buildDatabase Issues
Prisma migrate fails:
# Reset database (WARNING: deletes all data)python -m prisma migrate reset
# Generate Prisma clientpython -m prisma generatepgvector extension missing:
-- Connect to Postgres and run:CREATE EXTENSION IF NOT EXISTS vector;Frontend Issues
npm install fails:
# Clear cache and reinstallrm -rf node_modules package-lock.jsonnpm installWrong Node version:
# Check version (need 18+)node --version
# Use nvm to switchnvm install 18nvm use 18Bot Issues
Bot won’t connect:
- Check
FLEXUS_API_BASEURLis correct (include trailing slash) - Verify API key is valid
- Ensure backend is running
LLM rate limits:
- Check your API key quota
- Set
LITELLM_MODELto a less restricted model - Add retry logic with backoff
Common Errors
| Error | Cause | Solution |
|---|---|---|
Connection refused | Service not running | Start Docker services |
Invalid API key | Wrong or missing key | Check .env file |
Module not found | Dependencies missing | Run pip install -e ".[dev]" |
CORS error | Frontend URL mismatch | Check ALLOWED_ORIGINS in backend |
Areas to Contribute
Good First Issues
Look for issues labeled good first issue:
- Documentation improvements
- Bug fixes with clear reproduction
- Small feature additions
Bot Development
Create new bots for the marketplace:
- Follow patterns in
flexus_simple_bots/ - Use
frog/as a reference - Include tests and documentation
Integrations
Add new integrations to client kit:
- New messenger platforms
- External services
- API connectors
Frontend Improvements
- UI/UX enhancements
- Accessibility improvements
- Mobile optimization
Documentation
- Fix typos and errors
- Add examples
- Improve explanations
- Translate to other languages
Component Documentation
Each component has specific patterns and guidelines:
| Component | Documentation | Key Files |
|---|---|---|
| Backend | Backend Architecture | flexus_backend/flexus_v1/, services/ |
| Frontend | Frontend Guide | flexus_frontend/components/, stores/ |
| Client Kit | Client Kit Reference | ckit_*.py, integrations/ |
| Bots | Bot Patterns | flexus_simple_bots/ |
Release Process
Versioning
We follow Semantic Versioning:
- MAJOR (1.0.0 -> 2.0.0): Breaking changes
- MINOR (1.0.0 -> 1.1.0): New features, backward compatible
- PATCH (1.0.0 -> 1.0.1): Bug fixes, backward compatible
Release Steps
- Create release branch:
release/v1.2.0 - Update CHANGELOG.md: Document all changes
- Bump version: In
pyproject.toml,package.json - Create PR: Merge to
main - Tag release:
git tag v1.2.0 - GitHub Release: Create with release notes
- Publish artifacts:
- Docker images to registry
- Python packages to PyPI (client-kit)
Changelog Format
## [1.2.0] - 2024-01-15
### Added- New feature X (#123)
### Changed- Updated behavior of Y (#124)
### Fixed- Bug in Z (#125)
### Deprecated- Old API endpoint (use new one)Security
Reporting Vulnerabilities
Email security@flexus.team for security issues. Do not open public issues.
Security Guidelines
- Never commit secrets or credentials
- Validate all user input
- Check permissions in handlers
- Use parameterized queries
Getting Help
- GitHub Discussions — Questions and ideas
- Discord — Real-time chat
- Issues — Bug reports and feature requests
Use issue templates when creating issues — they help us understand and address your needs faster.
Code of Conduct
We follow the Contributor Covenant. Be respectful, inclusive, and constructive.
License
Flexus is MIT licensed. Your contributions will be under the same license.
Every contribution, whether code, documentation, or feedback, helps make Flexus better. We appreciate your help!