A starting point for integrating your App with Tesla and more!
tesla-starter/
├── src/
│ ├── apps/
│ │ ├── api/
│ │ │ └── TeslaStarter.Api/ # ASP.NET Core Web API
│ │ └── web/ # React TypeScript Frontend
│ ├── services/ # .NET Business Logic
│ │ ├── TeslaStarter.Domain/ # Domain layer (entities, value objects)
│ │ ├── TeslaStarter.Application/ # Application layer (use cases, DTOs)
│ │ └── TeslaStarter.Infrastructure/ # Infrastructure layer (persistence, external services)
│ └── shared/
│ ├── dotnet/
│ │ └── Common.Domain/ # Shared domain base classes
│ └── typescript/
│ └── api-contracts/ # Shared TypeScript API contracts
├── tests/ # All test projects
│ ├── api/
│ │ └── TeslaStarter.Api.Tests/
│ ├── services/
│ │ ├── TeslaStarter.Application.Tests/
│ │ ├── TeslaStarter.Domain.Tests/
│ │ └── TeslaStarter.Infrastructure.Tests/
│ └── shared/
│ └── dotnet/
│ └── Common.Domain.Tests/
├── docs/ # Documentation
│ ├── adr/ # Architecture Decision Records
│ └── prd/ # Product Requirements Documents
├── infra/ # Infrastructure code
│ ├── bicep/ # Azure Bicep templates
│ └── scripts/ # Deployment scripts
├── .github/ # GitHub workflows and actions
├── .vscode/ # VS Code configuration
└── .devcontainer/ # Dev container configuration
- .NET 9 SDK
- Node.js 18+
- pnpm
- Docker (for local development)
- PostgreSQL (or Docker)
- Descope account for authentication
- Backend Configuration - Create
src/apps/api/TeslaStarter.Api/appsettings.Development.json:
{
"ConnectionStrings": {
"TeslaStarterDb": "Host=localhost;Database=teslastarter;Username=postgres;Password=postgres"
},
"Descope": {
"ProjectId": "YOUR_DESCOPE_PROJECT_ID",
"ManagementKey": "YOUR_DESCOPE_MANAGEMENT_KEY"
},
"Tesla": {
"ClientId": "YOUR_TESLA_CLIENT_ID",
"RedirectUri": "http://localhost:3000/tesla/callback"
}
}- Frontend Configuration - Create
src/apps/web/.env:
VITE_DESCOPE_PROJECT_ID=YOUR_DESCOPE_PROJECT_ID
VITE_API_BASE_URL=http://localhost:5000/api# Start PostgreSQL with Docker
docker run -d \
--name teslastarter-db \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=teslastarter \
-p 5432:5432 \
postgres:16
# Run migrations
cd src/apps/api/TeslaStarter.Api
dotnet ef database updatepnpm installdotnet build
nx build webcd src/apps/api/TeslaStarter.Api
dotnet run
# API will be available at https://localhost:5001 or http://localhost:5000cd src/apps/web
pnpm dev
# Web app will be available at http://localhost:3000# .NET tests
dotnet test
# Frontend tests
nx test webThis is a monorepo using:
- Nx for JavaScript/TypeScript project management
- .NET SDK for C# projects
- pnpm for package management
- Vite for frontend tooling
See the Architecture Decision Records (ADRs) in the docs/adr/ directory for detailed technical decisions.
- Descope Integration: Secure authentication using Descope's hosted auth solution
- JWT Bearer Tokens: API authentication via Bearer tokens
- User Synchronization: Automatic user creation and profile updates on login
- Protected Routes: Frontend route protection with automatic redirects
- OAuth 2.0 Flow: Secure Tesla account linking via OAuth
- Token Management: Automatic token refresh and secure storage
- Account Linking: Users can link/unlink Tesla accounts
- User Profiles: Email, display name, and Tesla account status
- User Directory: View all registered users (authenticated endpoint)
- Real-time Updates: Profile changes reflected immediately
GET /api/auth/me- Get current user profileGET /api/auth/users- List all users (requires auth)GET /api/auth/tesla/authorize- Initialize Tesla OAuthPOST /api/auth/tesla/callback- Complete Tesla OAuthPOST /api/auth/tesla/refresh- Refresh Tesla tokensDELETE /api/auth/tesla/unlink- Unlink Tesla account
GET /api/users- List all usersGET /api/users/{id}- Get user by IDPUT /api/users/{id}- Update user profile
GET /api/vehicles- List user's vehiclesPOST /api/vehicles- Link a new vehicleGET /api/vehicles/{id}- Get vehicle detailsPUT /api/vehicles/{id}- Update vehicle detailsDELETE /api/vehicles/{id}- Unlink vehicle
- Framework: ASP.NET Core 9
- Database: PostgreSQL with Entity Framework Core
- Architecture: Clean Architecture (Domain, Application, Infrastructure)
- Authentication: Descope + Custom JWT validation
- API Documentation: Swagger/OpenAPI
- Framework: React 18 with TypeScript
- Build Tool: Vite
- State Management: React Context + React Query
- Routing: React Router v7
- UI Framework: Tailwind CSS + ShadCN UI
- Authentication: Descope React SDK
- All sensitive configuration stored in environment variables
- Tesla tokens encrypted at rest
- HTTPS required in production
- CORS configured for specific origins
- Secure session management via Descope