A full-stack web application for managing superhero characters with their images, powers, and stories. Built with React, TypeScript, Node.js, Express, PostgreSQL, and Drizzle ORM.
- React 18 with TypeScript
- React Router for navigation
- CSS Modules for styling
- Custom Hooks for state management
- Node.js with Express.js
- TypeScript for type safety
- Drizzle ORM for database operations
- PostgreSQL as database
- Multer for file uploads
- Zod for validation
Before running this application, make sure you have the following installed:
- Node.js (v18 or higher)
- npm
- PostgreSQL (v13 or higher)
- Git
git clone https://github.com/yourusername/superhero-collection.git
cd superhero-collectionnpm install
# Install backend dependencies
cd backend
npm install
# Install frontend dependencies
cd ../frontend
npm installnpm run docker:upCreate environment files in the backend directory:
backend/.env
DATABASE_URL=postgresql://postgres:admin@localhost:5433/superhero_collectioncd backend
# Setup main database
npm run db:migrate
#OR
# Setup database with mock data
npm run mock:db:migrate# From root directory
npm run dev# Terminal 1 - Start Backend Server
cd backend
npm run dev
# Terminal 2 - Start Frontend Development Server
cd frontend
npm run dev- Frontend: http://localhost:5173
- Backend API: http://localhost:4000
superhero-collection/
├── backend/
│ ├── src/
│ │ ├── db/
│ │ │ ├── schema.ts # Database schema definitions
│ │ │ └── db.ts # Database connection
│ │ ├── routes/
│ │ │ └── superhero.ts # API routes
│ │ ├── services/
│ │ │ └── superheroService.ts # Business logic
│ │ ├── middleware/
│ │ │ └── upload.ts # File upload middleware
│ │ └── index.ts # Server entry point
│ ├── uploads/ # File storage directory
│ ├── tests/ # Test files
│ ├── .env # Environment variables
│ └── package.json
├── frontend/
│ ├── src/
│ │ ├── components/ # Reusable components
│ │ ├── pages/ # Page components
│ │ ├── types/ # TypeScript type definitions
│ │ └── App.tsx
│ └── package.json
└── README.md
# Development
npm run dev # Start development server with hot reload
npm start # Start production server
# Database
npm run db:generate # Generate database migrations
npm run db:apply # Push schema to database# Development
npm run dev # Start development server
npm run build # Build for production
# Linting & Type Checking
npm run lint # Run ESLint
npm run type-check # Run TypeScript compiler check| Method | Endpoint | Description |
|---|---|---|
| GET | /api/superhero |
Get all superheroes (with pagination & search) |
| GET | /api/superhero/:id |
Get superhero by ID |
| POST | /api/superhero |
Create new superhero |
| PUT | /api/superhero/:id |
Update superhero |
| DELETE | /api/superhero/:id |
Delete superhero |
| GET | /api/superhero/:id/images |
Get superhero images |
| POST | /api/superhero/:id/images |
Add images to superhero |
| DELETE | /api/superhero/:id/images/:index |
Delete specific image |
| DELETE | /api/superhero/:id/images |
Delete all images |
Thanks for attention!