Cerebrum is the core backend API for Graymattermetrics. It manages user authentication and crud actions for Cogspeed.
- Web Framework: FastAPI
- Database ORM: SQLAlchemy (with
asyncio) - Testing: Pytest
- Containerization: Docker & Docker Compose
- Code Quality: Black, pre-commit
- CI/CD: GitHub Actions
The recommended way to run the application for local development is using Docker Compose.
-
Clone the repository:
git clone https://github.com/[your-username]/cerebrum.git cd cerebrum -
Create the environment file: An environment file is required to store sensitive information like database credentials. An example file is provided.
cp .env.sample .env
You can review and modify the variables in the
.envfile if needed, but the default values are configured to work with the provided Docker Compose setup. -
Build and run the containers: This command will build the Docker images for the API and the database, and start them in the background.
docker-compose up --build -d
The API will now be running and available at http://localhost:6060.
You can view the auto-generated interactive documentation (provided by FastAPI/Swagger) at http://localhost:6060/docs.
Tests are managed with Pytest and can be run inside the running API container. This ensures the tests are executed in the same environment as the application.
To run the full test suite:
docker-compose exec api pytestThis project uses pre-commit to enforce code style and quality checks before code is committed. The primary formatter is Black.
To enable these checks for your local development:
-
Install pre-commit:
pip install pre-commit
-
Install the Git hooks:
pre-commit install
This repository uses GitHub Actions for its Continuous Integration (CI) pipeline. The workflows are defined in the .github/workflows/ directory.
The pipeline automatically runs all tests and linting checks on every push to the main branch and on all pull requests.