General Information Service - API Adapter for OpenGIN (Open General Information Network)
A FastAPI-based service that provides data processing and API endpoints for government information management, including entity attributes, organizational charts, and data visualization capabilities.
- Entity Management: Create and manage government entities (departments, ministries, etc.)
- Attribute Processing: Process and store entity attributes with metadata
- Organizational Charts: Generate timeline-based organizational structures
- Data Visualization: Transform data for chart generation
- Category Management: Hierarchical category creation and relationships
- RESTful APIs: Clean, documented API endpoints
- Python 3.8 to 3.13
- pip (Python package installer)
- Git
git clone <repository-url>
cd GI-SERVICE# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activatepip install -r requirements.txtCreate a .env file in the root directory:
# Base URLs for CRUD and Query services
BASE_URL_CRUD=http://0.0.0.0:8080
BASE_URL_QUERY=http://0.0.0.0:8081
# Optional: Add other environment variables as needed# Development server
uvicorn main:app --reload --host 0.0.0.0 --port 8000
# Or using the Procfile (for production)
uvicorn main:app --host 0.0.0.0 --port $PORTThe API will be available at: http://localhost:8000
Once the server is running, you can access:
- Interactive API Docs:
http://localhost:8000/docs(Swagger UI) - Alternative Docs:
http://localhost:8000/redoc(ReDoc)
| Method | Endpoint | Description |
|---|---|---|
GET |
/allAttributes |
Get all available attributes |
POST |
/data/entity/{entityId} |
Get attributes for a specific entity |
POST |
/data/attribute/{entityId} |
Get data for a specific attribute |
| Method | Endpoint | Description |
|---|---|---|
POST |
/data/writeAttributes |
Process and write attributes to entities |
| Method | Endpoint | Description |
|---|---|---|
GET |
/data/orgchart/timeline |
Get timeline for organizational chart |
POST |
/data/orgchart/ministries |
Get ministries for selected date |
POST |
/data/orgchart/departments |
Get departments for selected ministry |
curl http://localhost:8000/docscurl -X GET "http://localhost:8000/allAttributes" \
-H "accept: application/json"curl -X POST "http://localhost:8000/data/entity/your-entity-id" \
-H "Content-Type: application/json" \
-d '{
"entityId": "your-entity-id",
"filters": {}
}'curl -X POST "http://localhost:8000/data/writeAttributes" \
-H "Content-Type: application/json" \
-d '{
"base_url": "/path/to/your/data"
}'GI-SERVICE/
βββ src/
β βββ dependencies/ # Dependency injection
β βββ models/ # Pydantic models
β βββ routers/ # API route handlers
β βββ services/ # Business logic
βββ chartFactory/ # Chart generation utilities
βββ test/ # Test data and scripts
βββ main.py # FastAPI application entry point
βββ requirements.txt # Python dependencies
βββ Procfile # Deployment configuration
βββ README.md # This file
| Variable | Description | Default |
|---|---|---|
BASE_URL_CRUD |
CRUD service base URL | http://0.0.0.0:8080 |
BASE_URL_QUERY |
Query service base URL | http://0.0.0.0:8081 |
The service processes data in the following format:
{
"attributeName": "example_attribute",
"relatedEntityName": "Department Name",
"relation": "2022 - Government - Minister - Department",
"attributeData": {
"columns": ["col1", "col2"],
"rows": [["val1", "val2"]]
},
"attributeMetadata": {
"storage_type": "tabular",
"dataset_name": "Example Dataset"
}
}- Install Heroku CLI
- Login to Heroku:
heroku login - Create app:
heroku create your-app-name - Deploy:
git push heroku main
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]- Port already in use: Change the port in the uvicorn command
- Environment variables not loaded: Ensure
.envfile is in the root directory - Import errors: Make sure virtual environment is activated
- API not responding: Check if the CRUD and Query services are running
# Run with debug logging
uvicorn main:app --reload --log-level debug- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Commit changes:
git commit -am 'Add feature' - Push to branch:
git push origin feature-name - Submit a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Create an issue in the repository
- Contact the development team
Happy Coding! π