Skip to content

AdrianBobish/trajecta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Trajecta Backend

Backend complet pentru aplicaศ›ia Travel AI, dezvoltat cu FastAPI ศ™i PostgreSQL, cu integrare Gemini AI pentru chat.

๐Ÿš€ Caracteristici

  • 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

๐Ÿ“‹ Cerinศ›e

  • Python 3.8+
  • PostgreSQL 12+
  • Google Gemini API Key
  • pip (pentru instalarea dependenศ›elor)

๐Ÿ› ๏ธ Instalare

1. Cloneazฤƒ repository-ul

git clone <repository-url>
cd travel-ai-be

2. Creeazฤƒ un environment virtual

python -m venv venv
source venv/bin/activate  # Linux/Mac
# sau
venv\Scripts\activate  # Windows

3. Instaleazฤƒ dependenศ›ele

pip install -r requirements.txt

4. Configureazฤƒ baza de date

# 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;
\q

5. Configureazฤƒ variabilele de mediu

Editeazฤƒ 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

๐Ÿƒโ€โ™‚๏ธ Rulare

Dezvoltare

# 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 8000

Producศ›ie

uvicorn app.main:app --host 0.0.0.0 --port 8000

๐Ÿ“– API Endpoints

Autentificare

POST /api/auth/register

รŽ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..."
}

POST /api/auth/login

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..."
}

Chat AI

POST /api/chat/message

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."
}

๐Ÿ”’ Validฤƒri

Email

  • Format valid conform RFC 5322
  • Unic รฎn sistem

Telefon

  • Format romรขnesc: 07xxxxxxxx
  • Unic รฎn sistem

Username

  • Minim 3 caractere
  • Doar caractere alfanumerice (a-Z, 0-9)
  • Unic รฎn sistem

Parolฤƒ

  • Minim 6 caractere
  • Hash-uitฤƒ cu bcrypt

Vรขrstฤƒ

  • รŽntre 13 ศ™i 120 ani

Mesaje Chat

  • Minim 1 caracter, maxim 1000 caractere

๐Ÿ—‚๏ธ Structura Proiectului

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

๐Ÿค– Integrare Gemini AI

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

Configurare Gemini API

  1. Obศ›ine o cheie API de la Google AI Studio
  2. Adaugฤƒ cheia รฎn fiศ™ierul .env:
    GEMINI_API_KEY=your-api-key-here

Limite API Gemini (Free Tier)

  • 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

๐Ÿงช Testare

Acces la documentaศ›ia API

Dupฤƒ pornirea serverului, acceseazฤƒ:

Test rapid cu curl

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?"
  }'

๐Ÿ”ง Troubleshooting

Eroare conexiune bazฤƒ de date

  • Verificฤƒ cฤƒ PostgreSQL ruleazฤƒ
  • Verificฤƒ credenศ›ialele din .env
  • Verificฤƒ cฤƒ baza de date travel_ai_db existฤƒ

Eroare import module

  • Asigurฤƒ-te cฤƒ environment-ul virtual este activat
  • Ruleazฤƒ pip install -r requirements.txt

Eroare Gemini API

  • Verificฤƒ cฤƒ GEMINI_API_KEY este setat corect รฎn .env
  • Verificฤƒ cฤƒ nu ai depฤƒศ™it limita de 15 cereri pe minut
  • Pentru erori persistente, verificฤƒ documentaศ›ia oficialฤƒ

Port deja ocupat

  • Schimbฤƒ portul รฎn .env: PORT=8001
  • Sau opreศ™te procesul care foloseศ™te portul 8000

Warning-uri GUI (Chromium/Electron)

  • Foloseศ™te python start_server_clean.py pentru a evita warning-urile
  • Sau seteazฤƒ manual variabilele de mediu:
    export EDITOR=true
    unset DISPLAY WAYLAND_DISPLAY

๐Ÿ“Š Dependenศ›e

