A comprehensive system that transforms GPS trip data into human-readable narratives using AI, featuring BCNF-normalized database schema, OAuth2 authentication, and geospatial validation.
- Trip Management: Create, retrieve, search, and delete GPS trips
- Geospatial Validation: Automatic validation of coordinates using PostGIS
- Security: OAuth2 with JWT authentication and role-based access control
- Configuration: Define geographic zones and regions for analytics
- Feedback System: Manual override and quality assurance for AI outputs
- API Documentation: Interactive Swagger UI and ReDoc
- Python 3.9+
- PostgreSQL 12+ with PostGIS extension
- MongoDB 4.4+ (for AI metadata)
cd "d:/5th Sem/dbms"
python -m venv venv
# Windows
venv\Scripts\activate
# Linux/Mac
source venv/bin/activatepip install -r requirements.txtCopy the example environment file and fill in your credentials:
copy .env.example .envEdit .env and configure:
# Database URLs
DATABASE_URL=postgresql://username:password@localhost:5432/trip_verbalization
MONGODB_URL=mongodb://localhost:27017/trip_verbalization
# Generate JWT secret with: openssl rand -hex 32
JWT_SECRET_KEY=your_generated_secret_key_here
# Optional: API keys for geocoding and LLM
GEOCODING_API_KEY=your_here_api_key
LLM_API_KEY=your_gemini_api_keyEnsure PostgreSQL is running, then initialize the database:
# Create database
psql -U postgres -c "CREATE DATABASE trip_verbalization;"
# Initialize tables and create admin user
python init_db.pyDefault admin credentials:
- Username:
admin - Password:
admin123(β οΈ Change after first login!)
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000The API will be available at:
- API: http://localhost:8000
- Interactive Docs: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 4curl -X POST "http://localhost:8000/auth/register" \
-H "Content-Type: application/json" \
-d '{
"username": "analyst1",
"email": "analyst@example.com",
"password": "SecurePass123",
"role": "analyst"
}'curl -X POST "http://localhost:8000/auth/login" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=analyst1&password=SecurePass123"Response:
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "bearer"
}curl -X POST "http://localhost:8000/trips/" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"start_lat": 12.9716,
"start_lon": 77.5946,
"end_lat": 13.0827,
"end_lon": 80.2707,
"start_time": "2025-12-22T08:00:00",
"end_time": "2025-12-22T12:00:00",
"route_points": [
{
"latitude": 12.9716,
"longitude": 77.5946,
"timestamp": "2025-12-22T08:00:00",
"sequence": 1
},
{
"latitude": 13.0827,
"longitude": 80.2707,
"timestamp": "2025-12-22T12:00:00",
"sequence": 2
}
]
}'curl -X GET "http://localhost:8000/trips/?start_date=2025-12-20&end_date=2025-12-25" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"- USER: Can create and manage their own trips
- ANALYST: Can manage trips, create zones/regions, and provide feedback
- ADMIN: Full access to all features
- Minimum 8 characters
- Passwords are hashed using bcrypt
- Expire after 30 minutes (configurable)
- Include in requests:
Authorization: Bearer <token>
- users: User authentication and authorization
- trip_data: Primary trip information
- route_points: GPS points along the trip route
- locations: Geocoded address information
- verbalized_trips: AI-generated narratives
- api_usage_logs: API call tracking
- zones: Geographic zones for analytics
- regions: Logical grouping of zones
- feedbacks: Manual corrections from analysts
- Latitude: -90 to 90 degrees
- Longitude: -180 to 180 degrees
- Polygon coordinates auto-close if not closed
- end_time must be after start_time
- Route points must be in chronological order
- Sequence numbers must be unique
If you get "PostGIS extension not found":
CREATE EXTENSION IF NOT EXISTS postgis;If using asyncpg, ensure your DATABASE_URL uses postgresql+asyncpg://:
# The app automatically handles this conversion
DATABASE_URL=postgresql://user:pass@localhost/dbnameGenerate a secure secret key:
openssl rand -hex 32This project was developed at RV College of Engineering for the DBMS course.
- AI Trip Verbalization Team
- RV College of Engineering
For issues or questions, please contact the development team.