OCA is a backend API designed to support catalogs, querying, and data management for observatories and contextual variables. It provides an extensible architecture for working with scientific data products, metadata models, and semantic queries using a custom query language.
βββ jubapi/ # FastAPI server with controller/service/repository structure
βββ db/ # MongoDB cluster config, scripts, keyfile
βββ docs/ # Markdown documentation (arch, model, etc.)
βββ tests/ # Pytest test suite
βββ docker-compose.yml # OCA API definition
βββ cluster.yml # MongoDB cluster definition
βββ deploy.sh # Script for full deployment
βββ run_local.sh # Script to launch local dev server
βββ pyproject.toml # Poetry project file
βββ mkdocs.yml # MkDocs configuration for documentation
Before running the project, install dependencies and activate the development environment:
poetry install && poetry lock
poetry shellTo deploy all services required for the system to function properly:
chmod +x ./deploy.sh && ./deploy.shYou must use the script db/createkey.sh db/ folder, if you dont execute it in that path, you should move the keyfile to db/.
cd db && chmod +x ./createkey.sh && ./createkey.sh
#replication:
# replSetName: rs0
net:
bindIp: 0.0.0.0
port: 27017
#security:
#authorization: enabled
#keyFile: /etc/mongo/keyfiledocker compose -f cluster.yml up -dEnter to the first mongodb node <container_id with the actual identifier of the container running at 27017:
Find the container running MongoDB on port 27017:
docker psThen enter the container:
docker exec -it <container_id> shInside the MongoDB shell:
use admin;
db.createUser({
user: "oca",
pwd: "d22a75e9e729debc",
roles: [{ role: "root", db: "admin" }]
});Verify user creation:
db.getUsers();You should see something like:
{
users: [
{
_id: 'admin.oca',
userId: UUID('233cf8af-61d0-40ae-80e5-99bfa2031391'),
user: 'oca',
db: 'admin',
roles: [ { role: 'root', db: 'admin' } ],
mechanisms: [ 'SCRAM-SHA-1', 'SCRAM-SHA-256' ]
}
],
ok: 1
}docker compose -f cluster.yml downThen you must mofidy the db/oca-db-0.conf and enable only security like this:
#replication:
# replSetName: rs0
net:
bindIp: 0.0.0.0
port: 27017
security:
authorization: enabled
keyFile: /etc/mongo/keyfileRestart the cluster:
docker compose -f cluster.yml up -dThen verify if you can logging try first to get inside the terminal of the mongo db at 27017 and in the terminal of the mongo db execute this:
mongosh -u oca -p d22a75e9e729debc --authenticationDatabase adminyou must authenticated correctly. if you cannot authenticated please try again from the step (5)
chmod +x ./run_local.sh && ./run_local.sh
INFO: Will watch for changes in these directories:
INFO: Uvicorn running on http://0.0.0.0:5000 (Press CTRL+C to quit)
INFO: Started reloader process [6783] using WatchFiles
INFO: Started server process [6785]
INFO: Waiting for application startup.
INFO: Application startup complete
poetry add mkdocs --group=dev
mkdocs servepytest tests/<name_of_test_file>.py -s -vvvv
MIT License
Contributions are welcome and encouraged!
To contribute to this project:
-
Fork the Repository
Click the Fork button at the top-right of this repository on GitHub to create your own copy.
-
Clone Your Fork
git clone https://github.com/<your-username>/oca.git cd oca
-
Create a New Branch Use a descriptive branch name based on your contribution:
git checkout -b fix/bug-description
-
Make Your Changes Add new features, fix bugs, or improve documentation β all changes should happen in your fork and branch.
-
Commit Your Changes Follow conventional commit messages if possible:
git commit -am "fix(api): handle null value in query result" -
Push to Your Fork Once you've committed your changes locally, you need to upload (push) them to your remote fork on GitHub:
git push origin fix/bug-description
-
originis the default name for the remote that points to your fork (you can check with git remote -v) -
fix/bug-descriptionis the name of your local branchThis command sends your local branch to your GitHub fork under the same branch name.
π‘ If you've renamed your remote or you're unsure of the name, run:
git remote -v
This will show you the list of remotes and their corresponding URLs.
After pushing, your changes will appear in your GitHub fork, and youβll be able to open a pull request (PR) from that branch to the original repository.
- Open a Pull Request
-
Go to your fork on GitHub
-
Click "Compare & Pull Request"
-
Write a clear title and description
-
Submit it to the main branch of the original repository
-
β Wait for Review
Your changes will be reviewed, and you may be asked to make adjustments before merging.