Overview
F1 PitLane Predict is built as a full-stack web application with a clear separation between frontend and backend services. The application uses modern web technologies to deliver a responsive user experience for tracking Formula 1 race results and predictions.Tech stack
Frontend
The client-side application is built with:- Vue.js 3.3.4 - Progressive JavaScript framework for building the user interface
- Vue Router 4.2.5 - Official routing library for navigation between views
- Vuex 4.1.0 - State management for centralized application state
- Axios 1.6.2 - HTTP client for API communication
- TypeScript 5.2 - Type-safe JavaScript with static typing
- Vite 5.4.20 - Fast build tool and development server
Backend
The server-side application uses:- Node.js 20+ - JavaScript runtime environment
- Nitro.js (unjs) - Next generation server toolkit for building APIs
- TypeScript - Type safety across the backend codebase
- Prisma ORM 5.7.0 - Type-safe database client
- PostgreSQL - Primary relational database
- bcrypt 5.1.1 - Password hashing for user authentication
- jsonwebtoken 9.0.2 - JWT token generation and validation
Architecture overview
Client-server separation
The application runs two separate development servers:- Frontend server - Runs on
http://localhost:5173using Vite - Backend server - Runs independently using Nitro.js dev server
This separation allows independent scaling and deployment of frontend and backend services. The backend is configured with CORS to accept requests from any origin during development.
Communication flow
Folder structure
Frontend structure
src/ - Frontend source code
src/ - Frontend source code
components/- Shared, reusable UI componentsviews/- Full page components mapped to routesrouter/- Route definitions and navigation logic
Backend structure
server/ - Backend source code
server/ - Backend source code
api/- RESTful API endpoints using Nitro’s file-based routing- Each subdirectory represents a resource with CRUD operations
prisma/ - Database schema and migrations
prisma/ - Database schema and migrations
Users- User accounts and authenticationDrivers- F1 driver informationTeams- Constructor/team dataRaces- Race events and circuitsResults- Race outcomes and pointsBets- User predictions and betting data
Key architectural decisions
Why Nitro.js?
Nitro.js was chosen as the backend framework because:- Minimal boilerplate - File-based routing reduces configuration
- TypeScript-first - Native TypeScript support without additional setup
- Fast development - Hot module replacement for rapid iteration
- Lightweight - Small footprint compared to full frameworks
- Flexible deployment - Can deploy to various platforms
Why Prisma ORM?
Prisma provides several advantages:- Type safety - Auto-generated TypeScript types from schema
- Developer experience - Intuitive query API and migrations
- Database agnostic - Easy to switch databases if needed
- Performance - Optimized query generation
Why separate frontend/backend?
The decoupled architecture offers:- Independent scaling - Scale frontend and backend separately
- Team productivity - Frontend and backend teams can work independently
- Deployment flexibility - Deploy to different hosting services
- Technology flexibility - Replace either layer without affecting the other
API design
RESTful endpoints
The backend follows REST conventions with file-based routing:GET /api/drivers- List all driversPOST /api/drivers/create- Create a new driverPUT /api/drivers/update- Update a driverDELETE /api/drivers/delete- Remove a driver
CORS configuration
The backend is configured inserver/nitro.config.ts to allow cross-origin requests:
Build configuration
Frontend build
Vite is configured invite.config.ts with:
- Vue.js plugin for
.vuefile support - Path alias
@pointing to./srcfor cleaner imports - Development server on port 5173
Backend build
Nitro compiles the backend into an optimized Node.js server:Type safety
The application maintains type safety across all layers:- Frontend - Vue components use TypeScript with
vue-tscfor type checking - Backend - Nitro endpoints use TypeScript
- Database - Prisma generates types from the schema automatically
Run
npm run type-check in the frontend directory to verify type correctness without building.