Skip to content

Commit e7c600d

Browse files
committed
Merge branch 'client-complete' of github.com:github-samples/planventure into client-complete
2 parents 6ce2a9f + a20a199 commit e7c600d

File tree

5 files changed

+202
-31
lines changed

5 files changed

+202
-31
lines changed

README.md

Lines changed: 90 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,124 @@
1-
# Planventure API 🚁
1+
# Planventure API Server 🚀
2+
3+
A Flask backend API that powers the Planventure travel planning application. This guide will help you quickly get the server running so you can focus on building the client application.
4+
5+
## Quick Start
6+
7+
1. Fork and clone the repository:
8+
```sh
9+
git clone https://github.com/yourusername/planventure.git
10+
cd planventure/planventure-api
11+
```
12+
13+
2. Set up Python environment and install dependencies:
14+
```sh
15+
python -m venv venv
16+
source venv/bin/activate # On Windows: venv\Scripts\activate
17+
pip install -r requirements.txt
18+
```
19+
20+
3. Start the development server:
21+
```sh
22+
flask run
23+
```
24+
25+
The API server will be running at `http://localhost:5000`
26+
27+
That's it! You can now proceed to set up and work on the client application.
28+
29+
## API Health Check
30+
31+
Verify the server is running:
32+
```sh
33+
curl http://localhost:5000/health
34+
```
35+
36+
Expected response: `{"status": "healthy"}`
37+
38+
# Planventure Client ✈️
239

340
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/github-samples/planventure)
441

5-
A Flask-based REST API backend for the Planventure application.
42+
A React-based travel planning application that helps you organize your trips, manage itineraries, and keep track of travel details.
43+
44+
## Features
45+
46+
- 🗺️ Trip Planning & Management
47+
- 📅 Interactive Itinerary Builder
48+
- 🏨 Accommodation Tracking
49+
- 🚗 Transportation Management
50+
- 📱 Responsive Design
51+
- 🔐 Secure Authentication
652

753
## Prerequisites
8-
Before you begin, ensure you have the following:
954

