Content Management System for Chop Logic Portal
A modern, headless CMS built with Strapi and TypeScript, designed to manage content for the Chop Logic Portal. This project provides a flexible and scalable backend solution for content management with built-in API functionality, user permissions management, and cloud deployment capabilities.
- Features
- Prerequisites
- Project Structure
- Getting Started
- Development Workflow
- Available Scripts
- Code Quality
- Testing
- Strapi CMS Development Flow
- Contributing
- License
- Headless CMS: Strapi provides a flexible, API-first content management system
- User Permissions: Built-in user authentication and role-based access control via the Users Permissions plugin
- Cloud Support: Integrated Strapi Cloud plugin for easy deployment
- TypeScript: Full TypeScript support for type-safe development
- Testing: Jest testing framework with coverage reporting
- Code Quality: Biome for fast code formatting and linting
- Git Hooks: Husky and lint-staged for automated pre-commit checks
- Conventional Commits: CommitLint ensures consistent commit messages
- Node.js: >= 20.0.0, <= 24.x.x
- npm: >= 6.0.0
- SQLite (better-sqlite3): Default database driver
chop-logic-cms/
βββ src/
β βββ index.ts # Main entry point
β βββ api/ # API routes and controllers
β β βββ article/ # Article content type
β β βββ controllers/ # Request handlers
β β βββ routes/ # Route definitions
β β βββ services/ # Business logic
β β βββ content-types/ # Content type schemas
β βββ admin/ # Admin panel customizations
β βββ extensions/ # Plugin extensions
β βββ utils/ # Utility functions
β βββ __tests__/ # Test files
βββ types/
β βββ generated/ # Auto-generated TypeScript types
βββ config/ # Strapi configuration files
β βββ api.ts # API configuration
β βββ database.ts # Database configuration
β βββ middlewares.ts # Middleware setup
β βββ plugins.ts # Plugin configuration
β βββ admin.ts # Admin panel configuration
β βββ server.ts # Server configuration
βββ database/
β βββ migrations/ # Database migrations
βββ public/
β βββ uploads/ # Uploaded files
βββ coverage/ # Test coverage reports
βββ package.json # Project dependencies and scripts
βββ tsconfig.json # TypeScript configuration
βββ jest.config.js # Jest testing configuration
βββ biome.json # Biome formatter/linter configuration
βββ README.md # Project documentation
npm installCreate a .env file in the root directory with necessary environment variables:
# Example .env configuration
NODE_ENV=developmentnpm run devThe Strapi admin panel will be available at http://localhost:1337/admin.
- REST API:
http://localhost:1337/api/
-
Start the development server:
npm run dev
This launches Strapi in development mode with hot-reload enabled.
-
Create or modify content types:
- Use the Strapi admin panel at
http://localhost:1337/admin - Navigate to Content-type Builder to create/modify schemas
- Use the Strapi admin panel at
-
Write custom API logic:
- Create controllers in
src/api/[content-type]/controllers/ - Add services in
src/api/[content-type]/services/ - Define routes in
src/api/[content-type]/routes/
- Create controllers in
-
Run code quality checks:
npm run lint npm run format npm run typecheck
-
Run tests:
npm run test # Watch mode npm run test:coverage # With coverage report
All code must adhere to:
- Biome formatting standards
- TypeScript strict mode
- ESLint/Biome rules with no errors
- Jest test coverage
Git hooks (via Husky) automatically enforce these on commit.
| Script | Command | Description |
|---|---|---|
| Development | ||
dev |
strapi develop |
Start Strapi in development mode with file watching |
start |
strapi start |
Start Strapi in production mode |
console |
strapi console |
Open interactive Strapi console |
| Building & Deployment | ||
build |
strapi build |
Build the admin panel and backend for production |
deploy |
strapi deploy |
Deploy to Strapi Cloud |
upgrade |
npx @strapi/upgrade latest |
Upgrade Strapi to the latest version |
upgrade:dry |
npx @strapi/upgrade latest --dry |
Preview upgrade changes without applying |
| Code Quality | ||
lint |
biome check |
Check code for linting issues |
lint:errors |
biome check --diagnostic-level error --max-diagnostics 100 |
Check and display only errors (max 100) |
lint:warnings |
biome check --diagnostic-level warn --max-diagnostics 100 |
Check and display warnings (max 100) |
lint:fix |
biome check --write |
Auto-fix linting issues |
format |
biome format --write |
Auto-format code files |
typecheck |
tsc --pretty --noEmit |
Type-check TypeScript without emitting files |
| Testing | ||
test |
jest --watch |
Run tests in watch mode |
test:ci |
jest --passWithNoTests --runInBand |
Run tests in CI environment (sequential) |
test:coverage |
jest --coverage |
Run tests with coverage report |
| Utilities | ||
strapi |
strapi |
Direct Strapi CLI access |
prepare |
husky |
Setup Husky git hooks |
The project uses Jest for unit and integration testing.
-
Watch mode (for development):
npm run test -
Coverage report:
npm run test:coverage
Reports are generated in the
coverage/directory. -
CI mode (for automated testing):
npm run test:ci
Test files are located in src/__tests__/ and should follow the naming convention: *.test.ts or *.spec.ts.
Strapi follows a layered architecture pattern:
Routes β Controllers β Services β Models
- Routes: Define API endpoints (e.g.,
GET /api/articles) - Controllers: Handle HTTP requests and responses
- Services: Contain business logic and database operations
- Models: Define content structure and relationships
Use the Strapi admin panel's Content-type Builder:
- Navigate to
http://localhost:1337/admin/content-manager - Click "Create new content type"
- Define fields (text, rich text, relations, etc.)
- Configure permissions in the Settings tab
Auto-generated files (after creating a content type):
src/api/[content-type]/models/- Database modelssrc/api/[content-type]/services/- Default servicesrc/api/[content-type]/controllers/- Default controllersrc/api/[content-type]/routes/- Default route definitions
Controllers handle business logic and HTTP responses:
// src/api/article/controllers/article.ts
import { factories } from '@strapi/strapi';
export default factories.createCoreController('api::article.article', {
async find(ctx) {
// Custom find logic
return await super.find(ctx);
},
async create(ctx) {
// Custom create logic
return await super.create(ctx);
}
});Services encapsulate reusable business logic:
// src/api/article/services/article.ts
import { factories } from '@strapi/strapi';
export default factories.createCoreService('api::article.article', {
async getPublishedArticles() {
return await strapi.entityService.findMany('api::article.article', {
filters: { publishedAt: { $ne: null } }
});
}
});Routes map HTTP requests to controllers:
// src/api/article/routes/article.ts
export default {
routes: [
{
method: 'GET',
path: '/articles/published',
handler: 'article.find',
config: { auth: false, policies: [] }
}
]
};Configure role-based access control:
- Admin panel β Settings β Roles
- Define permissions for each content type
- Map routes to specific roles (Public, Authenticated, Admin, etc.)
Access the API at http://localhost:1337/api/:
# Get articles
curl http://localhost:1337/api/articles
# Create article
curl -X POST http://localhost:1337/api/articles \
-H "Content-Type: application/json" \
-d '{"data": {"title": "My Article"}}'Strapi manages the database schema automatically based on content types. For custom migrations:
# Generate migration
npm run strapi migrate:create <migration-name>
# Run migrations
npm run strapi migrate:upPlugins are configured in config/plugins.ts:
- @strapi/plugin-users-permissions: User authentication and roles
- @strapi/plugin-cloud: Cloud deployment integration
- Custom plugins: Can be placed in
src/plugins/or installed from npm
Configuration files in config/ support environment variables:
// config/database.ts - automatically loads based on NODE_ENV
export default ({ env }) => ({
defaultConnection: 'default',
connections: {
default: {
connector: 'bookshelf',
settings: {
client: 'sqlite',
filename: env('DATABASE_FILENAME', '.tmp/data.db'),
}
}
}
});This project enforces code quality standards using:
Fast formatter and linter for JavaScript/TypeScript:
# Format code
npm run format
# Check for issues
npm run lint
# Auto-fix issues
npm run lint:fixConfiguration: biome.json
Static type checking:
npm run typecheckConfiguration: tsconfig.json
Automatic pre-commit checks:
- Type-checks all
.tsfiles - Formats and lints
.js,.ts,.json, etc. - Prevents commits with errors
- @strapi/strapi - Headless CMS framework
- @strapi/plugin-users-permissions - User authentication
- @strapi/plugin-cloud - Cloud deployment
- better-sqlite3 - SQLite database driver
- React (^18.0.0) - Admin panel UI library
- styled-components (^6.0.0) - CSS-in-JS styling
- TypeScript (^5) - Static type checking
- Jest - Testing framework
- Biome - Code formatter and linter
- Husky - Git hooks
- CommitLint - Commit message validation
npm run buildThis creates an optimized production build.
npm run deployRequires authentication with Strapi Cloud account.
Create a Dockerfile in the root directory for containerized deployment:
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
EXPOSE 1337
CMD ["npm", "start"]This project uses Conventional Commits enforced by CommitLint:
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
Valid types: feat, fix, docs, style, refactor, test, chore
Example:
feat(article): add article search functionality
Implement full-text search for articles
- Add search endpoint
- Create search service
Closes #123
- Create a feature branch:
git checkout -b feat/my-feature - Make changes and commit with conventional messages
- Push to GitHub
- Create a pull request with description
- Ensure all checks pass (tests, linting, types)
This project is licensed under the MIT License. See the LICENSE file for details.
Dmitrii Suroviagin
- Strapi Documentation
- Strapi Community
- REST API Documentation
- Content Type Builder Guide
- Users & Permissions Plugin
Last Updated: January 28, 2026