A full-stack web application for Fidelity Investment with a clean HTML/CSS/JS frontend and a secure Node.js/Express backend with MongoDB.
fidelity-project/
├── index.html # Main homepage
├── style.css # Main stylesheet
├── style.js # Main JavaScript
├── js/
│ └── api.js # API service for frontend
├── css/
│ └── forms.css # Auth form styles
├── pages/
│ ├── login.html # Login page
│ └── open-account.html # Registration page
├── backend/
│ ├── src/
│ │ ├── server.js # Express server
│ │ ├── config/
│ │ │ └── database.js # MongoDB connection
│ │ ├── models/
│ │ │ └── user.model.js
│ │ ├── controllers/
│ │ │ └── auth.controller.js
│ │ ├── routes/
│ │ │ ├── auth.routes.js
│ │ │ └── user.routes.js
│ │ └── middleware/
│ │ ├── auth.middleware.js
│ │ ├── error.middleware.js
│ │ └── notFound.middleware.js
│ ├── .env.example # Environment variables template
│ └── package.json
└── img/ # Images and assets
- Frontend: Clean HTML/CSS/JS with responsive design
- Backend: Secure Node.js/Express API
- Database: MongoDB with Mongoose
- Authentication: JWT-based authentication
- Security: Helmet, CORS, Rate limiting, Password hashing
- Node.js 18+
- MongoDB (local or Atlas)
- npm or yarn
-
Clone the repository
cd fidelity-project -
Install backend dependencies
cd backend npm install -
Configure environment variables
cp .env.example .env # Edit .env with your settings -
Start MongoDB
- Local: Make sure MongoDB is running on port 27017
- Atlas: Update MONGODB_URI in .env
-
Start the backend server
# Development mode npm run dev # Production mode npm start
-
Start the frontend
- Open
index.htmlin a browser using a local server - VS Code: Use Live Server extension
- Python:
python -m http.server 5500 - Node:
npx serve .
- Open
POST /api/auth/register- Register new userPOST /api/auth/login- Login userPOST /api/auth/logout- Logout userGET /api/auth/profile- Get user profile (auth required)
GET /api/users/profile- Get user profile (auth required)PUT /api/users/profile- Update user profile (auth required)
# Server Configuration
NODE_ENV=development
PORT=5000
# MongoDB Configuration
MONGODB_URI=mongodb://localhost:27017/fidelity
# JWT Configuration
JWT_SECRET=your-super-secure-jwt-secret-key
JWT_EXPIRES_IN=7d
# Frontend URL
FRONTEND_URL=http://localhost:5500- Password Hashing: bcrypt with salt rounds
- JWT Tokens: Secure authentication
- Rate Limiting: 100 requests per 15 minutes
- Helmet: Security headers
- CORS: Configured for specific origins
- Input Validation: express-validator
cd backend
npm test- ESLint configured for JavaScript
- Prettier for formatting
- Set
NODE_ENV=production - Use strong
JWT_SECRET - Configure proper CORS origins
- Use MongoDB Atlas or managed service
- Enable HTTPS
- Set up proper logging
MIT License