This is a full-stack shoe collection management application with JWT authentication, built with TypeScript, Node.js, Express, Prisma ORM, and React.
- Framework: Express.js with TypeScript
- Language: TypeScript for type safety and better developer experience
- Database: SQLite with Prisma ORM
- Authentication: JWT (JSON Web Tokens)
- Password Security: bcryptjs for hashing
- Type Safety: Full TypeScript coverage with strict mode
- Framework: React with TypeScript
- Language: TypeScript for type safety
- HTTP Client: Axios with TypeScript types
- State Management: React useState and useEffect with TypeScript
- Routing: Client-side authentication logic
- Type Safety: All components, services, and interfaces are typed
- User submits credentials (register/login)
- Backend validates and hashes password (bcryptjs)
- JWT token generated with user ID
- Token stored in localStorage
- Subsequent requests include token in Authorization header
- Middleware validates token on protected routes
- Frontend component triggers action (e.g., addShoe)
- API service method called (e.g.,
shoesAPI.addShoe) - Axios sends HTTP request to Express backend
- Authentication middleware validates JWT token
- Controller extracts data and calls service layer
- Service layer interacts with Prisma database
- Response flows back through the stack
- UI updates reactively
- Routes (
/routes): Define endpoints and mount middleware - Controllers (
/controllers): Handle HTTP requests/responses - Services (
/services): Business logic and database operations - Middleware (
/middleware): Authentication validation - Prisma (
/prisma): Database schema and migrations
- Components (
/components): TypeScript React componentsLogin.tsx: TypeScript authentication form with typed propsShoeList.tsx: TypeScript component to display all shoesAddShoeForm.tsx: TypeScript form to add new shoes
- Services (
/services): TypeScript API communication layer with typed interfaces - App.tsx: Main TypeScript application logic and state management
- Password Hashing: bcryptjs with salt rounds (10)
- JWT Tokens: Signed with secret key, 1-hour expiration
- Protected Routes: Middleware checks for valid token
- CORS: Enabled for cross-origin requests
- Input Validation: Required fields on forms
- id (Int, auto-increment, primary key)
- username (String, unique)
- password (String, hashed)
- createdAt (DateTime, default now)- id (Int, auto-increment, primary key)
- name (String)
- brand (String)
- createdAt (DateTime, default now)Authentication
-
POST /api/auth/register: Register new user- Body:
{ username, password } - Response:
{ message: "User registered successfully" }
- Body:
-
POST /api/auth/login: Login user- Body:
{ username, password } - Response:
{ token: "jwt-token" }
- Body:
Shoes (Protected - requires Bearer token)
-
GET /api/shoes: Get all shoes- Response:
[{ id, name, brand, createdAt }, ...]
- Response:
-
POST /api/shoes: Add new shoe- Body:
{ name, brand } - Response:
{ id, name, brand, createdAt }
- Body:
-
DELETE /api/shoes/:id: Delete shoe by ID- Response: 204 No Content
- Try-catch blocks in all async functions
- HTTP status codes: 200, 201, 204, 401, 500
- Error messages returned to client
- Database errors caught and logged
- API error responses handled
- User-friendly error messages displayed
- Loading states for async operations
- Form validation before submission
- TypeScript Throughout: Both frontend and backend use TypeScript for type safety, better IDE support, and catch errors at compile time
- Separation of Concerns: Clear layering (routes → controllers → services)
- Modular Components: Each React component handles specific UI concern with typed props and interfaces
- Centralized API Service: Single axios instance with interceptors and TypeScript types
- Local Storage: Simple token persistence without cookies
- Prisma ORM: Type-safe database queries and migrations with TypeScript integration
- SQLite: Self-contained database for simplicity
- bcryptjs: Industry-standard password hashing
- CORS Middleware: Enable frontend-backend communication
- Strict TypeScript: Enabled strict mode for maximum type safety
- Environment Variables: Sensitive data in .env files
- Gitignore: Exclude node_modules, database, .env
- Code Organization: Clean folder structure for scalability
- Error Messages: Informative feedback to users
- Loading States: UX best practices for async operations
- Responsive Design: Modern CSS with gradients and cards
- Test authentication flow (register → login)
- Test CRUD operations (add, view, delete shoes)
- Test error scenarios (invalid credentials, duplicate usernames)
- Test token expiration (logout after 1 hour)
- Test concurrent operations
- Test data persistence after page refresh
- Add user-specific shoe collections (foreign keys)
- Add update/edit functionality for shoes
- Add search and filter capabilities
- Add pagination for large datasets
- Add user profile management
- Add password reset functionality
- Switch to PostgreSQL for production
- Add Docker containerization
- Add automated testing (Jest, Supertest)
- Add CI/CD pipeline
- Change JWT_SECRET to secure random string
- Use environment-specific .env files
- Configure CORS to allow production domain only
- Use production database (PostgreSQL)
- Build React app:
npm run build - Serve static files from Express or CDN
- Set up reverse proxy (nginx)
- Enable HTTPS
- Monitor logs and errors
- Set up database backups