Обновить README.md
This commit is contained in:
parent
2c407d9e8d
commit
5242a36bf3
88
README.md
88
README.md
@ -135,44 +135,7 @@ python -c "from bot import start_bot; import asyncio; asyncio.run(start_bot())"
|
|||||||
### Vacancies
|
### Vacancies
|
||||||
- `GET /vacancies` - List all 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
|
## Development
|
||||||
|
|
||||||
@ -192,57 +155,6 @@ async def example_endpoint(db: AsyncSession = Depends(get_db)):
|
|||||||
└── docker-compose.yml # Docker services
|
└── 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**
|
3. **Monitoring**
|
||||||
- Add logging
|
- Add logging
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user