A content management system built with Go backend and React frontend, containerized with Docker. This CMS is specifically designed for psychology services platform with features for psychologists and clients.
my-little-go-cms/
βββ cmd/ # Main application entrypoint
β βββ main.go
β
βββ frontend/ # React frontend application
β βββ src/
β β βββ components/ # Reusable UI components
β β βββ pages/ # Page components
β β βββ context/ # React context providers
β β βββ routes/ # Routing configuration
β β βββ utils/ # Utility functions
β βββ Dockerfile # Frontend Docker configuration
β βββ package.json
β
βββ internal/ # Go backend application
β βββ db/ # Database configuration
β βββ handlers/ # HTTP request handlers
β βββ middleware/ # HTTP middleware
β βββ models/ # Data models
β βββ utils/ # Utility functions
β
βββ templates/ # Email templates
βββ tests/ # Test files
β βββ unit_tests/ # Unit tests for handlers
β βββ ...
β
βββ Dockerfile # Backend Docker configuration
βββ docker-compose.yml # Docker compose configuration
βββ Makefile # Build and test commands
- User Management: Registration, authentication, profile management
- Admin Panel: Complete administrative interface
- News Management: Create, edit, publish news articles
- Skills System: Manage psychologist skills and categories
- Portfolio System: Psychologist portfolios with photo uploads
- Review System: Client reviews and ratings for psychologists
- Blog System: Psychologist personal blogs
- Clients: Can register, create profiles, leave reviews
- Psychologists: Can manage portfolios, skills, blog posts
- Administrators: Full system management access
- Moderators: Limited admin access
- Master: Super admin with all permissions
- User management (create, update, delete, status control)
- News management (create, edit, publish, home page display)
- Skills and categories management
- Subscription plans management
- Administrator management
- System analytics and statistics
- Authentication: JWT-based authentication
- File Upload: Image upload for portfolios
- Email Verification: User email verification system
- WYSIWYG Editor: Rich text editor for content creation
- Responsive Design: Mobile-friendly interface
- API Documentation: Swagger/OpenAPI documentation
- Docker and Docker Compose
- Git
- Clone the repository:
git clone https://github.com/yourusername/my-little-go-cms.git
cd my-little-go-cms
- Create and configure environment files:
For backend (.env
):
DB_HOST=mysql
DB_PORT=3306
DB_USER=testuser
DB_PASSWORD=testpass
DB_NAME=testdb
JWT_SECRET=your_secret_key
ADMIN_EMAIL=admin@example.com
ADMIN_PASSWORD=admin_password
For frontend (frontend/.env
):
REACT_APP_API_URL=http://localhost:8080
- Build and start the containers:
docker-compose up --build
The application will be available at:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8080
- Swagger Documentation: http://localhost:8080/swagger/index.html
If you want to run only the frontend for development, follow these steps:
-
Navigate to the
frontend
directory:cd frontend
-
Install dependencies:
npm install
-
Start the development server:
npm run dev
The frontend will be available at the address shown in the terminal (usually
http://localhost:5173
). Note that for the application to work fully, the backend must also be running (e.g., via Docker).
Build and start containers:
docker-compose up --build # Build and start all services
docker-compose up -d # Run in detached mode
Stop containers:
docker-compose down # Stop all services
View logs:
docker-compose logs -f # Follow logs from all services
docker-compose logs frontend # View frontend logs
docker-compose logs go-api # View backend logs
Restart specific service:
docker-compose restart frontend # Restart frontend
docker-compose restart go-api # Restart backend
The project includes a comprehensive test suite using Go's native testing package and testify/suite
.
# Run all tests
make test
# Or run tests for a specific package
go test ./tests/unit_tests/...
# Run tests with coverage report
make test-coverage
# Run tests with race condition detection
make test-race
The API documentation is available through Swagger UI at http://localhost:8080/swagger/index.html when running locally.
POST /api/login
- User loginPOST /api/register
- User registrationGET /api/verify
- Email verificationPOST /api/auth/refresh
- Refresh JWT token
GET /api/admin/users
- List all usersPOST /api/admin/users
- Create userPUT /api/admin/users/{id}
- Update userDELETE /api/admin/users/{id}
- Delete user
GET /api/admin/news
- List all newsPOST /api/admin/news
- Create newsPUT /api/admin/news/{id}
- Update newsDELETE /api/admin/news/{id}
- Delete news
GET /api/news
- Public news listGET /api/news/{id}
- Get specific newsGET /api/news/home
- News for home page
GET /api/admin/skills
- List skillsPOST /api/admin/skills
- Create skillPUT /api/admin/skills/{id}
- Update skillDELETE /api/admin/skills/{id}
- Delete skillGET /api/admin/skills/categories
- List skill categoriesPOST /api/admin/skills/categories
- Create skill categoryPUT /api/admin/skills/categories/{id}
- Update skill categoryDELETE /api/admin/skills/categories/{id}
- Delete skill category
GET /api/users/self
- Get own profilePUT /api/users/self/updateuser
- Update own profileGET /api/users/{id}
- Get any user's public profilePUT /api/users/self/portfolio
- Create/Update portfolioPOST /api/users/portfolio/photo
- Upload portfolio photoDELETE /api/users/portfolio/photo/{photo_id}
- Delete portfolio photoPUT /api/users/self/skills
- Set own skillsGET /api/users/skills
- Get all skills grouped by categoryGET /api/users/{user_id}/skills
- Get a specific user's skills
POST /api/users/blog
- Create a blog postGET /api/users/blog/{psychologist_id}
- Get all posts by a psychologistGET /api/users/blog/post/{blog_id}
- Get a single blog postPUT /api/users/blog/post/{blog_id}
- Update a blog postDELETE /api/users/blog/post/{blog_id}
- Delete a blog post
POST /api/reviews/{psychologist_id}
- Create a review for a psychologist
- Make changes to the code
- Rebuild and restart the containers:
docker-compose down
docker-compose up --build
The frontend is built with:
- React 18 with TypeScript
- Tailwind CSS for styling
- React Router for navigation
- Context API for state management
- Vite for build tooling
- WYSIWYG Editor for rich text editing
Key frontend features:
- Responsive design for all devices
- Admin dashboard with statistics
- User profile management
- News and blog management
- Image upload and management
- Real-time form validation
The backend is built with:
- Go 1.21+ with Chi router
- GORM for database ORM
- JWT for authentication
- MySQL as database
- Swagger for API documentation
- Docker for containerization
Key backend features:
- RESTful API design
- Role-based access control
- File upload handling
- Email verification system
- Database migrations
- Comprehensive logging
The system uses MySQL with the following main tables:
users
- User accounts and profilesadministrators
- Admin accountsnews
- News articlesskills
- Psychologist skillscategories
- Skill categoriesportfolios
- Psychologist portfoliosphotos
- Portfolio photosreviews
- Client reviewsratings
- Psychologist ratingsblog_posts
- Blog articlesplans
- Subscription planspsychologist_skills
- Join table for users and skills
- JWT-based authentication with refresh tokens
- Password hashing with bcrypt
- Email verification for new accounts
- Role-based access control
- Input validation and sanitization
- CORS configuration
- Rate limiting (recommended for production)
For production deployment:
- Update environment variables for production
- Configure SSL/TLS certificates
- Set up reverse proxy (nginx recommended)
- Configure database backup strategy
- Set up monitoring and logging
- Configure email service for notifications
If you encounter issues:
- Check container status:
docker-compose ps
- View container logs:
docker-compose logs -f
- Rebuild containers:
docker-compose down
docker-compose up --build
-
Check database connection from within the container.
-
Reset database (development only):
docker-compose down -v
docker-compose up --build
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
make test
- Submit a pull request
MIT License - see LICENSE file for details
For support and questions:
- Create an issue in the GitHub repository
- Check the API documentation at
/swagger/index.html
- Review the test files in
tests/unit_tests/
for usage examples