Smart travel companion platform connecting students with compatible co-travelers through intelligent matching algorithms.
Travel Sync helps students find compatible travel companions by intelligently matching their journey details, schedules, and preferences. Post your travel plans, discover matching co-travelers, and coordinate journeys seamlessly.
- π Secure Google OAuth 2.0 authentication with JWT sessions
- π« Travel Ticket Management - Create, update, and manage trip details
- π€ Smart Recommendation Engine - Implemented Greedy algorithm with scoring
- π‘οΈ Multi-tier Rate Limiting - Protection against abuse
- π± Real-time Status Updates - Open/closed ticket management
- π Privacy-First Design - Redacted IDs, minimal data exposure
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend (Client) β
β HTTP + Cookies (JWT) β
ββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββΌβββββββββββββββββββββββββββββββ
β Middleware Layer β
β ββββββββ βββββββββββ ββββββββββββββββββββ β
β β CORS β β JWT β β Rate Limiting β β
β ββββββββ β Auth β β (3-tier system) β β
β βββββββββββ ββββββββββββββββββββ β
ββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββΌβββββββββββββββββββββββββββββββ
β Handlers β Services β Repositories β
β β
β βββββββββββββββ βββββββββββββββββββββββββ β
β β Auth β β Recommendation β β
β β Service β β Engine (Scoring) β β
β βββββββββββββββ βββββββββββββββββββββββββ β
ββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββΌβββββββββββββββββββββββββββββββ
β PostgreSQL (GORM) β
β Users | Travel Tickets | Sessions β
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Separation of Concerns - Each layer handles specific responsibilities
- Testability - Mock dependencies for unit testing
- Scalability - Easy to extend and modify
- Maintainability - Clear code organization
| Category | Technology |
|---|---|
| Backend | Go, Gin Framework |
| Database | PostgreSQL , GORM |
| Auth | Google OAuth 2.0, JWT (golang-jwt) |
| Security | HTTP-only Cookies, CORS, Rate Limiting |
| Rate Limiting | ulule/limiter (in-memory) |
sequenceDiagram
User->>+Server: GET /auth/google/login
Server->>+Google: Redirect to OAuth
Google->>+User: Authorization Page
User->>+Google: Grant Permission
Google->>+Server: Callback with code
Server->>+Server: Verify State (CSRF)
Server->>+Server: Generate JWT
Server->>+User: Set HTTP-only Cookie
User->>+Server: Authenticated Requests
β
HTTP-only Cookies - Prevents XSS attacks
β
CSRF Protection - OAuth state parameter validation
β
JWT Validation - Signature verification on every request
β
Rate Limiting - Prevents brute force attacks
β
Ownership Checks - Users can only modify their own data
β
Input Sanitization - Validates all user inputs
JWT Details:
- Algorithm: HS256
- Expiration: 8 days
- Claims:
user_id,email, standard claims - Storage: HTTP-only cookie (
jwt_token)
Three-tier protection system:
| Tier | Limit | Burst | Applied To |
|---|---|---|---|
| General | 100/hour | 200 | All routes |
| Auth | 5/minute | 10 | Login/Auth endpoints |
| Recommendations | 20/minute | 30 | Recommendation engine |
Key Strategy:
- Authenticated:
prefix:uid:<user_id> - Unauthenticated:
prefix:<client_ip>
Response Headers:
X-RateLimit-Limit: 20
X-RateLimit-Remaining: 15
X-RateLimit-Reset: 1729684800Smart matching algorithm with multi-factor scoring:
1. Route Matching
- Exact source and destination match
2. Asymmetric Time Window
Target: 14:00, flexibility: Β±30 mins
Acceptable Range:
ββ Before: 13:30 - 14:00 (configurable)
ββ After: 14:00 - 15:00 (fixed 60 mins)
3. Status Filtering
- Only
status: "open"tickets - Excludes user's own tickets
Score = (time_proximity Γ 0.5) +
(seat_availability Γ 0.3) +
(batch_similarity Γ 0.2)Result Tiers:
best_match- Highest scored recommendationbest_group- Optimal group formationother_alternatives- Additional options
Privacy Protection: Redacts ticket.id and user_id in responses
- Go 1.21+
- PostgreSQL
- Google OAuth credentials
- Clone the repository
git clone https://github.com/yourusername/travel-sync.git
cd travel-sync- Configure environment
cp .env.example .env
# Edit .env with your credentials.env file:
PORT=8080
DATABASE_URL=postgres://user:pass@localhost:5432/travel_sync?sslmode=disable
JWT_SECRET=your_secret_key_min_32_chars
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
FRONTEND_URL=http://localhost:3000- Install dependencies
go mod download- Run the server
go run ./cmd- Health check
curl http://localhost:8080/health
# Response: {"status":"healthy","message":"Travel Sync API is running"}GET /auth/google/login # Initiate Google OAuth
GET /auth/google/callback # OAuth callback
GET /auth/me # Get current user (protected)
POST /auth/logout # Clear sessionPOST /api/travel # Create ticket
GET /api/travel # List all tickets
GET /api/travel/my # Get my tickets
GET /api/travel/:id # Get ticket by ID
PUT /api/travel/:id # Update ticket
DELETE /api/travel/:id # Delete ticket
GET /api/travel/:id/recommendations # Get matches (rate limited)curl -X POST http://localhost:8080/api/travel \
-H "Content-Type: application/json" \
-b "jwt_token=your_token" \
-d '{
"source": "BLR",
"destination": "GOI",
"departure_at": "2025-10-01T14:30:00Z",
"time_diff_mins": 30,
"empty_seats": 2,
"phone_number": "9876543210"
}'Response:
{
"success": true,
"data": {
"id": 10,
"source": "BLR",
"destination": "GOI",
"status": "open",
"departure_at": "2025-10-01T14:30:00Z"
}
}Complete API documentation: API_REFERENCE.md
travel-sync/
βββ cmd/ # Application entry point
β βββ main.go
βββ internal/ # Private application code
β βββ middleware/ # CORS, rate limiting
β βββ security/ # OAuth, JWT, auth handlers
β βββ travel/ # Travel domain logic
β β βββ handlers/ # HTTP handlers
β β βββ services/ # Business logic + recommendation engine
β β βββ repositories/ # Data access
β β βββ models/ # Data models
β βββ user/ # User management
β βββ server/ # Server configuration
βββ docs/ # Documentation
βββ .env # Environment variables
βββ go.mod # Go dependencies
βββ README.md
|
π Authentication System
|
π€ Recommendation Engine
|
|
β‘ Rate Limiting
|
π« Ticket Management
|
Note: Add your application screenshots here by uploading them to your repository in a
/docs/images/folder
| Variable | Description | Required |
|---|---|---|
PORT |
Server port | Yes |
DATABASE_URL |
PostgreSQL connection | Yes |
JWT_SECRET |
JWT signing key (min 32 chars) | Yes |
GOOGLE_CLIENT_ID |
OAuth client ID | Yes |
GOOGLE_CLIENT_SECRET |
OAuth secret | Yes |
FRONTEND_URL |
Frontend URL for redirects | Yes |
- In-memory Rate Limiting - Fast, per-instance tracking
- GORM Query Optimization - Efficient database access
- Layered Architecture - Easy horizontal scaling
- Auto-migrations - Seamless schema updates
Contributions welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open a Pull Request