Accès vidéo Présentation : https://drive.google.com/file/d/1eE_iHi3lelr3NahonImvNVRxfWiW-f5T/view?usp=sharing
A full-stack web application for managing superheroes, built with React, TypeScript, Node.js, Express, and MongoDB.
- User authentication (login/register)
- Role-based access control (admin/editor)
- CRUD operations for superheroes
- Image upload for hero profiles
- Protected routes
- JWT-based authentication
- React 19
- TypeScript
- Vite
- React Router DOM
- Axios
- Node.js
- Express 5
- TypeScript
- MongoDB with Mongoose
- JWT for authentication
- Bcrypt for password hashing
- Multer for file uploads
- Node.js (v18 or higher)
- MongoDB (running locally or a MongoDB Atlas connection)
- npm or yarn
git clone https://github.com/Mavedial/TPDernierMiniProjet.git
cd TPDernierMiniProjetcd Backend
npm installcd ../Frontend
npm installCreate a .env file in the Backend directory (you can copy from .env.example):
cd ../Backend
cp .env.example .envEdit the .env file with your configuration:
PORT=5000
MONGO_URI=mongodb://localhost:27017/superhero
JWT_SECRET=your-secret-jwt-key-change-this-in-production
CORS_ORIGIN=http://localhost:5173Important:
- Replace
MONGO_URIwith your MongoDB connection string - Replace
JWT_SECRETwith a strong secret key in production
Make sure MongoDB is running on your system:
# For local MongoDB
sudo systemctl start mongod # Linux
brew services start mongodb-community # macOS
# Or use MongoDB Atlas cloud databasecd Backend
npm run devThe backend server will start on http://localhost:5000
In a new terminal:
cd Frontend
npm run devThe frontend will start on http://localhost:5173
cd Frontend
npm run buildThe built files will be in the Frontend/dist directory.
The backend uses ts-node-dev for development. For production, you can compile TypeScript:
cd Backend
npx tscThe compiled files will be in the Backend/dist directory.
TPDernierMiniProjet/
├── Backend/
│ ├── src/
│ │ ├── config/ # Database configuration
│ │ ├── controllers/ # Route controllers
│ │ ├── middleware/ # Authentication & authorization
│ │ ├── models/ # Mongoose models
│ │ ├── routes/ # Express routes
│ │ ├── types/ # TypeScript types
│ │ ├── uploads/ # Uploaded files
│ │ ├── utils/ # Utility functions
│ │ └── index.ts # Server entry point
│ ├── .env.example # Environment variables template
│ └── package.json
├── Frontend/
│ ├── src/
│ │ ├── api/ # API client functions
│ │ ├── components/ # React components
│ │ ├── context/ # React context (Auth)
│ │ ├── hooks/ # Custom hooks
│ │ ├── pages/ # Page components
│ │ ├── styles/ # CSS files
│ │ └── types/ # TypeScript types
│ ├── index.html
│ └── package.json
└── README.md
POST /api/auth/register- Register a new userPOST /api/auth/login- Login user
GET /api/heroes- Get all heroesGET /api/heroes/:id- Get a single heroPOST /api/heroes- Create a new hero (requires authentication)PUT /api/heroes/:id- Update a hero (requires authentication)DELETE /api/heroes/:id- Delete a hero (requires admin role)
- admin: Full access to all operations
- editor: Can create and edit heroes, but cannot delete
- Ensure MongoDB is running
- Check if the
MONGO_URIin.envis correct - Verify network connectivity if using MongoDB Atlas
- Change the
PORTinBackend/.env - Change the port in
Frontend/vite.config.tsif needed - Update
CORS_ORIGINinBackend/.envto match the new frontend port
- Delete
node_modulesandpackage-lock.json - Run
npm installagain
ISC