A powerful project lock management system that provides API endpoints for controlling and checking project lock status. Perfect for managing deployment gates, feature flags, or any system that needs centralized lock control.
Dashboard showing project lock statuses
Create new projects with lock control
Easy lock/unlock toggle interface
- π Lock Management - Create and manage multiple projects with lock/unlock capabilities
- π Public API - RESTful API endpoints for external projects to check lock status
- π Secure Authentication - User authentication with NextAuth.js (only owners can modify projects)
- β‘ Real-time Updates - Instant UI updates when toggling lock status
- π Modern Dashboard - Clean purple-themed interface to view and manage all your projects
- π¨ Beautiful UI - Solid color design with smooth animations and hover effects
- π‘οΈ Authorization - Only project owners can change lock status
- π API Integration - Easy-to-copy API endpoints for each project
- Next.js 15 - React framework
- NextAuth.js 5 - Authentication
- Prisma - Database ORM with PostgreSQL
- tRPC - End-to-end typesafe API
- Tailwind CSS - Utility-first CSS framework
- PostgreSQL - Relational database
- TypeScript - Type safety
- Node.js 18+
- PostgreSQL database
- npm/yarn/pnpm
- Clone the repository:
git clone https://github.com/Subtilizer28/LockSystem.git
cd LockSystem- Install dependencies:
npm install- Set up environment variables:
Create a .env file in the root directory:
DATABASE_URL="postgresql://user:password@localhost:5432/locksystem"
NEXTAUTH_SECRET="your-secret-key-here" # Generate with: openssl rand -base64 32
NEXTAUTH_URL="http://localhost:3000"- Set up the database:
npm run db:pushThis will create all necessary tables in your PostgreSQL database.
- Start the development server:
npm run devVisit http://localhost:3000 and create an account to get started!
The LockSystem provides a public API endpoint that external projects can use to check lock status.
Endpoint: GET /api/lock-status?projectId={id}
Description: Check if a project is locked or unlocked.
Parameters:
projectId(query parameter, required): The ID of the project to check
Example Request:
curl "http://localhost:3000/api/lock-status?projectId=1"Success Response (200):
{
"projectId": 1,
"name": "My Project",
"locked": true,
"status": "locked"
}Error Responses:
Missing projectId (400):
{
"error": "projectId is required"
}Invalid projectId (400):
{
"error": "projectId must be a valid number"
}Project not found (404):
{
"error": "Project not found"
}Endpoint: POST /api/lock-status
Description: Check if a project is locked or unlocked using POST method.
Request Body:
{
"projectId": 1
}Example Request:
curl -X POST http://localhost:3000/api/lock-status \
-H "Content-Type: application/json" \
-d '{"projectId": 1}'Response: Same as GET method
// Using fetch API
async function checkLockStatus(projectId) {
const response = await fetch(
`http://localhost:3000/api/lock-status?projectId=${projectId}`
);
const data = await response.json();
if (data.locked) {
console.log(`Project ${data.name} is LOCKED`);
// Stop deployment or return error
return false;
} else {
console.log(`Project ${data.name} is UNLOCKED`);
// Proceed with deployment
return true;
}
}
// Use in your deployment script
const canDeploy = await checkLockStatus(1);
if (!canDeploy) {
process.exit(1);
}import requests
def check_lock_status(project_id):
response = requests.get(
f"http://localhost:3000/api/lock-status?projectId={project_id}"
)
data = response.json()
if response.status_code == 200:
if data['locked']:
print(f"Project {data['name']} is LOCKED")
return False
else:
print(f"Project {data['name']} is UNLOCKED")
return True
else:
print(f"Error: {data.get('error', 'Unknown error')}")
return False
# Use in your deployment script
if not check_lock_status(1):
exit(1)#!/bin/bash
PROJECT_ID=1
API_URL="http://localhost:3000/api/lock-status?projectId=${PROJECT_ID}"
response=$(curl -s "$API_URL")
locked=$(echo "$response" | jq -r '.locked')
if [ "$locked" = "true" ]; then
echo "β Project is LOCKED. Deployment blocked."
exit 1
else
echo "β
Project is UNLOCKED. Proceeding with deployment."
# Continue with deployment
finame: Deploy
on:
push:
branches: [main]
jobs:
check-lock:
runs-on: ubuntu-latest
steps:
- name: Check Lock Status
id: lock-check
run: |
response=$(curl -s "https://your-domain.com/api/lock-status?projectId=1")
locked=$(echo "$response" | jq -r '.locked')
if [ "$locked" = "true" ]; then
echo "Project is locked. Stopping deployment."
exit 1
fi
- name: Deploy
if: success()
run: |
echo "Deploying application..."
# Your deployment commands heremodel Project {
id Int @id @default(autoincrement())
name String
description String?
ownerId String
owner User @relation(fields: [ownerId], references: [id])
locked Boolean @default(true) // Projects locked by default
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model User {
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
password String?
image String?
accounts Account[]
projects Project[]
sessions Session[]
}Security Note: Only the project owner (user who created the project) can lock/unlock their projects. The system enforces ownership verification on all mutation operations.
npm run dev- Start development server with Turbonpm run build- Build for productionnpm run start- Start production servernpm run lint- Run ESLintnpm run lint:fix- Fix ESLint errorsnpm run typecheck- Run TypeScript type checkingnpm run db:push- Push schema changes to databasenpm run db:studio- Open Prisma Studionpm run format:write- Format code with Prettiernpm run format:check- Check code formatting
locksystem/
βββ prisma/
β βββ schema.prisma # Database schema
βββ src/
β βββ app/
β β βββ api/
β β β βββ auth/ # Authentication routes
β β β βββ lock-status/ # Public lock check API
β β β βββ trpc/ # tRPC routes
β β βββ auth/
β β β βββ login/ # Login page
β β β βββ signup/ # Signup page
β β βββ create/ # Create project page
β β βββ layout.tsx # Root layout
β β βββ page.tsx # Dashboard
β βββ server/
β β βββ api/
β β β βββ routers/
β β β β βββ project.ts # Project router
β β β βββ root.ts # Root router
β β β βββ trpc.ts # tRPC config
β β βββ auth/ # Auth configuration
β β βββ db.ts # Database client
β βββ trpc/ # tRPC client setup
βββ public/ # Static files
- Push your code to GitHub
- Import your repository in Vercel
- Add environment variables
- Deploy
docker build -t locksystem .
docker run -p 3000:3000 locksystem| Variable | Description | Required | Example |
|---|---|---|---|
DATABASE_URL |
PostgreSQL connection string | Yes | postgresql://user:password@localhost:5432/locksystem |
NEXTAUTH_SECRET |
Secret for NextAuth.js (generate with openssl rand -base64 32) |
Yes | your-secret-key-here |
NEXTAUTH_URL |
Your application URL | Yes | http://localhost:3000 |
- β Password Hashing - User passwords encrypted with bcrypt
- β Session Management - Secure session handling with NextAuth.js
- β Owner Authorization - Only project owners can modify lock status
- β Protected Routes - Authentication required for all project operations
- β Type Safety - Full TypeScript implementation with tRPC
- β Input Validation - Zod schemas validate all inputs
- User Registration - Users create accounts with email and password
- Create Projects - Authenticated users can create projects (locked by default)
- Manage Locks - Only the project owner can toggle lock/unlock status
- Public API - External services check lock status via public API endpoint
- Access Control - Dashboard shows only user's own projects
- Deployment Gates: Prevent deployments when a project is locked
- Feature Flags: Control feature availability across environments
- Maintenance Mode: Lock projects during maintenance windows
- Release Control: Coordinate releases across multiple services
- CI/CD Integration: Integrate with your CI/CD pipeline to block automated deployments
- Emergency Stop: Quickly lock all projects to prevent changes during incidents
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.
For issues and questions, please open an issue on GitHub.
- GitHub: ashtonmths
Built with β€οΈ using the T3 Stack