A modern blog platform with a Next.js frontend and NestJS API backend, built as an Nx monorepo.
SutraMD is a modern blogging platform that allows users to create, manage, and publish markdown-based content. The application provides a clean user interface for writing and organizing blog posts, with robust backend services for content management.
This project is built as an Nx monorepo with the following main applications:
[Frontend (Next.js)] <---HTTP/REST---> [API (NestJS)] <---EdgeDB/GEL---> [Database]
│ │
│ │
└──────────shared types──────────────┘
(through libs)
Frontend:
Backend:
Tooling:
Clone the repository:
tsx
git clone https://github.com/yourusername/sutramd.git cd sutramd
Install dependencies:
tsx
yarn install
Set up environment variables:
tsx
# For API cp apps/api/.env.example apps/api/.env # Update with your database credentials
Start the EdgeDB database:
tsx
# If you have Docker installed docker-compose up -d edgedb # Or if you have EdgeDB CLI edgedb project init
Build the projects:
tsx
yarn build
To start both the API and frontend in development mode:
tsx
# Start everything yarn dev # Start only API yarn start:api # Start only frontend yarn start:frontend
This project uses Nx for managing the monorepo. Some useful commands:
tsx
# Run a command on a specific project nx run [project]:[command] # Run a command only on projects affected by your changes nx affected --target=[command] # Visualize your project dependency graph nx graph
sutramd/
├── apps/
│ ├── api/ # NestJS Backend
│ │ ├── src/
│ │ │ ├── blog/ # Blog functionality
│ │ │ ├── auth/ # Authentication services
│ │ │ ├── user/ # User management
│ │ │ ├── geldata/ # EdgeDB connection services
│ │ │ └── dbschema/ # Generated database schema
│ │ └── project.json # API build configuration
│ ├── frontend/ # Next.js Frontend
│ │ ├── src/
│ │ │ ├── pages/ # Next.js page components
│ │ │ ├── components/# Reusable React components
│ │ │ └── icons/ # UI icons
│ │ ├── lib/ # Utility functions
│ │ └── styles/ # CSS and styling
│ └── api-e2e/ # API End-to-End Tests
├── libs/
│ └── gel/ # Shared EdgeDB/GEL Library
└── nx.json # Nx Configuration
Command | Description |
---|---|
yarn dev | Start both frontend and API in development mode |
yarn build | Build all projects |
yarn build:api | Build only the API |
yarn build:frontend | Build only the frontend |
yarn start:api | Start the API server |
yarn start:frontend | Start the frontend server |
yarn lint | Run linting on all projects |
yarn test | Run tests on all projects |
yarn nx graph | Visualize the project dependency graph |
SutraMD uses EdgeDB with the GEL client for database operations. The database schema is defined in the API project and schemas are automatically generated.
The main entities in the database are:
To run database migrations:
tsx
cd apps/api yarn migrate:dev
The API documentation is available through Swagger UI when running the API server:
http://localhost:3001/docs
Key API endpoints:
/blog
: Blog post management/auth
: Authentication/user
: User managementBuild all projects:
tsx
yarn build
Set production environment variables:
# In your production environment
NODE_ENV=production
tsx
git checkout -b feature/your-feature-name
tsx
yarn affected:test yarn affected:lint
tsx
git commit -m "Add some feature"
tsx
git push origin feature/your-feature-name