Backend complet pentru aplicaศia Travel AI, dezvoltat cu FastAPI ศi PostgreSQL, cu integrare Gemini AI pentru chat.
- Autentificare JWT - Sistem securizat de login/register
- Chat AI - Integrare cu Google Gemini AI pentru asistenศฤ turisticฤ
- Validฤri robuste - Format email, telefon romรขnesc, username alfanumeric
- Securitate - Hash parole cu bcrypt, token-uri cu expirare
- Base de date - PostgreSQL cu SQLAlchemy ORM
- API Documentation - Swagger UI automatฤ la
/docs
- Python 3.8+
- PostgreSQL 12+
- Google Gemini API Key
- pip (pentru instalarea dependenศelor)
git clone <repository-url>
cd travel-ai-bepython -m venv venv
source venv/bin/activate # Linux/Mac
# sau
venv\Scripts\activate # Windowspip install -r requirements.txt# Creeazฤ baza de date PostgreSQL
sudo -u postgres psql
CREATE DATABASE travel_ai_db;
CREATE USER travel_user WITH PASSWORD 'travel_password';
GRANT ALL PRIVILEGES ON DATABASE travel_ai_db TO travel_user;
\qEditeazฤ fiศierul .env:
DATABASE_URL=postgresql://travel_user:travel_password@localhost/travel_ai_db
SECRET_KEY=your-super-secret-key-change-in-production
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_HOURS=24
GEMINI_API_KEY=your-gemini-api-key-here
HOST=localhost
PORT=8000
DEBUG=True# Mod standard cu auto-reload
python start_server.py
# Mod curat fฤrฤ warning-uri GUI
python start_server_clean.py
# Sau direct cu uvicorn
uvicorn app.main:app --reload --host localhost --port 8000uvicorn app.main:app --host 0.0.0.0 --port 8000รnregistreazฤ un utilizator nou.
Request:
{
"full_name": "John Doe",
"email": "john@example.com",
"phone": "0712345678",
"username": "johndoe",
"age": 25,
"password": "securepassword",
"confirmPassword": "securepassword"
}Response:
{
"message": "User registered successfully",
"user": {
"id": 1,
"full_name": "John Doe",
"email": "john@example.com",
"phone": "0712345678",
"username": "johndoe",
"age": 25,
"is_first_login": true,
"created_at": "2024-01-01T12:00:00Z",
"updated_at": "2024-01-01T12:00:00Z"
},
"token": "eyJhbGciOiJIUzI1NiIs..."
}Autentificฤ un utilizator existent.
Request:
{
"identifier": "john@example.com",
"password": "securepassword"
}Response:
{
"message": "Login successful",
"user": {
"id": 1,
"full_name": "John Doe",
"email": "john@example.com",
"phone": "0712345678",
"username": "johndoe",
"age": 25,
"is_first_login": false,
"created_at": "2024-01-01T12:00:00Z",
"updated_at": "2024-01-01T12:00:00Z"
},
"token": "eyJhbGciOiJIUzI1NiIs..."
}Trimite un mesaj cฤtre asistentul AI pentru cฤlฤtorii.
Headers:
Authorization: Bearer <your-jwt-token>
Request:
{
"message": "Ce atracศii turistice รฎmi recomanzi รฎn Bucureศti?"
}Response:
{
"message": "รn Bucureศti รฎศi recomand sฤ vizitezi Palatul Parlamentului, Centrul Vechi, Parcul Herฤstrฤu, Muzeul Satului ศi Arcul de Triumf. Pentru o experienศฤ completฤ, nu rata nici Ateneul Romรขn ศi Calea Victoriei pentru shopping ศi cafenele."
}- Format valid conform RFC 5322
- Unic รฎn sistem
- Format romรขnesc:
07xxxxxxxx - Unic รฎn sistem
- Minim 3 caractere
- Doar caractere alfanumerice (a-Z, 0-9)
- Unic รฎn sistem
- Minim 6 caractere
- Hash-uitฤ cu bcrypt
- รntre 13 ศi 120 ani
- Minim 1 caracter, maxim 1000 caractere
travel-ai-be/
โโโ app/
โ โโโ __init__.py
โ โโโ main.py # Aplicaศia principalฤ FastAPI
โ โโโ database.py # Configurare PostgreSQL
โ โโโ config.py # Configurare environment
โ โโโ models/
โ โ โโโ __init__.py
โ โ โโโ user.py # Model SQLAlchemy User
โ โ โโโ chat.py # Model SQLAlchemy ChatMessage
โ โโโ schemas/
โ โ โโโ __init__.py
โ โ โโโ user.py # Scheme Pydantic User
โ โ โโโ chat.py # Scheme Pydantic Chat
โ โโโ routers/
โ โ โโโ __init__.py
โ โ โโโ auth.py # Rute autentificare
โ โ โโโ chat.py # Rute chat AI
โ โโโ utils/
โ โโโ __init__.py
โ โโโ auth.py # Utilitare JWT
โ โโโ password.py # Utilitare parole
โ โโโ chat.py # Integrare Gemini AI
โโโ requirements.txt # Dependenศe Python
โโโ start_server.py # Script pornire server (cu debug)
โโโ start_server_clean.py # Script pornire server (fฤrฤ warning-uri)
โโโ .env # Variabile de mediu
โโโ .gitignore # Fiศiere ignorate de Git
โโโ README.md # Documentaศie
Aplicaศia foloseศte Google Gemini AI pentru a oferi rฤspunsuri inteligente la รฎntrebฤrile despre cฤlฤtorii. Caracteristici:
- Context specializat - Asistentul este optimizat pentru sfaturi de cฤlฤtorie
- Rฤspunsuri concise - Limitate la 200 cuvinte pentru claritate
- Istoric conversaศii - Toate mesajele sunt salvate รฎn baza de date
- Rate limiting - Gestionarea automatฤ a limitelor API
- Obศine o cheie API de la Google AI Studio
- Adaugฤ cheia รฎn fiศierul
.env:GEMINI_API_KEY=your-api-key-here
- 15 cereri pe minut pentru modelul
gemini-1.5-flash - Aplicaศia gestioneazฤ automat erorile de rate limiting
- Pentru utilizare intensivฤ, considerฤ upgrade la plan plฤtit
Dupฤ pornirea serverului, acceseazฤ:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
Register:
curl -X POST "http://localhost:8000/api/auth/register" \
-H "Content-Type: application/json" \
-d '{
"full_name": "Test User",
"email": "test@example.com",
"phone": "0712345678",
"username": "testuser",
"age": 25,
"password": "testpass",
"confirmPassword": "testpass"
}'Login:
curl -X POST "http://localhost:8000/api/auth/login" \
-H "Content-Type: application/json" \
-d '{
"identifier": "test@example.com",
"password": "testpass"
}'Chat (necesitฤ token din login):
curl -X POST "http://localhost:8000/api/chat/message" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{
"message": "Ce รฎmi recomanzi sฤ vizitez รฎn Cluj-Napoca?"
}'- Verificฤ cฤ PostgreSQL ruleazฤ
- Verificฤ credenศialele din
.env - Verificฤ cฤ baza de date
travel_ai_dbexistฤ
- Asigurฤ-te cฤ environment-ul virtual este activat
- Ruleazฤ
pip install -r requirements.txt
- Verificฤ cฤ
GEMINI_API_KEYeste setat corect รฎn.env - Verificฤ cฤ nu ai depฤศit limita de 15 cereri pe minut
- Pentru erori persistente, verificฤ documentaศia oficialฤ
- Schimbฤ portul รฎn
.env:PORT=8001 - Sau opreศte procesul care foloseศte portul 8000
- Foloseศte
python start_server_clean.pypentru a evita warning-urile - Sau seteazฤ manual variabilele de mediu:
export EDITOR=true unset DISPLAY WAYLAND_DISPLAY
- FastAPI - Framework web modern ศi rapid
- SQLAlchemy - ORM pentru PostgreSQL
- Pydantic - Validare ศi serializare date
- Uvicorn - Server ASGI
- python-jose - JWT token handling
- passlib - Hash parole cu bcrypt
- google-generativeai - Client oficial Gemini AI
- psycopg2-binary - Driver PostgreSQL
- Fork repository-ul
- Creeazฤ o ramurฤ pentru feature:
git checkout -b feature/numele-feature - Commit modificฤrile:
git commit -m 'Adaugฤ feature nou' - Push la ramurฤ:
git push origin feature/numele-feature - Deschide un Pull Request
Acest proiect este licenศiat sub MIT License.
Pentru รฎntrebฤri sau suport, contacteazฤ echipa de dezvoltare.
An intelligent AI-powered travel planning platform designed for travel agencies and individual travelers
- Intelligent Conversations: Chat with Trajecta AI for personalized travel recommendations
- Real-time Responses: Get instant travel advice and planning assistance
- Context-Aware: AI remembers your preferences throughout the conversation
- Voice Calls: Start voice conversations with the AI assistant
- Real-time Speech: Speak naturally and get voice responses
- Visual Feedback: Live audio visualization and call status indicators
- Microphone Controls: Mute/unmute functionality with visual feedback
- Trip Library: Browse and manage your travel plans
- Status Tracking: Organize trips by status (Completed, Planned, Wishlist)
- Quick Access: Click any trip to get AI assistance for that destination
- Trip Statistics: Track your travel history and savings
- Secure Login: User authentication with session management
- User Profiles: Personalized experience with user data
- Protected Routes: Secure access to dashboard features
- Responsive Design: Works seamlessly on desktop and mobile
- Beautiful Interface: Modern gradient design with smooth animations
- Dark/Light Themes: Adaptive interface design
- Accessibility: Built with accessibility best practices
- Node.js (v18 or higher) - Install with nvm
- npm or yarn package manager
-
Clone the repository
git clone <YOUR_GIT_URL> cd travel-ai-fe
-
Install dependencies
npm install # or yarn install -
Start the development server
npm run dev # or yarn dev -
Open your browser Navigate to
http://localhost:5173to see the application
- React 18 - Modern React with hooks and concurrent features
- TypeScript - Type-safe development with enhanced IDE support
- Vite - Lightning-fast build tool and development server
- Tailwind CSS - Utility-first CSS framework
- shadcn/ui - High-quality, accessible React components
- Lucide React - Beautiful, customizable icons
- CSS Animations - Smooth transitions and micro-interactions
- Vapi AI - Voice AI integration for natural conversations
- Custom Chat API - AI-powered text conversations
- Real-time Audio - Live voice processing and feedback
- React Router - Client-side routing with protected routes
- React Hooks - Modern state management with useState, useEffect
- Context API - Global state for authentication
- ESLint - Code linting and quality assurance
- PostCSS - CSS processing and optimization
- TypeScript Config - Strict type checking configuration
src/
โโโ components/ # Reusable UI components
โ โโโ ui/ # shadcn/ui components
โ โโโ VoiceCall.tsx # Voice integration component
โโโ pages/ # Main application pages
โ โโโ Dashboard.tsx # Main dashboard with chat
โ โโโ Login.tsx # Authentication page
โ โโโ Index.tsx # Landing page
โโโ lib/ # Utility libraries
โ โโโ auth.ts # Authentication logic
โ โโโ vapi.ts # Voice AI integration
โ โโโ utils.ts # Helper functions
โโโ hooks/ # Custom React hooks
โโโ main.tsx # Application entry point
The platform integrates with Vapi AI to provide natural voice conversations:
- Real-time speech recognition
- AI voice responses
- Visual call interface with audio feedback
- Automatic call management
AI assistant helps with:
- Destination recommendations
- Budget planning
- Itinerary creation
- Local insights and tips
- Cultural information
- Intuitive Interface: Clean, modern design that's easy to navigate
- Responsive Layout: Optimized for all screen sizes
- Fast Performance: Optimized with Vite for quick loading
- Accessibility: WCAG compliant design
Create a .env file in the root directory:
VITE_API_URL=your_api_endpoint
VITE_VAPI_PUBLIC_KEY=your_vapi_public_keyThe application uses Vapi AI for voice integration. Make sure to:
- Configure your Vapi assistant ID
- Set up proper voice models
- Configure microphone permissions
npm run build
# or
yarn build- Open Lovable Project
- Click on Share โ Publish
- Your app will be deployed automatically
To connect a custom domain:
- Navigate to Project > Settings > Domains
- Click Connect Domain
- Follow the setup instructions
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.