55+
Before you begin, ensure you have the following:
56+
- Node.js (v16 or higher)
57+
- npm or yarn
1058
- A GitHub account
1159
- Access to GitHub Copilot - [sign up for FREE](https://gh.io/gfb-copilot)!
12-
- A Code Editor
13-
- API Client (like [Bruno](https://github.com/usebruno/bruno))
1460
- Git - [Download & Install Git](https://git-scm.com/downloads)
1561

1662
## 🚀 Getting Started
1763

18-
## Build along in a Codespace
64+
### Quick Start with Codespaces
1965

20-
1. Click the "Open in GitHub Codespaces" button above to start developing in a GitHub Codespace.
66+
1. Click the "Open in GitHub Codespaces" button above
67+
2. Wait for the environment to build
68+
3. Run `npm install` and `npm run dev`
2169

2270
### Local Development Setup
2371

24-
If you prefer to develop locally, follow the steps below:
25-
26-
1. Clone the repository and navigate to the [planventue-api](/planventure-api/) directory:
72+
1. Open a new terminal window and cd into the `planventure-client` directory:
2773
```sh
28-
cd planventure-api
74+
cd planventure/planventure-client
2975
```
3076

31-
2. Create a virtual environment and activate it:
77+
2. Install dependencies:
3278
```sh
33-
python -m venv venv
34-
source venv/bin/activate # On Windows: venv\Scripts\activate
79+
npm install
3580
```
3681

37-
3. Install the required dependencies:
82+
3. Create a `.env` file:
3883
```sh
39-
pip install -r requirements.txt
84+
VITE_API_URL=http://localhost:5000
4085
```
4186

42-
4. Create an `.env` file based on [.sample.env](/planventure-api/.sample.env):
87+
4. Start the development server:
4388
```sh
44-
cp .sample.env .env
89+
npm run dev
4590
```
4691

47-
5. Start the Flask development server:
48-
```sh
49-
flask run
50-
```
92+
Visit `http://localhost:5173` to see the application.
93+
94+
## 🏗️ Tech Stack
95+
96+
- React
97+
- Material-UI
98+
- React Router
99+
- Day.js
100+
- Vite
101+
102+
## 📱 Features Overview
103+
104+
### Trip Management
105+
- Create and manage trips
106+
- Set destinations and dates
107+
- Track accommodations and transportation
51108

52-
## Docker Setup
109+
### Itinerary Planning
110+
- Day-by-day planning
111+
- Activity scheduling
112+
- Time management
53113

54-
If bulding locally, follow the Docker setup steps in the [DockerSetup](DockerSetup) file.
114+
## 🤝 Contributing
55115

56-
## 📚 API Endpoints
57-
- GET / - Welcome message
58-
- GET /health - Health check endpoint
116+
1. Fork the repository
117+
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
118+
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
119+
4. Push to the branch (`git push origin feature/AmazingFeature`)
120+
5. Open a Pull Request
59121

60122
## 📝 License
61123

62-
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
124+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

planventure-api/requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ werkzeug==2.3.7
1212
bcrypt==4.0.1
1313

1414
# Database migrations
15-
Flask-Migrate==4.0.5
15+
Flask-Migrate==4.0.5
16+
17+
pytest==8.3.2
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import pytest
2+
from .validators import validate_email, validate_username
3+
4+
def test_valid_emails():
5+
"""Test validation of properly formatted email addresses"""
6+
valid_emails = [
7+
8+
9+
10+
11+
12+
]
13+
for email in valid_emails:
14+
assert validate_email(email) is True
15+
16+
def test_invalid_emails():
17+
"""Test validation of improperly formatted email addresses"""
18+
invalid_emails = [
19+
20+
"@domain.com",
21+
"test@domain",
22+
"test@domain.",
23+
"test.domain.com",
24+
25+
26+
]
27+
for email in invalid_emails:
28+
assert validate_email(email) is False
29+
30+
def test_edge_cases():
31+
"""Test validation with edge cases"""
32+
assert validate_email("") is False
33+
with pytest.raises(TypeError):
34+
validate_email(None)
35+
36+
def test_valid_usernames():
37+
"""Test validation of properly formatted usernames"""
38+
valid_usernames = [
39+
"user123",
40+
"_user",
41+
"john_doe",
42+
"a123",
43+
"Developer42",
44+
"code_master",
45+
"Alice_Bob_123"
46+
]
47+
for username in valid_usernames:
48+
assert validate_username(username) is True
49+
50+
def test_invalid_usernames():
51+
"""Test validation of improperly formatted usernames"""
52+
invalid_usernames = [
53+
"ab", # too short
54+
"a" * 17, # too long
55+
"123user", # starts with number
56+
"__user", # multiple underscores at start
57+
"user name", # contains space
58+
"user@name", # special character
59+
"-user", # starts with hyphen
60+
"user-", # ends with hyphen
61+
]
62+
for username in invalid_usernames:
63+
assert validate_username(username) is False
64+
65+
def test_username_edge_cases():
66+
"""Test username validation with edge cases"""
67+
assert validate_username("") is False
68+
with pytest.raises(TypeError):
69+
validate_username(None)

planventure-api/utils/validators.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,42 @@ def validate_email(email: str) -> bool:
44
"""Validate email format using regex pattern"""
55
pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
66
return bool(re.match(pattern, email))
7+
8+
def validate_username(username: str) -> bool:
9+
"""
10+
Validates a username according to the following rules:
11+
- Between 3 and 16 characters
12+
- Starts with a letter or single underscore
13+
- Can contain letters, numbers, and underscores after first character
14+
- No spaces or special characters
15+
16+
Args:
17+
username: The username to validate
18+
19+
Returns:
20+
bool: True if username is valid, False otherwise
21+
22+
Raises:
23+
TypeError: If username is None
24+
"""
25+
if username is None:
26+
raise TypeError("Username cannot be None")
27+
28+
# Check for empty string
29+
if not username:
30+
return False
31+
32+
# Check length (3-16 characters)
33+
if len(username) < 3 or len(username) > 16:
34+
return False
35+
36+
# Pattern explanation:
37+
# ^ - Start of string
38+
# [a-zA-Z_] - First character must be letter or underscore
39+
# (?!_) - Negative lookahead to prevent multiple underscores at start
40+
# [a-zA-Z0-9_] - Remaining characters can be letters, numbers, or underscores
41+
# {2,15} - Length of remaining characters (2-15, plus first character = 3-16 total)
42+
# $ - End of string
43+
pattern = r'^[a-zA-Z_](?!_)[a-zA-Z0-9_]{2,15}$'
44+
45+
return bool(re.match(pattern, username))

planventure-client/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"@emotion/styled": "^11.14.0",
1515
"@mui/icons-material": "^6.2.0",
1616
"@mui/material": "^6.2.0",
17-
"@mui/x-date-pickers": "^7.27.1",
18-
"dayjs": "^1.11.13",
17+
"@mui/icons-material": "^6.2.0",
1918
"react": "^18.3.1",
2019
"react-dom": "^18.3.1",
2120
"react-router-dom": "^7.0.2"

0 commit comments

Comments
 (0)