Core

  • FastAPI - Framework web modern ศ™i rapid
  • SQLAlchemy - ORM pentru PostgreSQL
  • Pydantic - Validare ศ™i serializare date
  • Uvicorn - Server ASGI

Securitate

  • python-jose - JWT token handling
  • passlib - Hash parole cu bcrypt

AI Integration

  • google-generativeai - Client oficial Gemini AI

Database

  • psycopg2-binary - Driver PostgreSQL

๐Ÿค Contribuศ›ie

  1. Fork repository-ul
  2. Creeazฤƒ o ramurฤƒ pentru feature: git checkout -b feature/numele-feature
  3. Commit modificฤƒrile: git commit -m 'Adaugฤƒ feature nou'
  4. Push la ramurฤƒ: git push origin feature/numele-feature
  5. Deschide un Pull Request

๐Ÿ“„ Licenศ›ฤƒ

Acest proiect este licenศ›iat sub MIT License.

๐Ÿ“ž Contact

Pentru รฎntrebฤƒri sau suport, contacteazฤƒ echipa de dezvoltare.

Trajecta Frontent

Trajecta Logo

An intelligent AI-powered travel planning platform designed for travel agencies and individual travelers

React TypeScript Vite Tailwind CSS

๐ŸŒŸ Features

๐Ÿค– AI-Powered Chat Assistant

  • 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 Integration

  • 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 Management

  • 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

๐Ÿ” Authentication System

  • Secure Login: User authentication with session management
  • User Profiles: Personalized experience with user data
  • Protected Routes: Secure access to dashboard features

๐ŸŽจ Modern UI/UX

  • 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

๐Ÿš€ Getting Started

Prerequisites

Installation

  1. Clone the repository

    git clone <YOUR_GIT_URL>
    cd travel-ai-fe
  2. Install dependencies

    npm install
    # or
    yarn install
  3. Start the development server

    npm run dev
    # or
    yarn dev
  4. Open your browser Navigate to http://localhost:5173 to see the application

๐Ÿ› ๏ธ Technology Stack

Frontend Framework

  • 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

Styling & UI

  • 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

AI & Voice Integration

  • Vapi AI - Voice AI integration for natural conversations
  • Custom Chat API - AI-powered text conversations
  • Real-time Audio - Live voice processing and feedback

State Management & Routing

  • React Router - Client-side routing with protected routes
  • React Hooks - Modern state management with useState, useEffect
  • Context API - Global state for authentication

Development Tools

  • ESLint - Code linting and quality assurance
  • PostCSS - CSS processing and optimization
  • TypeScript Config - Strict type checking configuration

๐Ÿ“ Project Structure

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

๐ŸŽฏ Key Features Explained

Voice AI Integration

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

Trip Planning Intelligence

AI assistant helps with:

  • Destination recommendations
  • Budget planning
  • Itinerary creation
  • Local insights and tips
  • Cultural information

User Experience

  • 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

๐Ÿ”ง Configuration

Environment Variables

Create a .env file in the root directory:

VITE_API_URL=your_api_endpoint
VITE_VAPI_PUBLIC_KEY=your_vapi_public_key

Voice AI Setup

The application uses Vapi AI for voice integration. Make sure to:

  1. Configure your Vapi assistant ID
  2. Set up proper voice models
  3. Configure microphone permissions

๐Ÿš€ Deployment

Build for Production

npm run build
# or
yarn build

Deploy to Lovable

  1. Open Lovable Project
  2. Click on Share โ†’ Publish
  3. Your app will be deployed automatically

Custom Domain

To connect a custom domain:

  1. Navigate to Project > Settings > Domains
  2. Click Connect Domain
  3. Follow the setup instructions

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

About

TRAJECTA is an innovative travel platform featuring a fine-tuned AI agent for personalised trip planning. Showcased at Cluj Hackathon 2024, it highlights natural vocal interaction between clients and agents, as well as seamless communication among multiple AI agents for enhanced travel assistance.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages