diff --git a/.env.example b/.env.example deleted file mode 100644 index 82180c68..00000000 --- a/.env.example +++ /dev/null @@ -1,3 +0,0 @@ -# URL of the backend API (no trailing slash). -# Must match the origin the backend server listens on. -VITE_BACKEND_URL=http://localhost:5000 diff --git a/README.md b/README.md index b16c9995..a747b53a 100644 --- a/README.md +++ b/README.md @@ -41,206 +41,28 @@ Welcome to **GitHub Tracker**, a web app designed to help you monitor and analyz --- ## ๐ Setup Guide - -### ๐ Prerequisites - -Before setting up the project locally, ensure the following tools are installed on your system: - -- Node.js (v18 or later recommended) -- npm -- Docker -- Docker Compose -- MongoDB (required for backend services and testing) - ---- - -## ๐ฅ Clone the Repository - -```bash -git clone https://github.com/GitMetricsLab/github_tracker.git -cd github-tracker -``` - ---- - -# ๐ป Local Development Setup - -This project contains both frontend and backend services. - -## โถ๏ธ Frontend Setup - -Install frontend dependencies: - -```bash -npm install -``` - -Start the frontend development server: - -```bash -npm run dev -``` - -The frontend will run on: - -```txt -http://localhost:5173 -``` - ---- - -## โ๏ธ Backend Setup - -Move into the backend directory: - +1. Clone the repository to your local machine: ```bash -cd backend +$ git clone https://github.com/yourusername/github-tracker.git ``` -Install backend dependencies: - +2. Navigate to the project directory: ```bash -npm install +$ cd github-tracker ``` -3. Configure environment variables - - Copy the example files and fill in your values: - ```bash - # Frontend (.env in the repo root) - cp .env.example .env - - # Backend (.env inside backend/) - cp backend/.env.example backend/.env - ``` - - Key variables to set: - - | Variable | Where | Description | - |---|---|---| - | `VITE_BACKEND_URL` | root `.env` | URL of the backend (default: `http://localhost:5000`) | - | `MONGO_URI` | `backend/.env` | MongoDB connection string | - | `SESSION_SECRET` | `backend/.env` | Long random string used to sign session cookies | - | `FRONTEND_ORIGIN` | `backend/.env` | URL of the frontend โ restricts CORS. **Required in production.** Defaults to `http://localhost:5173` in development. | - -4. Run the frontend +3. Run the frontend ```bash -npm run dev -``` - -The backend server will run on: - -```txt -http://localhost:5000 +$ npm i +$ npm run dev ``` -5. Run the backend +4. Run the backend ```bash -$ cd backend $ npm i $ npm start ``` -This command: - -- Builds frontend and backend containers -- Starts development services -- Enables live file changes using Docker volumes -- Runs frontend and backend simultaneously - -### Development Services - -| Service | Port | -|----------|------| -| Frontend | 5173 | -| Backend | 5000 | - ---- - -## ๐ Production Environment - -Run the production Docker setup: - -```bash -npm run docker:prod -``` - -This command: - -- Creates optimized production builds -- Runs frontend using Nginx -- Starts backend production services - -### Production Services - -| Service | Port | -|----------|------| -| Frontend | 3000 | -| Backend | 5000 | - ---- - -# ๐ Docker Configuration Overview - -| File | Purpose | -|------|----------| -| `Dockerfile.dev` | Development container setup | -| `Dockerfile.prod` | Production container setup | -| `docker-compose.yml` | Multi-service container orchestration | - ---- - -# ๐ Local Development Workflow - -Recommended contributor workflow: - -1. Fork the repository -2. Clone your fork locally -3. Create a new branch -4. Install dependencies -5. Run frontend/backend locally or using Docker -6. Make changes -7. Test your implementation -8. Commit and push changes -9. Open a Pull Request - ---- - -# ๐ฑ Environment Configuration - -The project uses environment variables for configuration. - -Frontend environment variables: - -```env -VITE_BACKEND_URL=http://localhost:5000 -``` - -Backend environment variables: - -```env -PORT=5000 -MONGO_URI=your_mongodb_connection -SESSION_SECRET=your_secret -``` - -Create corresponding `.env` files before running the application. - ---- - -# ๐ ๏ธ Useful Commands - -| Command | Description | -|----------|-------------| -| `npm run dev` | Start frontend locally | -| `npm run build` | Create production build | -| `npm run docker:dev` | Run Docker development environment | -| `npm run docker:prod` | Run Docker production environment | -| `npm run test` | Run frontend tests | -| `npm run test:backend` | Run backend tests | - ---- - ## ๐งช Backend Unit & Integration Testing with Jasmine This project uses the Jasmine framework for backend unit and integration tests. The tests cover: @@ -318,6 +140,3 @@ spec_files: [ โฌ๏ธ Back to Top
- - - diff --git a/backend/.env.example b/backend/.env.example deleted file mode 100644 index a46d9911..00000000 --- a/backend/.env.example +++ /dev/null @@ -1,37 +0,0 @@ -# --------------------------------------------------------------- -# Server -# --------------------------------------------------------------- -PORT=5000 -NODE_ENV=development - -# --------------------------------------------------------------- -# MongoDB -# --------------------------------------------------------------- -MONGO_URI=mongodb://127.0.0.1:27017/github_tracker - -# --------------------------------------------------------------- -# Session -# Generate a long random string for production, e.g.: -# node -e "console.log(require('crypto').randomBytes(64).toString('hex'))" -# --------------------------------------------------------------- -SESSION_SECRET=replace-with-a-long-random-string - -# --------------------------------------------------------------- -# CORS โ Frontend origin allowlist -# -# Set this to the exact URL of your frontend (no trailing slash). -# REQUIRED in production: the server will refuse to start without it. -# In development, the server defaults to http://localhost:5173 when -# this variable is not set. -# -# Examples: -# Development : FRONTEND_ORIGIN=http://localhost:5173 -# Production : FRONTEND_ORIGIN=https://app.example.com -# --------------------------------------------------------------- -FRONTEND_ORIGIN=http://localhost:5173 - -# --------------------------------------------------------------- -# Logging -# Accepted values: error | warn | info | debug -# --------------------------------------------------------------- -LOG_LEVEL=debug diff --git a/backend/config/validateEnv.js b/backend/config/validateEnv.js deleted file mode 100644 index fde3d9a7..00000000 --- a/backend/config/validateEnv.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Validates required environment variables before the server starts. - * Throws so callers can decide whether to log + exit or handle otherwise, - * which keeps the logic unit-testable without spawning child processes. - */ -function validateEnv() { - if (process.env.NODE_ENV === 'production' && !process.env.FRONTEND_ORIGIN) { - throw new Error( - 'FRONTEND_ORIGIN environment variable is required in production. ' + - 'Set it to the URL of your frontend (e.g., https://app.example.com).' - ); - } -} - -module.exports = { validateEnv }; diff --git a/backend/package.json b/backend/package.json index 747482ec..74ab9dd7 100644 --- a/backend/package.json +++ b/backend/package.json @@ -25,8 +25,6 @@ "zod": "^4.4.3" }, "devDependencies": { - "jasmine": "^5.0.0", - "nodemon": "^3.1.9", - "supertest": "^7.0.0" + "nodemon": "^3.1.9" } } diff --git a/backend/server.js b/backend/server.js index c7fa106c..48d6ccfb 100644 --- a/backend/server.js +++ b/backend/server.js @@ -6,62 +6,32 @@ const bodyParser = require('body-parser'); require('dotenv').config(); const cors = require('cors'); -const { validateEnv } = require('./config/validateEnv'); -const logger = require('./logger'); - -// Fail fast in production when required env vars are absent. -try { - validateEnv(); -} catch (err) { - logger.error(`[FATAL] ${err.message}`); - process.exit(1); -} - // Passport configuration require('./config/passportConfig'); -const app = express(); - -// In development, fall back to localhost:5173 if FRONTEND_ORIGIN is not set so -// that contributors can run the stack without a full .env file. -const corsOrigin = process.env.FRONTEND_ORIGIN || 'http://localhost:5173'; +const logger = require('./logger'); -if (!process.env.FRONTEND_ORIGIN) { - logger.warn( - 'FRONTEND_ORIGIN is not set; defaulting to http://localhost:5173. ' + - 'Set this variable in production.' - ); -} +const app = express(); -// CORS โ explicit allowlist with credentials support. -// A function-based origin is required so that the header is only set (and -// reflected) for allowed origins; a static string would send the header on -// every response regardless of the requesting origin. +// CORS configuration +const allowedOrigins = ['http://localhost:5173', 'https://github-spy.etlify.app']; app.use(cors({ - origin: (requestOrigin, callback) => { - // Allow same-origin requests (no Origin header) and the configured origin. - if (!requestOrigin || requestOrigin === corsOrigin) { - return callback(null, true); - } - callback(null, false); - }, - credentials: true, - methods: ['GET', 'POST'], - allowedHeaders: ['Content-Type'], + origin: function (origin, callback) { + if (!origin || allowedOrigins.indexOf(origin) !== -1) { + callback(null, true); + } else{ + callback(new Error('Blocked by CORS policy')); + } + }, + credentials: true })); // Middleware app.use(bodyParser.json()); app.use(session({ - secret: process.env.SESSION_SECRET, - resave: false, - saveUninitialized: false, - cookie: { - httpOnly: true, - // Only transmit the cookie over HTTPS in production. - secure: process.env.NODE_ENV === 'production', - sameSite: 'strict', - }, + secret: process.env.SESSION_SECRET, + resave: false, + saveUninitialized: false, })); app.use(passport.initialize()); app.use(passport.session()); @@ -72,10 +42,12 @@ app.use('/api/auth', authRoutes); // Connect to MongoDB mongoose.connect(process.env.MONGO_URI, {}).then(() => { - logger.info('Connected to MongoDB'); - app.listen(process.env.PORT, () => { - logger.info(`Server running on port ${process.env.PORT}`); - }); + logger.info('Connected to MongoDB'); + + const PORT = process.env.PORT || 5000; + app.listen(PORT, () => { + logger.info(`Server running on port ${PORT}`); + }); }).catch((err) => { - logger.error('MongoDB connection error', err); + logger.error('MongoDB connection error', err); }); diff --git a/index.html b/index.html index 57ad94cb..b6d940d0 100644 --- a/index.html +++ b/index.html @@ -4,9 +4,6 @@ - - -- > initialize tracking capabilities -
-
- Everything you need to track, analyze, and understand GitHub activity patterns.
+
+ Everything you need to track, analyze, and understand GitHub activity patterns
- {feature.description}
-
+ {feature.description}
+
- Monitor and analyze GitHub user activity with powerful insights.
- Perfect for developers, project managers, and teams who want to
- understand contribution patterns and repository engagement.
+
+
+ Monitor and analyze GitHub user activity with powerful insights. Perfect for developers,
+ project managers, and teams who want to understand contribution patterns and repository engagement.
- A clean three-step flow with a horizontal rhythm, subtle hierarchy, and just enough motion to feel polished.
+ return (
+
+ Get started in minutes with our simple three-step process
+
{step.description}
Powerful Features
+ {feature.title}
+
+ {/* LEFT COLUMN: Typography & CTA */}
+
Track GitHub Activity
-
+
Like Never Before
-
-
- How It Works
-
- How It Works
+
+
- {step.title}
-
-
- {step.title}
+