A real-time parking slot sharing application where users can mark their parking spots as available when leaving and find open parking on an interactive map.
- Interactive Map: Browse available parking spots on a Leaflet-powered map with OpenStreetMap
- Real-time Updates: WebSocket-based live updates when parking spots are added, updated, or removed
- Geolocation: Automatically center the map on your current location
- Distance Calculation: See how far parking spots are from your current location
- Two Views: Toggle between map view and list view
- Dark/Light Mode: Theme switcher for comfortable viewing
- Mobile Responsive: Works seamlessly on desktop and mobile devices
- React 18 with TypeScript
- Wouter - Lightweight routing
- TanStack Query - Server state management
- Shadcn UI + Radix UI - Component library
- Tailwind CSS - Styling
- Leaflet.js - Interactive maps
- Framer Motion - Animations
- Express.js - Web server
- WebSocket (ws) - Real-time communication
- PostgreSQL - Database (Neon serverless)
- Drizzle ORM - Type-safe database queries
- Zod - Schema validation
- Vite - Frontend bundler
- esbuild - Backend bundler
- tsx - TypeScript execution
- Node.js 20.x or higher
- npm (comes with Node.js)
- PostgreSQL database (we recommend Neon for serverless PostgreSQL)
git clone <your-repo-url>
cd calhack25npm installCreate a .env file in the root directory:
cp .env.example .envEdit .env and add your database connection string:
DATABASE_URL=postgresql://username:password@your-host.neon.tech/parkshare?sslmode=require
PORT=5000
NODE_ENV=developmentOption 1: Neon (Recommended for serverless)
- Sign up at neon.tech
- Create a new project
- Copy the connection string from the dashboard
- Paste it into your
.envfile
Option 2: Local PostgreSQL
- Install PostgreSQL locally
- Create a database:
createdb parkshare - Use connection string:
postgresql://localhost:5432/parkshare
Push the database schema to your PostgreSQL database:
npm run db:pushThis will create the parking_slots table with the following schema:
id(UUID, primary key)latitude(double precision)longitude(double precision)address(text)notes(text, optional)status(varchar, default: "available")posted_at(timestamp, default: now)
npm run devThe application will start on http://localhost:5000
npm run dev- Start development server with hot reloadnpm run build- Build for production (frontend + backend)npm run start- Start production server (runbuildfirst)npm run check- Type-check TypeScript codenpm run db:push- Push database schema changes
calhack25/
├── client/ # Frontend React app
│ ├── src/
│ │ ├── App.tsx # Root component with routing
│ │ ├── main.tsx # React entry point
│ │ ├── index.css # Global styles
│ │ ├── pages/
│ │ │ └── Home.tsx # Main application page
│ │ ├── components/ # React components
│ │ │ ├── ParkingMap.tsx
│ │ │ ├── ParkingSlotCard.tsx
│ │ │ ├── AddParkingSpotDialog.tsx
│ │ │ └── ui/ # Shadcn UI components
│ │ ├── hooks/ # Custom React hooks
│ │ └── lib/ # Utilities
│ └── index.html # HTML template
│
├── server/ # Backend Express app
│ ├── index.ts # Express server entry point
│ ├── routes.ts # API routes + WebSocket server
│ ├── storage.ts # Database operations
│ ├── db.ts # Database connection
│ └── vite.ts # Vite dev server setup
│
├── shared/ # Shared code
│ └── schema.ts # Database schema + Zod validation
│
├── .env # Environment variables (create this)
├── .env.example # Environment variables template
├── package.json # Dependencies and scripts
├── vite.config.ts # Vite configuration
├── tsconfig.json # TypeScript configuration
├── tailwind.config.ts # Tailwind CSS configuration
└── drizzle.config.ts # Database migration configuration
GET /health- Health check with database connectivityGET /api/parking-slots- List all parking slotsGET /api/parking-slots/:id- Get a single parking slotPOST /api/parking-slots- Create a new parking slotPATCH /api/parking-slots/:id- Update a parking slotDELETE /api/parking-slots/:id- Delete a parking slot
WS /ws- Real-time updates for parking slots- Connected clients receive updates when slots are created, updated, or deleted
npm run checknpm run buildThis will:
- Build the React frontend with Vite →
dist/public/ - Bundle the Express backend with esbuild →
dist/index.js
npm run startThe project uses Drizzle Kit for database migrations. The schema is defined in shared/schema.ts.
To push schema changes:
npm run db:pushMake sure to set these environment variables in your deployment platform:
DATABASE_URL- PostgreSQL connection stringNODE_ENV=productionPORT- (optional, defaults to 5000)
npm run buildnpm run startThis app can be deployed to:
- Vercel (with Neon PostgreSQL)
- Render (with managed PostgreSQL)
- Railway (with PostgreSQL addon)
- Fly.io (with PostgreSQL cluster)
- Heroku (with PostgreSQL addon)
- DigitalOcean App Platform
- AWS (EC2 + RDS)
If you see "Database connection failed":
- Check your
DATABASE_URLin.env - Verify your database is running
- Check firewall/network settings
- For Neon: Ensure your IP is allowlisted (Neon allows all IPs by default)
If real-time updates aren't working:
- Check browser console for WebSocket errors
- Verify port 5000 is accessible
- Check if your hosting platform supports WebSockets
If TypeScript errors occur:
npm run checkIf dependency issues occur:
rm -rf node_modules package-lock.json
npm install- 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
MIT License - see LICENSE file for details
For issues and questions, please open an issue on GitHub.