Go to file
2026-01-13 13:41:29 +01:00
claude Initial commit 2026-01-13 15:38:27 +03:00
database Initial commit 2026-01-13 15:38:27 +03:00
logger Initial commit 2026-01-13 15:38:27 +03:00
routers Initial commit 2026-01-13 15:38:27 +03:00
tests Initial commit 2026-01-13 15:38:27 +03:00
.dockerignore Initial commit 2026-01-13 15:38:27 +03:00
.gitignore Initial commit 2026-01-13 15:38:27 +03:00
app.py Initial commit 2026-01-13 15:38:27 +03:00
authorizer.py Initial commit 2026-01-13 15:38:27 +03:00
bot.py Initial commit 2026-01-13 15:38:27 +03:00
check_db.sh Initial commit 2026-01-13 15:38:27 +03:00
config.py Initial commit 2026-01-13 15:38:27 +03:00
docker-compose.yml Initial commit 2026-01-13 15:38:27 +03:00
init_db.py Initial commit 2026-01-13 15:38:27 +03:00
openrouter_client.py Initial commit 2026-01-13 15:38:27 +03:00
QUICK_START.md Initial commit 2026-01-13 15:38:27 +03:00
README.md Обновить README.md 2026-01-13 13:41:08 +01:00
requirements.txt Initial commit 2026-01-13 15:38:27 +03:00

RAG AI Assistant

A FastAPI application with Telegram bot integration for user authentication and profile management.

Features

  • User Authentication via Telegram Bot
  • Profile Management with CV upload to MinIO
  • PostgreSQL Database with async SQLAlchemy ORM
  • RESTful API endpoints for profiles and vacancies

Architecture

  • Backend: FastAPI (Python)
  • Database: PostgreSQL with async support (asyncpg)
  • File Storage: MinIO (S3-compatible)
  • Bot: Telegram Bot (aiogram 3.x)
  • ORM: SQLAlchemy with async sessions

Database Schema

Users Table

  • id - Auto-increment primary key
  • telegram_id - Unique Telegram user ID (indexed)
  • token - Unique auth token (indexed)
  • username - Telegram username
  • status - Auth status ('pending' or 'success')
  • created_at - Timestamp
  • updated_at - Timestamp

Profiles Table

  • id - Auto-increment primary key
  • email - Unique email (indexed)
  • name, position, competencies, experience, skills
  • country, languages, employment_format, rate, relocation
  • cv_url - Link to uploaded CV in MinIO
  • created_at - Timestamp
  • updated_at - Timestamp

Setup Instructions

1. Prerequisites

  • Python 3.10+
  • PostgreSQL 14+
  • Docker (for MinIO)

2. Install Dependencies

# Create virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

3. Configure Environment

Copy and configure your .env file:

# Bot Configuration
BOT_API_KEY=your_telegram_bot_token
HOST=localhost
PORT=8000

# PostgreSQL Configuration
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=rag_ai_assistant
POSTGRES_PORT=5432
POSTGRES_HOST=localhost

# MinIO Configuration
MINIO_ROOT_USER=minioadmin
MINIO_ROOT_PASSWORD=minioadmin
MINIO_ENDPOINT=localhost:9000
MINIO_PORT=9000
MINIO_CONSOLE_PORT=9001
MINIO_ACCESS_KEY=minioadmin
MINIO_SECRET_KEY=minioadmin
MINIO_BUCKET=resumes

4. Start Services

# Start PostgreSQL and MinIO using Docker
docker-compose up -d

# Verify services are running
docker ps

5. Initialize Database

# Run database initialization script
python init_db.py

# Or manually create tables
python -c "from database.database import init_db; import asyncio; asyncio.run(init_db())"

6. Run Application

Option A: Run bot and API together

python bot.py

Option B: Run separately

# Terminal 1 - API
uvicorn app:app --reload --host localhost --port 8000

# Terminal 2 - Bot
python -c "from bot import start_bot; import asyncio; asyncio.run(start_bot())"

API Endpoints

Authentication

  • GET /login - Generate auth token and Telegram bot URL
  • GET /check-auth/{token} - Check authentication status
  • GET /database/tokens - List all tokens (debug)

Profiles

  • POST /profile - Create/update profile with CV upload
  • GET /profile/{email} - Get profile by email
  • GET /profile/cv/{file_id} - Download CV file

Vacancies

  • GET /vacancies - List all vacancies

Development

Project Structure

.
├── app.py                  # FastAPI application
├── bot.py                  # Telegram bot
├── config.py               # Configuration
├── init_db.py              # Database initialization script
├── requirements.txt        # Python dependencies
├── .env                    # Environment variables
├── database/
│   ├── database.py         # Database models and session management
│   └── minio-processor.py  # MinIO utilities
├── tests/                  # Test files
└── docker-compose.yml      # Docker services
  1. Monitoring
    • Add logging
    • Set up error tracking (Sentry)
    • Monitor database performance

License

MIT