diff --git a/README.md b/README.md index 0c98afc..f1e4075 100644 --- a/README.md +++ b/README.md @@ -134,45 +134,8 @@ python -c "from bot import start_bot; import asyncio; asyncio.run(start_bot())" ### Vacancies - `GET /vacancies` - List all vacancies - -## Usage Flow - -1. **User visits website** → Calls `GET /login` -2. **Gets Telegram bot link** with unique token -3. **User clicks link** → Opens Telegram bot -4. **User sends `/start {token}`** to bot -5. **Bot validates token** → Updates status to "success" in DB -6. **Website polls** `GET /check-auth/{token}` → User authenticated! - -## Database Operations - -### Manual Database Operations - -```python -# Test database connection -python database/database.py - -# Initialize database -python init_db.py - -# Drop and recreate tables (⚠️ DELETES ALL DATA) -python init_db.py # Choose option 2 -``` - -### Using Database Sessions in Code - -```python -from database.database import get_db, User -from sqlalchemy import select -from fastapi import Depends - -@app.get("/example") -async def example_endpoint(db: AsyncSession = Depends(get_db)): - # Query users - result = await db.execute(select(User).where(User.status == "success")) - users = result.scalars().all() - return users -``` + + ## Development @@ -192,57 +155,6 @@ async def example_endpoint(db: AsyncSession = Depends(get_db)): └── docker-compose.yml # Docker services ``` -### Testing - -```bash -# Install test dependencies -pip install pytest pytest-asyncio httpx - -# Run tests -pytest tests/ -v - -# Test specific file -pytest tests/test_bot.py -v -``` - -## Troubleshooting - -### PostgreSQL Connection Issues -```bash -# Check if PostgreSQL is running -docker ps | grep postgres - -# Check connection -psql -h localhost -U postgres -d rag_ai_assistant -``` - -### MinIO Connection Issues -```bash -# Check if MinIO is running -docker ps | grep minio - -# Access MinIO console -open http://localhost:9001 -``` - -### Database Migration -```bash -# If you need to reset the database -python init_db.py # Choose option 2 (reset) -``` - -## Production Considerations - -1. **Security** - - Change default passwords in `.env` - - Use environment-specific configurations - - Enable SSL/TLS for PostgreSQL - - Implement rate limiting - -2. **Performance** - - Adjust SQLAlchemy pool settings - - Add database indexes as needed - - Implement caching (Redis) 3. **Monitoring** - Add logging