- Project Overview
- Features
- Tech Stack
- Prerequisites
- Installation Guide
- Environment Setup
- Running the Application
- API Documentation
- Authentication Flow
- Project Structure
- Contributing
- Troubleshooting
Subscription Tracker is a modern web application designed to help users efficiently manage and monitor their subscriptions. Built with TypeScript and Express.js, it provides a secure and scalable solution for subscription management with features like user authentication and CRUD operations.
Feature | Description |
---|---|
π Authentication | Complete user authentication system (Sign Up, Sign In, Sign Out) |
π CRUD Operations | Full subscription management capabilities |
π Security | JWT-based authentication with secure password hashing |
π Database | Robust MongoDB integration with Mongoose ODM |
π TypeScript | Full TypeScript support for better development experience |
graph LR
A[Node.js] --> B[Express.js]
B --> C[TypeScript]
graph LR
A[MongoDB] --> B[Mongoose ODM]
- π JSON Web Tokens (JWT)
- π Bcrypt Password Hashing
- π‘ Cookie-based Authentication
Before starting, ensure you have the following installed:
Requirement | Version | Description |
---|---|---|
Node.js | v18+ | JavaScript runtime |
Bun | Latest | Modern JavaScript runtime & package manager |
MongoDB | Latest | Database server |
-
Clone the Repository
git clone https://github.com/your-username/tracker-suscription.git cd tracker-suscription
-
Install Dependencies
bun install
-
Create a
.env.development.local
file in the project root:# Server Configuration PORT=5500 NODE_ENV=development # Database Configuration DB_URI=mongodb://your-mongodb-connection-string # JWT Authentication JWT_SECRET="your-secret-key" JWT_EXPIRES_IN=1d
-
Environment Variables Description
Variable Description Example PORT Server port number 5500 NODE_ENV Environment mode development DB_URI MongoDB connection string mongodb://localhost:27017/subscription-tracker JWT_SECRET Secret key for JWT your-secret-key JWT_EXPIRES_IN JWT expiration time 1d
bun dev
bun run build
bun start
Method | Endpoint | Description | Authentication Required |
---|---|---|---|
POST | /api/v1/auth/sign-up |
Register new user | No |
POST | /api/v1/auth/sign-in |
User login | No |
GET | /api/v1/auth/sign-out |
User logout | Yes |
Method | Endpoint | Description | Authentication Required |
---|---|---|---|
GET | /api/v1/subscriptions |
Get all subscriptions | Yes |
GET | /api/v1/subscriptions/:id |
Get specific subscription | Yes |
POST | /api/v1/subscriptions |
Create subscription | Yes |
PUT | /api/v1/subscriptions/:id |
Update subscription | Yes |
DELETE | /api/v1/subscriptions/:id |
Delete subscription | Yes |
sequenceDiagram
participant User
participant Server
participant Database
User->>Server: Register with email/password
Server->>Database: Hash password & store user
Database-->>Server: Confirm storage
Server-->>User: Success response
User->>Server: Login with credentials
Server->>Database: Verify credentials
Database-->>Server: User found
Server-->>User: JWT token
project-root/
βββ config/
β βββ arcjet.ts
β βββ env.ts
βββ controllers/
β βββ auth.controller.ts
β βββ user.controller.ts
βββ database/
β βββ mongodb.ts
βββ middleware/
β βββ arcjet.middleware.ts
β βββ auth.middleware.ts
β βββ error.middleware.ts
βββ models/
β βββ subscription.model.ts
β βββ user.model.ts
βββ routes/
βββ auth.routes.ts
βββ subscription.routes.ts
βββ user.routes.ts
- Fork the repository
- Create your feature branch:
git checkout -b feature/amazing-feature
- Commit your changes:
git commit -m 'Add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
Issue | Solution |
---|---|
MongoDB Connection Failed | Check if MongoDB is running and connection string is correct |
JWT Token Invalid | Ensure JWT_SECRET is properly set in .env file |
Port Already in Use | Change PORT in .env file or kill the process using the port |
For support, please open an issue in the GitHub repository or contact the maintainers.
π License: MIT