This commit is contained in:
270
README.md
270
README.md
@@ -1,122 +1,212 @@
|
||||
# Discours Core
|
||||
# Discours.io Core
|
||||
|
||||
Core backend for Discours.io platform
|
||||
🚀 **Modern community platform** with GraphQL API, RBAC system, and comprehensive testing infrastructure.
|
||||
|
||||
## Requirements
|
||||
## 🎯 Features
|
||||
|
||||
- **🔐 Authentication**: JWT + OAuth (Google, GitHub, Facebook)
|
||||
- **🏘️ Communities**: Full community management with roles and permissions
|
||||
- **🔒 RBAC System**: Role-based access control with inheritance
|
||||
- **🌐 GraphQL API**: Modern API with comprehensive schema
|
||||
- **🧪 Testing**: Complete test suite with E2E automation
|
||||
- **🚀 CI/CD**: Automated testing and deployment pipeline
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
### Prerequisites
|
||||
- Python 3.11+
|
||||
- Node.js 18+
|
||||
- Redis
|
||||
- uv (Python package manager)
|
||||
|
||||
## Installation
|
||||
|
||||
### Install uv
|
||||
|
||||
```bash
|
||||
# macOS/Linux
|
||||
curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||
|
||||
# Windows
|
||||
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
|
||||
```
|
||||
|
||||
### Setup project
|
||||
|
||||
### Installation
|
||||
```bash
|
||||
# Clone repository
|
||||
git clone <repository-url>
|
||||
cd discours-core
|
||||
cd core
|
||||
|
||||
# Install dependencies
|
||||
uv sync --dev
|
||||
# Install Python dependencies
|
||||
uv sync --group dev
|
||||
|
||||
# Activate virtual environment
|
||||
source .venv/bin/activate # Linux/macOS
|
||||
# or
|
||||
.venv\Scripts\activate # Windows
|
||||
# Install Node.js dependencies
|
||||
cd panel
|
||||
npm ci
|
||||
cd ..
|
||||
|
||||
# Setup environment
|
||||
cp .env.example .env
|
||||
# Edit .env with your configuration
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
### Install dependencies
|
||||
|
||||
### Development
|
||||
```bash
|
||||
# Install all dependencies (including dev)
|
||||
uv sync --dev
|
||||
|
||||
# Install only production dependencies
|
||||
uv sync
|
||||
|
||||
# Install specific group
|
||||
uv sync --group test
|
||||
uv sync --group lint
|
||||
```
|
||||
|
||||
### Run tests
|
||||
|
||||
```bash
|
||||
# Run all tests
|
||||
uv run pytest
|
||||
|
||||
# Run specific test file
|
||||
uv run pytest tests/test_auth_fixes.py
|
||||
|
||||
# Run with coverage
|
||||
uv run pytest --cov=services,utils,orm,resolvers
|
||||
```
|
||||
|
||||
### Code quality
|
||||
|
||||
```bash
|
||||
# Run ruff linter
|
||||
uv run ruff check . --select I
|
||||
uv run ruff format --line-length=120
|
||||
|
||||
# Run mypy type checker
|
||||
uv run mypy .
|
||||
```
|
||||
|
||||
### Run application
|
||||
|
||||
```bash
|
||||
# Run main application
|
||||
uv run python main.py
|
||||
|
||||
# Run development server
|
||||
# Start backend server
|
||||
uv run python dev.py
|
||||
|
||||
# Start frontend (in another terminal)
|
||||
cd panel
|
||||
npm run dev
|
||||
```
|
||||
|
||||
## Project structure
|
||||
## 🧪 Testing
|
||||
|
||||
### Run All Tests
|
||||
```bash
|
||||
uv run pytest tests/ -v
|
||||
```
|
||||
|
||||
### Test Categories
|
||||
|
||||
#### Run only unit tests
|
||||
```bash
|
||||
uv run pytest tests/ -m "not e2e" -v
|
||||
```
|
||||
|
||||
#### Run only integration tests
|
||||
```bash
|
||||
uv run pytest tests/ -m "integration" -v
|
||||
```
|
||||
|
||||
#### Run only e2e tests
|
||||
```bash
|
||||
uv run pytest tests/ -m "e2e" -v
|
||||
```
|
||||
|
||||
#### Run browser tests
|
||||
```bash
|
||||
uv run pytest tests/ -m "browser" -v
|
||||
```
|
||||
|
||||
#### Run API tests
|
||||
```bash
|
||||
uv run pytest tests/ -m "api" -v
|
||||
```
|
||||
|
||||
#### Skip slow tests
|
||||
```bash
|
||||
uv run pytest tests/ -m "not slow" -v
|
||||
```
|
||||
|
||||
#### Run tests with specific markers
|
||||
```bash
|
||||
uv run pytest tests/ -m "db and not slow" -v
|
||||
```
|
||||
|
||||
### Test Markers
|
||||
- `unit` - Unit tests (fast)
|
||||
- `integration` - Integration tests
|
||||
- `e2e` - End-to-end tests
|
||||
- `browser` - Browser automation tests
|
||||
- `api` - API-based tests
|
||||
- `db` - Database tests
|
||||
- `redis` - Redis tests
|
||||
- `auth` - Authentication tests
|
||||
- `slow` - Slow tests (can be skipped)
|
||||
|
||||
### E2E Testing
|
||||
E2E tests automatically start backend and frontend servers:
|
||||
- Backend: `http://localhost:8000`
|
||||
- Frontend: `http://localhost:3000`
|
||||
|
||||
## 🚀 CI/CD Pipeline
|
||||
|
||||
### GitHub Actions Workflow
|
||||
The project includes a comprehensive CI/CD pipeline that:
|
||||
|
||||
1. **🧪 Testing Phase**
|
||||
- Matrix testing across Python 3.11, 3.12, 3.13
|
||||
- Unit, integration, and E2E tests
|
||||
- Code coverage reporting
|
||||
- Linting and type checking
|
||||
|
||||
2. **🚀 Deployment Phase**
|
||||
- **Staging**: Automatic deployment on `dev` branch
|
||||
- **Production**: Automatic deployment on `main` branch
|
||||
- Dokku integration for seamless deployments
|
||||
|
||||
### Local CI Testing
|
||||
Test the CI pipeline locally:
|
||||
|
||||
```bash
|
||||
# Run local CI simulation
|
||||
chmod +x scripts/test-ci-local.sh
|
||||
./scripts/test-ci-local.sh
|
||||
```
|
||||
|
||||
### CI Server Management
|
||||
The `scripts/ci-server.py` script manages servers for CI:
|
||||
|
||||
```bash
|
||||
# Start servers in CI mode
|
||||
CI_MODE=true python3 scripts/ci-server.py
|
||||
```
|
||||
|
||||
## 📊 Project Structure
|
||||
|
||||
```
|
||||
discours-core/
|
||||
├── auth/ # Authentication and authorization
|
||||
├── cache/ # Caching system
|
||||
core/
|
||||
├── auth/ # Authentication system
|
||||
├── orm/ # Database models
|
||||
├── resolvers/ # GraphQL resolvers
|
||||
├── services/ # Business logic services
|
||||
├── utils/ # Utility functions
|
||||
├── schema/ # GraphQL schema
|
||||
├── services/ # Business logic
|
||||
├── panel/ # Frontend (SolidJS)
|
||||
├── tests/ # Test suite
|
||||
├── scripts/ # CI/CD scripts
|
||||
└── docs/ # Documentation
|
||||
```
|
||||
|
||||
## Configuration
|
||||
## 🔧 Configuration
|
||||
|
||||
The project uses `pyproject.toml` for configuration:
|
||||
### Environment Variables
|
||||
- `DATABASE_URL` - Database connection string
|
||||
- `REDIS_URL` - Redis connection string
|
||||
- `JWT_SECRET` - JWT signing secret
|
||||
- `OAUTH_*` - OAuth provider credentials
|
||||
|
||||
- **Dependencies**: Defined in `[project.dependencies]` and `[project.optional-dependencies]`
|
||||
- **Build system**: Uses `hatchling` for building packages
|
||||
- **Code quality**: Configured with `ruff` and `mypy`
|
||||
- **Testing**: Configured with `pytest`
|
||||
### Database
|
||||
- **Development**: SQLite (default)
|
||||
- **Production**: PostgreSQL
|
||||
- **Testing**: In-memory SQLite
|
||||
|
||||
## CI/CD
|
||||
## 📚 Documentation
|
||||
|
||||
The project includes GitHub Actions workflows for:
|
||||
- [API Documentation](docs/api.md)
|
||||
- [Authentication](docs/auth.md)
|
||||
- [RBAC System](docs/rbac-system.md)
|
||||
- [Testing Guide](docs/testing.md)
|
||||
- [Deployment](docs/deployment.md)
|
||||
|
||||
- Automated testing
|
||||
- Code quality checks
|
||||
- Deployment to staging and production servers
|
||||
## 🤝 Contributing
|
||||
|
||||
## License
|
||||
1. Fork the repository
|
||||
2. Create a feature branch
|
||||
3. Make your changes
|
||||
4. Add tests for new functionality
|
||||
5. Ensure all tests pass
|
||||
6. Submit a pull request
|
||||
|
||||
MIT License
|
||||
### Development Workflow
|
||||
```bash
|
||||
# Create feature branch
|
||||
git checkout -b feature/your-feature
|
||||
|
||||
# Make changes and test
|
||||
uv run pytest tests/ -v
|
||||
|
||||
# Commit changes
|
||||
git commit -m "feat: add your feature"
|
||||
|
||||
# Push and create PR
|
||||
git push origin feature/your-feature
|
||||
```
|
||||
|
||||
## 📈 Status
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
## 📄 License
|
||||
|
||||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
||||
|
||||
Reference in New Issue
Block a user